The S32 SDK provides a Peripheral Abstraction Layer for the output compare mode of S32 SDK devices.
The OC PAL driver allows to set pin, clear pin or toggle pin. It was designed to be portable across all platforms and IPs which support FTM, eMIOS and eTIMER.
Unlike the other drivers, OC PAL modules need to include a configuration file named oc_pal_cfg.h. This one allows the user to specify which IPs are used. The following code example shows how to configure one instance for each available OC IPs.
The following table contains the matching between platforms and available IPs
IP/MCU | S32K116 | S32K118 | S32K142 | S32K144 | S32K146 | S32K148 | MPC5748G | MPC5746C | MPC5744P |
---|---|---|---|---|---|---|---|---|---|
FTM_OC | YES | YES | YES | YES | YES | YES | NO | NO | NO |
eMIOS_OC | NO | NO | NO | NO | NO | NO | YES | YES | NO |
eTIMER | NO | NO | NO | NO | NO | NO | NO | NO | YES |
In order to use the OC PAL driver it must be first initialized, using OC_Init() function. Once initialized, it should be de-initialized before initialized again for the same OC module instance, using OC_Deinit(). The initialization function does the following operations:
This function will disable the output compare mode. The driver can't be used again until reinitialized. All register are reset to default value and counter is stopped.
This function will set the channel is in the output compare mode.
This function will set the channel is used in GPIO mode or other peripheral.
This function is used to forces the output pin to a specified value. It can be used to control the output pin value when the OC channel is disabled.
This function will set the action executed on a compare match value to set output pin, clear output pin, toggle output pin.
This function will update the value of an output compare channel to the counter matches to this value.
Data Structures | |
struct | oc_output_ch_param_t |
The configuration structure of output compare parameters for each channel. More... | |
struct | oc_config_t |
Defines the configuration structures are used in the output compare mode. More... | |
Enumerations | |
enum | oc_option_mode_t { OC_DISABLE_OUTPUT = 0x00U, OC_TOGGLE_ON_MATCH = 0x01U, OC_CLEAR_ON_MATCH = 0x02U, OC_SET_ON_MATCH = 0x03U } |
The type of comparison for output compare mode Implements : oc_option_mode_t_Class. More... | |
enum | oc_option_update_t { OC_RELATIVE_VALUE = 0x00U, OC_ABSOLUTE_VALUE = 0x01U } |
The type of update on the channel match Implements : oc_option_mode_t_Class. More... | |
Functions | |
status_t | OC_Init (const oc_instance_t *const instance, const oc_config_t *const configPtr) |
Initializes the output compare mode. More... | |
status_t | OC_Deinit (const oc_instance_t *const instance) |
De-initialize the output compare instance. More... | |
void | OC_StartChannel (const oc_instance_t *const instance, const uint8_t channel) |
Start the counter. More... | |
void | OC_StopChannel (const oc_instance_t *const instance, const uint8_t channel) |
Stop the counter. More... | |
status_t | OC_SetOutputState (const oc_instance_t *const instance, const uint8_t channel, bool outputValue) |
Control the channel output by software. More... | |
status_t | OC_SetOutputAction (const oc_instance_t *const instance, const uint8_t channel, oc_option_mode_t channelMode) |
Set the operation mode of channel output. More... | |
status_t | OC_SetCompareValue (const oc_instance_t *const instance, const uint8_t channel, uint32_t nextCompareMatchValue, oc_option_update_t typeOfupdate) |
Update the match value on the channel. More... | |
void | OC_EnableNotification (const oc_instance_t *const instance, const uint8_t channel) |
Enable channel notifications. More... | |
void | OC_DisableNotification (const oc_instance_t *const instance, const uint8_t channel) |
Disable channel notifications. More... | |
enum oc_option_mode_t |
enum oc_option_update_t |
status_t OC_Deinit | ( | const oc_instance_t *const | instance | ) |
De-initialize the output compare instance.
This function will disable the output compare mode. The driver can't be used again until reinitialized. The context structure is no longer needed by the driver and can be freed after calling this function.
[in] | instance | The output compare instance number. |
void OC_DisableNotification | ( | const oc_instance_t *const | instance, |
const uint8_t | channel | ||
) |
void OC_EnableNotification | ( | const oc_instance_t *const | instance, |
const uint8_t | channel | ||
) |
status_t OC_Init | ( | const oc_instance_t *const | instance, |
const oc_config_t *const | configPtr | ||
) |
Initializes the output compare mode.
This function will initialize the OC PAL instance, including the other platform specific HW units used together in the output compare mode. This function configures a group of channels in instance to set, clear toggle the output signal.
[in] | instance | The output compare instance number. |
[in] | configPtr | The pointer to configuration structure. |
status_t OC_SetCompareValue | ( | const oc_instance_t *const | instance, |
const uint8_t | channel, | ||
uint32_t | nextCompareMatchValue, | ||
oc_option_update_t | typeOfupdate | ||
) |
Update the match value on the channel.
This function will update the value of an output compare channel to the counter matches to this value.
[in] | instance | The output compare instance number. |
[in] | channel | The channel number. |
[in] | nextCompareMatchValue | The timer value in ticks until the next compare match event should be appeared. |
[in] | typeOfupdate | The type of update:
|
status_t OC_SetOutputAction | ( | const oc_instance_t *const | instance, |
const uint8_t | channel, | ||
oc_option_mode_t | channelMode | ||
) |
Set the operation mode of channel output.
This function will set the action executed on a compare match value to set output pin, clear output pin, toggle output pin.
[in] | instance | The output compare instance number. |
[in] | channel | The channel number. |
[in] | channelMode | The channel mode in output compare:
|
status_t OC_SetOutputState | ( | const oc_instance_t *const | instance, |
const uint8_t | channel, | ||
bool | outputValue | ||
) |
Control the channel output by software.
This function is used to forces the output pin to a specified value. It can be used to control the output pin value when the OC channel is disabled.
[in] | instance | The output compare instance number. |
[in] | channel | The channel number. |
[in] | outputValue | The output value:
|
void OC_StartChannel | ( | const oc_instance_t *const | instance, |
const uint8_t | channel | ||
) |
void OC_StopChannel | ( | const oc_instance_t *const | instance, |
const uint8_t | channel | ||
) |