The S32 SDK provides a Peripheral Abstraction Layer for the input capture mode of S32 SDK devices.
The IC PAL driver allows to detect the input signal and measure pulse width or period of the channel input signal. It was designed to be portable across all platforms and IPs which support FTM , eMIOS and ETIMER.
Unlike the other drivers, IC PAL modules need to include a configuration file named ic_pal_cfg.h, which allows the user to specify which IPs are used. The following code example shows how to configure one instance for each available IC IPs.
The following table contains the matching between platforms and available IPs
IP/MCU | S32K116 | S32K118 | S32K142 | S32K144 | S32K146 | S32K148 | MPC5748G | MPC5746C | MPC5744P |
---|---|---|---|---|---|---|---|---|---|
FTM_IC | YES | YES | YES | YES | YES | YES | NO | NO | NO |
eMIOS_IC | NO | NO | NO | NO | NO | NO | YES | YES | NO |
ETIMER | NO | NO | NO | NO | NO | NO | NO | NO | YES |
In order to use the IC PAL driver it must be first initialized, using IC_Init() function. Once initialized, it should be de-initialized before initialized again for the same IC module instance, using IC_Deinit(). The initialization function does the following operations:
This function will disable the input capture 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 input capture mode.
This function will set the channel is used in GPIO mode or other peripheral.
The pulse width measurement and the period measurement can be made after the channel input is in the input capture mode. The value is last captured by count. Note that to get true value of measurement at the first of pulse, please use the IC_GetValueMeasurement function in interrupt.
The notification is executed in the callback application with the IC_EVENT_MEASUREMENT_COMPLETE event which indicates that the measurement of input signal is completed.
The callback application will be not executed when the notification is disabled.
Data Structures | |
struct | ic_input_ch_param_t |
The configuration structure of input capture parameters for each channel. More... | |
struct | ic_config_t |
Defines the configuration structures are used in the input capture mode. More... | |
struct | ic_pal_state_t |
The internal context structure. More... | |
Enumerations | |
enum | ic_option_mode_t { IC_DISABLE_OPERATION = 0x00U, IC_TIMESTAMP_RISING_EDGE = 0x01U, IC_TIMESTAMP_FALLING_EDGE = 0x02U, IC_TIMESTAMP_BOTH_EDGES = 0x03U, IC_MEASURE_RISING_EDGE_PERIOD = 0x04U, IC_MEASURE_FALLING_EDGE_PERIOD = 0x05U, IC_MEASURE_PULSE_HIGH = 0x06U, IC_MEASURE_PULSE_LOW = 0x07U } |
The measurement type for input capture mode Implements : ic_option_mode_t_Class. More... | |
Functions | |
status_t | IC_Init (const ic_instance_t *const instance, const ic_config_t *configPtr) |
Initializes the input capture mode. More... | |
status_t | IC_Deinit (const ic_instance_t *const instance) |
De-initialize a input capture instance. More... | |
void | IC_StartChannel (const ic_instance_t *const instance, uint8_t channel) |
Start the counter. More... | |
void | IC_StopChannel (const ic_instance_t *const instance, uint8_t channel) |
Stop the counter. More... | |
status_t | IC_SetChannelMode (const ic_instance_t *const instance, uint8_t channel, ic_option_mode_t channelMode) |
Get the measured value. More... | |
uint16_t | IC_GetMeasurement (const ic_instance_t *const instance, uint8_t channel) |
Get the measured value. More... | |
void | IC_EnableNotification (const ic_instance_t *const instance, uint8_t channel) |
Enable channel notifications. More... | |
void | IC_DisableNotification (const ic_instance_t *const instance, uint8_t channel) |
Disable channel notifications. More... | |
enum ic_option_mode_t |
The measurement type for input capture mode Implements : ic_option_mode_t_Class.
status_t IC_Deinit | ( | const ic_instance_t *const | instance | ) |
De-initialize a input capture instance.
This function will disable the input capture 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 pointer to instance number structure. |
void IC_DisableNotification | ( | const ic_instance_t *const | instance, |
uint8_t | channel | ||
) |
void IC_EnableNotification | ( | const ic_instance_t *const | instance, |
uint8_t | channel | ||
) |
uint16_t IC_GetMeasurement | ( | const ic_instance_t *const | instance, |
uint8_t | channel | ||
) |
status_t IC_Init | ( | const ic_instance_t *const | instance, |
const ic_config_t * | configPtr | ||
) |
Initializes the input capture mode.
This function will initialize the IC PAL instance, including the other platform specific HW units used together in the input capture mode. This function configures a group of channels in instance to detect or measure the input signal.
[in] | instance | The pointer to instance number structure. |
[in] | configPtr | The pointer to configuration structure. |
status_t IC_SetChannelMode | ( | const ic_instance_t *const | instance, |
uint8_t | channel, | ||
ic_option_mode_t | channelMode | ||
) |
void IC_StartChannel | ( | const ic_instance_t *const | instance, |
uint8_t | channel | ||
) |
void IC_StopChannel | ( | const ic_instance_t *const | instance, |
uint8_t | channel | ||
) |