![]() |
PDL for FM0+
Version1.0
Peripheral Driverl Library for FM0+
|
Data Structures | |
struct | stc_mft_icu_config |
Structure of Mft icu configuration. More... | |
struct | stc_mft_icu_intern_data |
Icu instance internal data, storing internal information for each enabled Icu instance. More... | |
struct | stc_mft_icu_instance_data |
Mft_icu instance data type. More... | |
Defines | |
#define | stc_mftn_icu_t FM0P_MFT_ICU_TypeDef |
#define | MFT0_ICU (*((volatile stc_mftn_icu_t *) FM0P_MFT0_ICU_BASE)) |
#define | MFT1_ICU (*((volatile stc_mftn_icu_t *) FM0P_MFT1_ICU_BASE)) |
#define | MFT2_ICU (*((volatile stc_mftn_icu_t *) FM0P_MFT2_ICU_BASE)) |
#define | MFT_ICU_CH0 0u |
#define | MFT_ICU_CH1 1u |
#define | MFT_ICU_CH2 2u |
#define | MFT_ICU_CH3 3u |
#define | MFT_ICU_CHx_MAX 3u |
#define | MFT_ICU_INSTANCE_COUNT |
Typedefs | |
typedef enum en_icu_instance_index | en_icu_instance_index_t |
Enumeration to define an index for each ICU instance. | |
typedef enum en_mft_icu_frt | en_mft_icu_frt_t |
Frt channel. | |
typedef enum en_mft_icu_mode | en_mft_icu_mode_t |
Icu mode. | |
typedef enum en_icu_edge | en_mft_icu_edge_t |
Icu edge. | |
typedef struct stc_mft_icu_config | stc_mft_icu_config_t |
Structure of Mft icu configuration. | |
typedef struct stc_mft_icu_intern_data | stc_mft_icu_intern_data_t |
Icu instance internal data, storing internal information for each enabled Icu instance. | |
typedef struct stc_mft_icu_instance_data | stc_mft_icu_instance_data_t |
Mft_icu instance data type. | |
Enumerations | |
enum | en_icu_instance_index { IcuInstanceIndexIcu0, IcuInstanceIndexIcu1, IcuInstanceIndexIcu2 } |
Enumeration to define an index for each ICU instance. More... | |
enum | en_mft_icu_frt { Frt0ToIcu = 0u, Frt1ToIcu = 1u, Frt2ToIcu = 2u, IcuFrtToExt0 = 3u, IcuFrtToExt1 = 4u } |
Frt channel. More... | |
enum | en_mft_icu_mode { IcuDisable = 0u, IcuRisingDetect = 1u, IcuFallingDetect = 2u, IcuBothDetect = 3u } |
Icu mode. More... | |
enum | en_icu_edge { IcuFallingEdge = 0u, IcuRisingEdge = 1u } |
Icu edge. More... | |
Functions | |
static stc_mft_icu_intern_data_t * | MftIcuGetInternDataPtr (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu) |
Return the internal data for a certain MFT_ICU instance. | |
static void | Mft_Icu_InitIrq (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu) |
Device dependent initialization of interrupts according CMSIS with level defined in pdl.h. | |
static void | Mft_Icu_DeInitIrq (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu) |
Device dependent de-initialization of interrupts according CMSIS. | |
void | Mft_Icu_IrqHandler (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, stc_mft_icu_intern_data_t *pstcMftIcuInternData) |
Device Interrupt handler. | |
en_result_t | Mft_Icu_SelFrt (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch, en_mft_icu_frt_t enFrt) |
Select FRTx channel to connect to ICUx. | |
en_result_t | Mft_Icu_ConfigDetectMode (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch, en_mft_icu_mode_t enMode) |
Configure ICU module detection mode(different edge) | |
en_result_t | Mft_Icu_EnableInt (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch, func_ptr_t pfnCallback) |
Enable Mft Icu interrupt. | |
en_result_t | Mft_Icu_DisableInt (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch) |
Disable Mft Icu interrupt and release callback function. | |
en_int_flag_t | Mft_Icu_GetIntFlag (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch) |
Get interrupt flag. | |
en_result_t | Mft_Icu_ClrIntFlag (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch) |
Clear interrupt flag. | |
en_mft_icu_edge_t | Mft_Icu_GetLastEdge (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch) |
Get the latest captured edge type. | |
uint16_t | Mft_Icu_GetCaptureData (volatile FM0P_MFT_ICU_TypeDef *pstcMftIcu, uint8_t u8Ch) |
Readout captured data value. | |
Variables | |
stc_mft_icu_instance_data_t | m_astcMftIcuInstanceDataLut [(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT0_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT1_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT2_ICU==PDL_ON)] |
stc_mft_icu_instance_data_t | m_astcMftIcuInstanceDataLut [(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT0_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT1_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT2_ICU==PDL_ON)] |
Provided functions of ICU module:
How to use ICU module?
Before using OCU, a FRT used to connect with applying OCU must be initialed. For how to configure FRT, see the description in the mft_frt.h. With Mft_Icu_SelFrt(), a FRT can be connected with OCU.
A ICU interrupt can be enabled by the function Mft_Icu_EnableInt(). This function can set callback function for each channel too.
After above setting, calling Mft_Icu_ConfigDetectMode() will select a detection mode and start ICU operation at the same time. Following detection mode cna be select:
With interrupt mode, the interrupt occurs when valid edge is detected, the interrupt flag will be cleared and run into user interrupt callback function. In the callback function, the capture value can be read with Mft_Icu_GetCaptureData().
With polling mode, user can use Mft_Icu_GetIntFlag() to check if the interrupt occurs, and clear the interrupt flag by Mft_Icu_ClrIntFlag(). when interrupt is detected, the capture value can be read with Mft_Icu_GetCaptureData().
When the valid edge is detected, Mft_Icu_GetLastEdge() can get the edge information of last valid edge.
When stopping the ICU, use Mft_Icu_ConfigDetectMode() to disable ICU and Mft_Icu_DisableInt() to disable ICU interrupt.
#define MFT0_ICU (*((volatile stc_mftn_icu_t *) FM0P_MFT0_ICU_BASE)) |
Definition at line 115 of file mft_icu.h.
Referenced by Mft_Icu_DeInitIrq(), Mft_Icu_InitIrq(), and MFT_IPC_IRQHandler().
#define MFT1_ICU (*((volatile stc_mftn_icu_t *) FM0P_MFT1_ICU_BASE)) |
Definition at line 116 of file mft_icu.h.
Referenced by Mft_Icu_DeInitIrq(), Mft_Icu_InitIrq(), and MFT_IPC_IRQHandler().
#define MFT2_ICU (*((volatile stc_mftn_icu_t *) FM0P_MFT2_ICU_BASE)) |
Definition at line 117 of file mft_icu.h.
Referenced by Mft_Icu_DeInitIrq(), Mft_Icu_InitIrq(), and MFT_IPC_IRQHandler().
#define MFT_ICU_CH0 0u |
Definition at line 119 of file mft_icu.h.
Referenced by Mft_Icu_ClrIntFlag(), Mft_Icu_ConfigDetectMode(), Mft_Icu_DisableInt(), Mft_Icu_EnableInt(), Mft_Icu_GetCaptureData(), Mft_Icu_GetIntFlag(), Mft_Icu_GetLastEdge(), and Mft_Icu_SelFrt().
#define MFT_ICU_CH1 1u |
Definition at line 120 of file mft_icu.h.
Referenced by Mft_Icu_ClrIntFlag(), Mft_Icu_ConfigDetectMode(), Mft_Icu_DisableInt(), Mft_Icu_EnableInt(), Mft_Icu_GetCaptureData(), Mft_Icu_GetIntFlag(), Mft_Icu_GetLastEdge(), and Mft_Icu_SelFrt().
#define MFT_ICU_CH2 2u |
Definition at line 121 of file mft_icu.h.
Referenced by Mft_Icu_ClrIntFlag(), Mft_Icu_ConfigDetectMode(), Mft_Icu_DisableInt(), Mft_Icu_EnableInt(), Mft_Icu_GetCaptureData(), Mft_Icu_GetIntFlag(), Mft_Icu_GetLastEdge(), and Mft_Icu_SelFrt().
#define MFT_ICU_CH3 3u |
Definition at line 122 of file mft_icu.h.
Referenced by Mft_Icu_ClrIntFlag(), Mft_Icu_ConfigDetectMode(), Mft_Icu_DisableInt(), Mft_Icu_EnableInt(), Mft_Icu_GetCaptureData(), Mft_Icu_GetIntFlag(), Mft_Icu_GetLastEdge(), and Mft_Icu_SelFrt().
#define MFT_ICU_CHx_MAX 3u |
Definition at line 124 of file mft_icu.h.
Referenced by Mft_Icu_ClrIntFlag(), Mft_Icu_ConfigDetectMode(), Mft_Icu_DisableInt(), Mft_Icu_EnableInt(), and Mft_Icu_SelFrt().
#define MFT_ICU_INSTANCE_COUNT |
(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT0_ICU == PDL_ON) + \ (uint8_t)(PDL_PERIPHERAL_ENABLE_MFT1_ICU == PDL_ON) + \ (uint8_t)(PDL_PERIPHERAL_ENABLE_MFT2_ICU == PDL_ON)
Definition at line 126 of file mft_icu.h.
Referenced by MftIcuGetInternDataPtr().
#define stc_mftn_icu_t FM0P_MFT_ICU_TypeDef |
Definition at line 114 of file mft_icu.h.
Referenced by Mft_Icu_DeInitIrq(), Mft_Icu_DisableInt(), Mft_Icu_EnableInt(), Mft_Icu_InitIrq(), and MFT_IPC_IRQHandler().
typedef enum en_icu_instance_index en_icu_instance_index_t |
Enumeration to define an index for each ICU instance.
typedef enum en_icu_edge en_mft_icu_edge_t |
Icu edge.
To select Icu edge
typedef enum en_mft_icu_frt en_mft_icu_frt_t |
Frt channel.
To select FRT channel to connect to ICU
typedef enum en_mft_icu_mode en_mft_icu_mode_t |
Icu mode.
To select Icu edge detection mode
typedef struct stc_mft_icu_config stc_mft_icu_config_t |
Structure of Mft icu configuration.
typedef struct stc_mft_icu_instance_data stc_mft_icu_instance_data_t |
Mft_icu instance data type.
typedef struct stc_mft_icu_intern_data stc_mft_icu_intern_data_t |
Icu instance internal data, storing internal information for each enabled Icu instance.
enum en_icu_edge |
enum en_mft_icu_frt |
enum en_mft_icu_mode |
en_result_t Mft_Icu_ClrIntFlag | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch | ||
) |
Clear interrupt flag.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
Ok | Interrupt flag is clear |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 574 of file mft_icu.c.
References ErrorInvalidParameter, MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, MFT_ICU_CH3, MFT_ICU_CHx_MAX, and Ok.
en_result_t Mft_Icu_ConfigDetectMode | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch, | ||
en_mft_icu_mode_t | enMode | ||
) |
Configure ICU module detection mode(different edge)
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
[in] | enMode | Icu detect mode
|
Ok | ICU detection mode selected |
ErrorInvalidParameter | If one of following conditions are met:
|
mode set
Definition at line 340 of file mft_icu.c.
References ErrorInvalidParameter, IcuBothDetect, MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, MFT_ICU_CH3, MFT_ICU_CHx_MAX, and Ok.
static void Mft_Icu_DeInitIrq | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu | ) | [static] |
Device dependent de-initialization of interrupts according CMSIS.
[in] | pstcMftIcu | Pointer to ICU instance |
Definition at line 221 of file mft_icu.c.
References MFT0_ICU, MFT1_ICU, MFT2_ICU, PDL_DEFAULT_INTERRUPT_LEVEL, and stc_mftn_icu_t.
Referenced by Mft_Icu_DisableInt().
en_result_t Mft_Icu_DisableInt | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch | ||
) |
Disable Mft Icu interrupt and release callback function.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
Ok | ICU interrupt are disabled |
ErrorInvalidParameter | If one of following conditions are met:
|
Definition at line 467 of file mft_icu.c.
References ErrorInvalidParameter, MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, MFT_ICU_CH3, MFT_ICU_CHx_MAX, Mft_Icu_DeInitIrq(), MftIcuGetInternDataPtr(), Ok, stc_mft_icu_intern_data::pfnIcu0Callback, stc_mft_icu_intern_data::pfnIcu1Callback, stc_mft_icu_intern_data::pfnIcu2Callback, stc_mft_icu_intern_data::pfnIcu3Callback, and stc_mftn_icu_t.
en_result_t Mft_Icu_EnableInt | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch, | ||
func_ptr_t | pfnCallback | ||
) |
Enable Mft Icu interrupt.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
[in] | pfnCallback | register callback function
|
Ok | ICU interrupt are enabled |
ErrorInvalidParameter | If one of following conditions are met:
|
Interrupt
Definition at line 401 of file mft_icu.c.
References ErrorInvalidParameter, MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, MFT_ICU_CH3, MFT_ICU_CHx_MAX, Mft_Icu_InitIrq(), MftIcuGetInternDataPtr(), Ok, stc_mft_icu_intern_data::pfnIcu0Callback, stc_mft_icu_intern_data::pfnIcu1Callback, stc_mft_icu_intern_data::pfnIcu2Callback, stc_mft_icu_intern_data::pfnIcu3Callback, and stc_mftn_icu_t.
uint16_t Mft_Icu_GetCaptureData | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch | ||
) |
Readout captured data value.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
Count read
Definition at line 660 of file mft_icu.c.
References MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, and MFT_ICU_CH3.
en_int_flag_t Mft_Icu_GetIntFlag | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch | ||
) |
Get interrupt flag.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
FALSE | ICU active edge is not detected |
TRUE | ICU active edge is detected |
Definition at line 529 of file mft_icu.c.
References MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, MFT_ICU_CH3, PdlClr, and PdlSet.
en_mft_icu_edge_t Mft_Icu_GetLastEdge | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch | ||
) |
Get the latest captured edge type.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
Status read/write
Definition at line 620 of file mft_icu.c.
References IcuFallingEdge, IcuRisingEdge, MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, and MFT_ICU_CH3.
static void Mft_Icu_InitIrq | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu | ) | [static] |
Device dependent initialization of interrupts according CMSIS with level defined in pdl.h.
pstcMftIcu | Pointer to ICU instance |
Definition at line 202 of file mft_icu.c.
References MFT0_ICU, MFT1_ICU, MFT2_ICU, PDL_IRQ_LEVEL_MFT_ICU, and stc_mftn_icu_t.
Referenced by Mft_Icu_EnableInt().
void Mft_Icu_IrqHandler | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
stc_mft_icu_intern_data_t * | pstcMftIcuInternData | ||
) |
Device Interrupt handler.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | pstcMftIcuInternData | Pointer to intern data |
IRQ handler
Definition at line 154 of file mft_icu.c.
References stc_mft_icu_intern_data::pfnIcu0Callback, stc_mft_icu_intern_data::pfnIcu1Callback, stc_mft_icu_intern_data::pfnIcu2Callback, stc_mft_icu_intern_data::pfnIcu3Callback, and TRUE.
Referenced by MFT_IPC_IRQHandler().
en_result_t Mft_Icu_SelFrt | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu, |
uint8_t | u8Ch, | ||
en_mft_icu_frt_t | enFrt | ||
) |
Select FRTx channel to connect to ICUx.
[in] | pstcMftIcu | Pointer to ICU instance |
[in] | u8Ch | Mft Icu channel
|
[in] | enFrt | Frt channel number
|
Ok | FRT channel selected |
ErrorInvalidParameter | If one of following conditions are met:
|
C binding of definitions if building with C++ compiler Clock
Definition at line 272 of file mft_icu.c.
References ErrorInvalidParameter, IcuFrtToExt1, MFT_ICU_CH0, MFT_ICU_CH1, MFT_ICU_CH2, MFT_ICU_CH3, MFT_ICU_CHx_MAX, Ok, and TRUE.
static stc_mft_icu_intern_data_t * MftIcuGetInternDataPtr | ( | volatile FM0P_MFT_ICU_TypeDef * | pstcMftIcu | ) | [static] |
Return the internal data for a certain MFT_ICU instance.
pstcMftIcu | Pointer to MftIcu instance |
Definition at line 130 of file mft_icu.c.
References MFT_ICU_INSTANCE_COUNT, and stc_mft_icu_instance_data::stcInternData.
Referenced by Mft_Icu_DisableInt(), and Mft_Icu_EnableInt().
stc_mft_icu_instance_data_t m_astcMftIcuInstanceDataLut[(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT0_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT1_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT2_ICU==PDL_ON)] |
{ { & (*((volatile FM0P_MFT_ICU_TypeDef *) FM0P_MFT0_ICU_BASE)) , {NULL,NULL,NULL,NULL} }, { & (*((volatile FM0P_MFT_ICU_TypeDef *) FM0P_MFT1_ICU_BASE)) , {NULL,NULL,NULL,NULL} }, { & (*((volatile FM0P_MFT_ICU_TypeDef *) FM0P_MFT2_ICU_BASE)) , {NULL,NULL,NULL,NULL} }, }
Look-up table for all enabled MFT_ICU instances and their internal data
Definition at line 74 of file mft_icu.c.
Referenced by MFT_IPC_IRQHandler().
stc_mft_icu_instance_data_t m_astcMftIcuInstanceDataLut[(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT0_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT1_ICU==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_MFT2_ICU==PDL_ON)] |
Look-up table for all enabled MFT_ICU instances and their internal data
Definition at line 74 of file mft_icu.c.
Referenced by MFT_IPC_IRQHandler().