![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
How to use ADCMP module. More...
Data Structures | |
| struct | stc_mft_adcmp_config |
| Define Mft_adcmp configure parameters. More... | |
| struct | stc_mft_adcmp_func |
| Define Mft_adcmp functions. More... | |
| struct | stc_mft_adcmp_fm3_config |
| Define Mft_adcmp compatible fm3 configure parameters. More... | |
Macros | |
| #define | MFT_ADCMP_CH0 0 |
| #define | MFT_ADCMP_CH1 1 |
| #define | MFT_ADCMP_CH2 2 |
| #define | MFT_ADCMP_CH3 3 |
| #define | MFT_ADCMP_CH4 4 |
| #define | MFT_ADCMP_CH5 5 |
| #define | MFT_ADCMP_CH10 0 |
| #define | MFT_ADCMP_CH32 1 |
| #define | MFT_ADCMP_CH54 2 |
| #define | MFT_ADCMP_CH_MAX 5 |
| #define | MFT_ADCMP_CPCH_MAX 2 |
| #define | stc_mftn_adcmp_t FM4_MFT_ADCMP_TypeDef |
| #define | MFT0_ADCMP (*(volatile stc_mftn_adcmp_t *) FM4_MFT0_ADCMP_BASE) |
| #define | MFT1_ADCMP (*(volatile stc_mftn_adcmp_t *) FM4_MFT1_ADCMP_BASE) |
| #define | MFT2_ADCMP (*(volatile stc_mftn_adcmp_t *) FM4_MFT2_ADCMP_BASE) |
Typedefs | |
| typedef enum en_adcmp_frt | en_adcmp_frt_t |
| Define Frt channel connect to Adcmp. More... | |
| typedef enum en_adcmp_fm3_frt | en_adcmp_fm3_frt_t |
| Define Frt channel with FM3 mode connect to Adcmp. More... | |
| typedef enum en_adcmp_buf | en_adcmp_buf_t |
| Define Adcmp buffer type. More... | |
| typedef enum en_adcmp_trig_channel | en_adcmp_start_trig_t |
| Define Mft Adcmp output start trig channel. More... | |
| typedef enum en_adcmp_trig_sel | en_adcmp_trig_sel_t |
| Define Mft Adcmp trig mode. More... | |
| typedef enum en_adcmp_mode | en_adcmp_mode_t |
| Define Adcmp running mode. More... | |
| typedef enum en_adcmp_occp_sel | en_adcmp_occp_sel_t |
| Define Occp channel. More... | |
| typedef struct stc_mft_adcmp_config | stc_mft_adcmp_config_t |
| Define Mft_adcmp configure parameters. More... | |
| typedef struct stc_mft_adcmp_func | stc_mft_adcmp_func_t |
| Define Mft_adcmp functions. More... | |
| typedef enum en_adcmp_fm3_mode | en_adcmp_fm3_mode_t |
| Define Mft_adcmp compatible fm3 mode. More... | |
| typedef struct stc_mft_adcmp_fm3_config | stc_mft_adcmp_fm3_config_t |
| Define Mft_adcmp compatible fm3 configure parameters. More... | |
Functions | |
| en_result_t | Mft_Adcmp_Init (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, stc_mft_adcmp_config_t *pstcConfig) |
| Device dependent initialization of Mft adcmp module. More... | |
| en_result_t | Mft_Adcmp_EnableOperation (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, stc_mft_adcmp_func_t *pstcFunc) |
| Enable Mft Adcmp operations. More... | |
| en_result_t | Mft_Adcmp_DisableOperation (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, stc_mft_adcmp_func_t *pstcFunc) |
| Disable Mft Adcmp operations. More... | |
| en_result_t | Mft_Adcmp_WriteAcmp (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, uint16_t u16AcmpVal) |
| Write compare and offset value to ACMP. More... | |
| uint16_t | Mft_Adcmp_ReadAcmp (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch) |
| Read compare and offset value of ACMP. More... | |
| en_result_t | Mft_Adcmp_Fm3_Init (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh, stc_mft_adcmp_fm3_config_t *pstcConfig) |
| Mft Adcmp fm3 compatible initialization. More... | |
| en_result_t | Mft_Adcmp_Fm3_EnableOperation (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh) |
| Mft Adcmp fm3 compatible mode configuration and enable operation. More... | |
| en_result_t | Mft_Adcmp_Fm3_DisableOperation (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh) |
| Dis-configurate Mft Adcmp fm3 compatible fucntion and disable operation. More... | |
| en_result_t | Mft_Adcmp_Fm3_WriteAccp (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh, uint16_t u16AccpVal) |
| Mft Adcmp fm3 compatible mode, write Accp register. More... | |
| uint16_t | Mft_Adcmp_Fm3_ReadAccp (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh) |
| Mft Adcmp fm3 compatible mode, read Accp register stored value. More... | |
| en_result_t | Mft_Adcmp_Fm3_WriteAccpdn (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh, uint16_t u16AccpdnVal) |
| Mft Adcmp fm3 compatible mode, write Accpdn register. More... | |
| uint16_t | Mft_Adcmp_Fm3_ReadAccpdn (volatile FM4_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh) |
| Mft Adcmp fm3 compatible mode, read Accpdn register stored value. More... | |
How to use ADCMP module.
Provided functions of ADCMP module:
Two modes including normal mode and offset mode can be configured for ADCMP. This module should be used with ADC.
Before using ADCMP, a FRT used to connect with applying ADCMP must be initialed. For how to configure FRT, see the description in the mft_frt.h. In the offset mode, a OCU should also be used and initialed. For how to configure OCU, see the description in the mft_ocu.h
Mft_Adcmp_Init() must be used for configuration of a ADCMP channel with a structure of the type stc_mft_adcmp_config_t.
With Mft_Adcmp_WriteAcmp() the ADC start compare value is set to the value given in the parameter Mft_Adcmp_WriteAcmp::u16AcmpVal. Whether the compare value is modified directly depends on buffer function.
After above setting, calling Mft_Adcmp_EnableOperation() will start ADCMP.
When stopping the OCU, use Mft_Adcmp_DisableOperation() to disable ADCMP.
In addition, the module is also compatible with FM3 usage.
How to use ADCMP module with FM3 compatibility function
Before using ADCMP, a FRT used to connect with applying ADCMP must be initialed. For how to configure FRT, see the description in the mft_frt.h.
Mft_Adcmp_Fm3_Init() must be used for configuration of a ADCMP channel with a structure of the type stc_mft_adcmp_fm3_config_t.
With Mft_Adcmp_Fm3_WriteAccp() the ADC start up compare value is set to the value given in the parameter Mft_Adcmp_WriteAcmp::u16AccpVal. With Mft_Adcmp_Fm3_ReadAccp() the ADC start up compare value is read.
With Mft_Adcmp_Fm3_WriteAccpdn() the ADC start down compare value is set to the value given in the parameter Mft_Adcmp_WriteAcmp::u16AccpVal. With Mft_Adcmp_Fm3_ReadAccpdn() the ADC start down compare value is read.
| #define MFT0_ADCMP (*(volatile stc_mftn_adcmp_t *) FM4_MFT0_ADCMP_BASE) |
Definition at line 145 of file mft_adcmp.h.
| #define MFT1_ADCMP (*(volatile stc_mftn_adcmp_t *) FM4_MFT1_ADCMP_BASE) |
Definition at line 146 of file mft_adcmp.h.
| #define MFT2_ADCMP (*(volatile stc_mftn_adcmp_t *) FM4_MFT2_ADCMP_BASE) |
Definition at line 147 of file mft_adcmp.h.
| #define MFT_ADCMP_CH0 0 |
Definition at line 127 of file mft_adcmp.h.
| #define MFT_ADCMP_CH1 1 |
Definition at line 128 of file mft_adcmp.h.
| #define MFT_ADCMP_CH10 0 |
Definition at line 134 of file mft_adcmp.h.
Referenced by Mft_Adcmp_Fm3_DisableOperation(), Mft_Adcmp_Fm3_EnableOperation(), and Mft_Adcmp_Fm3_Init().
| #define MFT_ADCMP_CH2 2 |
Definition at line 129 of file mft_adcmp.h.
| #define MFT_ADCMP_CH3 3 |
Definition at line 130 of file mft_adcmp.h.
| #define MFT_ADCMP_CH32 1 |
Definition at line 135 of file mft_adcmp.h.
Referenced by Mft_Adcmp_Fm3_DisableOperation(), Mft_Adcmp_Fm3_EnableOperation(), and Mft_Adcmp_Fm3_Init().
| #define MFT_ADCMP_CH4 4 |
Definition at line 131 of file mft_adcmp.h.
| #define MFT_ADCMP_CH5 5 |
Definition at line 132 of file mft_adcmp.h.
| #define MFT_ADCMP_CH54 2 |
Definition at line 136 of file mft_adcmp.h.
Referenced by Mft_Adcmp_Fm3_DisableOperation(), Mft_Adcmp_Fm3_EnableOperation(), and Mft_Adcmp_Fm3_Init().
| #define MFT_ADCMP_CH_MAX 5 |
Definition at line 138 of file mft_adcmp.h.
Referenced by Mft_Adcmp_DisableOperation(), Mft_Adcmp_EnableOperation(), Mft_Adcmp_Init(), Mft_Adcmp_ReadAcmp(), and Mft_Adcmp_WriteAcmp().
| #define MFT_ADCMP_CPCH_MAX 2 |
Definition at line 139 of file mft_adcmp.h.
Referenced by Mft_Adcmp_Fm3_DisableOperation(), Mft_Adcmp_Fm3_EnableOperation(), Mft_Adcmp_Fm3_ReadAccp(), Mft_Adcmp_Fm3_ReadAccpdn(), Mft_Adcmp_Fm3_WriteAccp(), and Mft_Adcmp_Fm3_WriteAccpdn().
| #define stc_mftn_adcmp_t FM4_MFT_ADCMP_TypeDef |
Definition at line 143 of file mft_adcmp.h.
| typedef enum en_adcmp_buf en_adcmp_buf_t |
Define Adcmp buffer type.
| typedef enum en_adcmp_fm3_frt en_adcmp_fm3_frt_t |
Define Frt channel with FM3 mode connect to Adcmp.
| typedef enum en_adcmp_fm3_mode en_adcmp_fm3_mode_t |
Define Mft_adcmp compatible fm3 mode.
| typedef enum en_adcmp_frt en_adcmp_frt_t |
Define Frt channel connect to Adcmp.
| typedef enum en_adcmp_mode en_adcmp_mode_t |
Define Adcmp running mode.
| typedef enum en_adcmp_occp_sel en_adcmp_occp_sel_t |
Define Occp channel.
| typedef enum en_adcmp_trig_channel en_adcmp_start_trig_t |
Define Mft Adcmp output start trig channel.
| typedef enum en_adcmp_trig_sel en_adcmp_trig_sel_t |
Define Mft Adcmp trig mode.
| typedef struct stc_mft_adcmp_config stc_mft_adcmp_config_t |
Define Mft_adcmp configure parameters.
| typedef struct stc_mft_adcmp_fm3_config stc_mft_adcmp_fm3_config_t |
Define Mft_adcmp compatible fm3 configure parameters.
| typedef struct stc_mft_adcmp_func stc_mft_adcmp_func_t |
Define Mft_adcmp functions.
| enum en_adcmp_buf |
Define Adcmp buffer type.
Definition at line 178 of file mft_adcmp.h.
| enum en_adcmp_fm3_frt |
Define Frt channel with FM3 mode connect to Adcmp.
| Enumerator | |
|---|---|
| Frt1ToAdcmpFm3 |
connect Frt channel 1 to Icu |
| Frt2ToAdcmpFm3 |
connect Frt channel 2 to Icu |
Definition at line 167 of file mft_adcmp.h.
| enum en_adcmp_fm3_mode |
Define Mft_adcmp compatible fm3 mode.
Definition at line 266 of file mft_adcmp.h.
| enum en_adcmp_frt |
Define Frt channel connect to Adcmp.
Definition at line 153 of file mft_adcmp.h.
| enum en_adcmp_mode |
Define Adcmp running mode.
| Enumerator | |
|---|---|
| AdcmpNormalMode |
select Adcmp Normal mode |
| AdcmpOffsetMode |
select Adcmp Offset mode |
Definition at line 221 of file mft_adcmp.h.
| enum en_adcmp_occp_sel |
Define Occp channel.
| Enumerator | |
|---|---|
| AdcmpSelOccp0 |
select Occp0 channel |
| AdcmpSelOccp1 |
select Occp1 channel |
Definition at line 231 of file mft_adcmp.h.
Define Mft Adcmp output start trig channel.
Definition at line 191 of file mft_adcmp.h.
| enum en_adcmp_trig_sel |
Define Mft Adcmp trig mode.
Definition at line 207 of file mft_adcmp.h.
| en_result_t Mft_Adcmp_DisableOperation | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8Ch, | ||
| stc_mft_adcmp_func_t * | pstcFunc | ||
| ) |
Disable Mft Adcmp operations.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8Ch | Mft Adcmp channel
|
| [in] | pstcFunc | Mft Adcmp function |
Definition at line 230 of file mft_adcmp.c.
References ErrorInvalidParameter, MFT_ADCMP_CH_MAX, and Ok.
| en_result_t Mft_Adcmp_EnableOperation | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8Ch, | ||
| stc_mft_adcmp_func_t * | pstcFunc | ||
| ) |
Enable Mft Adcmp operations.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8Ch | Mft Adcmp channel
|
| [in] | pstcFunc | Mft Adcmp function |
Definition at line 196 of file mft_adcmp.c.
References stc_mft_adcmp_func::bDownEn, stc_mft_adcmp_func::bPeakEn, stc_mft_adcmp_func::bUpEn, stc_mft_adcmp_func::bZeroEn, ErrorInvalidParameter, MFT_ADCMP_CH_MAX, and Ok.
| en_result_t Mft_Adcmp_Fm3_DisableOperation | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh | ||
| ) |
Dis-configurate Mft Adcmp fm3 compatible fucntion and disable operation.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
Definition at line 442 of file mft_adcmp.c.
References ErrorInvalidParameter, MFT_ADCMP_CH10, MFT_ADCMP_CH32, MFT_ADCMP_CH54, MFT_ADCMP_CPCH_MAX, and Ok.
| en_result_t Mft_Adcmp_Fm3_EnableOperation | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh | ||
| ) |
Mft Adcmp fm3 compatible mode configuration and enable operation.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
Definition at line 402 of file mft_adcmp.c.
References ErrorInvalidParameter, MFT_ADCMP_CH10, MFT_ADCMP_CH32, MFT_ADCMP_CH54, MFT_ADCMP_CPCH_MAX, and Ok.
| en_result_t Mft_Adcmp_Fm3_Init | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh, | ||
| stc_mft_adcmp_fm3_config_t * | pstcConfig | ||
| ) |
Mft Adcmp fm3 compatible initialization.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
| [in] | pstcConfig | Mft Adcmp configuration parameter |
Definition at line 320 of file mft_adcmp.c.
References AdcmpBufFrtZeroPeak, AdcmpTrigAdc2Prio, stc_mft_adcmp_fm3_config::enBuf, stc_mft_adcmp_fm3_config::enFrt, stc_mft_adcmp_fm3_config::enMode, stc_mft_adcmp_fm3_config::enTrigSel, ErrorInvalidParameter, MFT_ADCMP_CH10, MFT_ADCMP_CH32, MFT_ADCMP_CH54, and Ok.
| uint16_t Mft_Adcmp_Fm3_ReadAccp | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh | ||
| ) |
Mft Adcmp fm3 compatible mode, read Accp register stored value.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
Definition at line 511 of file mft_adcmp.c.
References ErrorInvalidParameter, and MFT_ADCMP_CPCH_MAX.
| uint16_t Mft_Adcmp_Fm3_ReadAccpdn | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh | ||
| ) |
Mft Adcmp fm3 compatible mode, read Accpdn register stored value.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
Definition at line 567 of file mft_adcmp.c.
References ErrorInvalidParameter, and MFT_ADCMP_CPCH_MAX.
| en_result_t Mft_Adcmp_Fm3_WriteAccp | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh, | ||
| uint16_t | u16AccpVal | ||
| ) |
Mft Adcmp fm3 compatible mode, write Accp register.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
| [in] | u16AccpVal | Mft Adcmp configuration parameter
|
Definition at line 484 of file mft_adcmp.c.
References ErrorInvalidParameter, MFT_ADCMP_CPCH_MAX, and Ok.
| en_result_t Mft_Adcmp_Fm3_WriteAccpdn | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8CoupleCh, | ||
| uint16_t | u16AccpdnVal | ||
| ) |
Mft Adcmp fm3 compatible mode, write Accpdn register.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8CoupleCh | Mft Adcmp channel
|
| [in] | u16AccpdnVal | data value of Accpdn |
Definition at line 540 of file mft_adcmp.c.
References ErrorInvalidParameter, MFT_ADCMP_CPCH_MAX, and Ok.
| en_result_t Mft_Adcmp_Init | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8Ch, | ||
| stc_mft_adcmp_config_t * | pstcConfig | ||
| ) |
Device dependent initialization of Mft adcmp module.
Global function prototypes (definition in C source)
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8Ch | Mft adcmp channel
|
| [in] | pstcConfig | Pointer to Mft adcmp config
|
Definition at line 96 of file mft_adcmp.c.
References AdcmpBufFrtZeroPeak, AdcmpOffsetMode, AdcmpSelOccp1, AdcmpTrigAdc2Prio, stc_mft_adcmp_config::enBuf, stc_mft_adcmp_config::enFrt, stc_mft_adcmp_config::enMode, stc_mft_adcmp_config::enOccpSel, stc_mft_adcmp_config::enTrigSel, ErrorInvalidParameter, MFT_ADCMP_CH_MAX, and Ok.
| uint16_t Mft_Adcmp_ReadAcmp | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8Ch | ||
| ) |
Read compare and offset value of ACMP.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8Ch | Mft Adcmp channel
|
Definition at line 290 of file mft_adcmp.c.
References ErrorInvalidParameter, and MFT_ADCMP_CH_MAX.
| en_result_t Mft_Adcmp_WriteAcmp | ( | volatile FM4_MFT_ADCMP_TypeDef * | pstcMftAdcmp, |
| uint8_t | u8Ch, | ||
| uint16_t | u16AcmpVal | ||
| ) |
Write compare and offset value to ACMP.
| [in] | pstcMftAdcmp | Pointer to Mft instance
|
| [in] | u8Ch | Channel |
| [in] | u16AcmpVal | Mft Adcmp channel
|
Definition at line 264 of file mft_adcmp.c.
References ErrorInvalidParameter, MFT_ADCMP_CH_MAX, and Ok.