| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Functions
ADC Start Compare Unit (ADCMP)

## Functions
en_result_t | Mft_Adcmp_Init (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, stc_mft_adcmp_config_t *pstcConfig)
| Device dependent initialization of Mft adcmp module.
en_result_t | Mft_Adcmp_EnableOperation (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, stc_mft_adcmp_func_t *pstcFunc)
| Enable Mft Adcmp operations.
en_result_t | Mft_Adcmp_DisableOperation (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, stc_mft_adcmp_func_t *pstcFunc)
| Disable Mft Adcmp operations.
en_result_t | Mft_Adcmp_WriteAcmp (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch, uint16_t u16AdcmpVal)
| Write compare or offset value to ADCMP.
uint16_t | Mft_Adcmp_ReadAcmp (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8Ch)
| Read compare and offset value of ACMP.
en_result_t | Mft_Adcmp_Fm3_Init (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh, stc_mft_adcmp_fm3_config_t *pstcConfig)
| Mft Adcmp fm3 compatible initialization.
en_result_t | Mft_Adcmp_Fm3_EnableOperation (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh)
| Mft Adcmp fm3 compatible mode configuration and enable operation.
en_result_t | Mft_Adcmp_Fm3_DisableOperation (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh)
| De-configurate Mft Adcmp fm3 compatible function and disable operation.
en_result_t | Mft_Adcmp_Fm3_WriteAccp (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh, uint16_t u16AccpVal)
| Mft Adcmp fm3 compatible mode, write Accp register.
uint16_t | Mft_Adcmp_Fm3_ReadAccp (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh)
| Mft Adcmp fm3 compatible mode, read Accp register stored value.
en_result_t | Mft_Adcmp_Fm3_WriteAccpdn (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh, uint16_t u16AccpdnVal)
| Mft Adcmp fm3 compatible mode, write Accpdn register.
uint16_t | Mft_Adcmp_Fm3_ReadAccpdn (volatile FM0P_MFT_ADCMP_TypeDef *pstcMftAdcmp, uint8_t u8CoupleCh)
| Mft Adcmp fm3 compatible mode, read Accpdn register stored value.

## Detailed Description

Provided functions of ADCMP module:

- Mft_Adcmp_Init()
- Mft_Adcmp_EnableOperation()
- Mft_Adcmp_DisableOperation()
- Mft_Adcmp_WriteAcmp()
- Mft_Adcmp_ReadAcmp()
- Mft_Adcmp_Fm3_Init()
- Mft_Adcmp_Fm3_EnableOperation()
- Mft_Adcmp_Fm3_DisableOperation()
- Mft_Adcmp_Fm3_WriteAccp()
- Mft_Adcmp_Fm3_ReadAccp()
- Mft_Adcmp_Fm3_WriteAccpdn()
- Mft_Adcmp_Fm3_ReadAccpdn()

How to use 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.

Mft_Adcmp_Fm3_EnableOperation() enables ADCMP operation and Mft_Adcmp_Fm3_DisableOperation() disables ADCMP operation.

## Function Documentation

en_result_t Mft_Adcmp_DisableOperation | ( | volatile FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8Ch,
|  | stc_mft_adcmp_func_t * | pstcFunc
| ) |  |

Disable Mft Adcmp operations.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8Ch | Mft Adcmp channel MFT_ADCMP_CH0 ADCMP channel 0 MFT_ADCMP_CH1 ADCMP channel 1 MFT_ADCMP_CH2 ADCMP channel 2 MFT_ADCMP_CH3 ADCMP channel 3 MFT_ADCMP_CH4 ADCMP channel 4 MFT_ADCMP_CH5 ADCMP channel 5
  [in] | pstcFunc | Pointer to Mft Adcmp function structure

Return values:

  Ok | Mft Adcmp operations disabled
  ErrorInvalidParameter | If one of following conditions are met: pstcMftAdcmp == NULL pstcFunc == NULL u8Ch > MFT_ADCMP_CH_MAX

Definition at line 253 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_EnableOperation | ( | volatile FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8Ch,
|  | stc_mft_adcmp_func_t * | pstcFunc
| ) |  |

Enable Mft Adcmp operations.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8Ch | Mft Adcmp channel MFT_ADCMP_CH0 ADCMP channel 0 MFT_ADCMP_CH1 ADCMP channel 1 MFT_ADCMP_CH2 ADCMP channel 2 MFT_ADCMP_CH3 ADCMP channel 3 MFT_ADCMP_CH4 ADCMP channel 4 MFT_ADCMP_CH5 ADCMP channel 5
  [in] | pstcFunc | Pointer to Mft Adcmp function structure

Return values:

  Ok | Functions enabled
  ErrorInvalidParameter | If one of following conditions are met: pstcMftAdcmp == NULL pstcFunc == NULL u8Ch > MFT_ADCMP_CH_MAX

Definition at line 213 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 FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh
| ) |  |

De-configurate Mft Adcmp fm3 compatible function and disable operation.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8CoupleCh | Mft Adcmp channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5

Return values:

  Ok | ADCMP FM3 operation disabled
  ErrorInvalidParameter | If one of followings conditions are met: pstcMftAdcmp == NULL u8CoupleCh > MFT_ADCMP_CPCH_MAX

Definition at line 486 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 FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh
| ) |  |

Mft Adcmp fm3 compatible mode configuration and enable operation.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8CoupleCh | Mft Adcmp channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5

Return values:

  Ok | ADCMP FM3 mode funcitons enabled
  ErrorInvalidParameter | If one of following conditions are met: pstcMftAdcmp == NULL u8CoupleCh > MFT_ADCMP_CPCH_MAX

Definition at line 441 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 FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh,
|  | stc_mft_adcmp_fm3_config_t * | pstcConfig
| ) |  |

Mft Adcmp fm3 compatible initialization.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8CoupleCh | Mft Adcmp couple channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5
  [in] | pstcConfig | Mft Adcmp configuration parameter

Return values:

  Ok | Mft Adcmp fm3 compatible mode initialized
  ErrorInvalidParameter | Invalid setting of pstcConfig elements

Definition at line 355 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 FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh
| ) |  |

Mft Adcmp fm3 compatible mode, read Accp register stored value.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance structure of Mft_Adcmp
  [in] | u8CoupleCh | Mft Adcmp channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5

Returns:
  Data stored in Accp register

Definition at line 558 of file mft_adcmp.c.

References ErrorInvalidParameter, and MFT_ADCMP_CPCH_MAX.

uint16_t Mft_Adcmp_Fm3_ReadAccpdn | ( | volatile FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh
| ) |  |

Mft Adcmp fm3 compatible mode, read Accpdn register stored value.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance structure of Mft_Adcmp
  [in] | u8CoupleCh | Mft Adcmp channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5

Returns:
  Data stored in Accpdn register

Definition at line 620 of file mft_adcmp.c.

References ErrorInvalidParameter, and MFT_ADCMP_CPCH_MAX.

en_result_t Mft_Adcmp_Fm3_WriteAccp | ( | volatile FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh,
|  | uint16_t | u16AccpVal
| ) |  |

Mft Adcmp fm3 compatible mode, write Accp register.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8CoupleCh | Mft Adcmp channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5
  [in] | u16AccpVal | Mft Adcmp configuration parameter

Return values:

  Ok | Accp is written
  ErrorInvalidParameter | If one of following conditions are met: pstcMftAdcmp == NULL u8CoupleCh > MFT_ADCMP_CPCH_MAX

Definition at line 530 of file mft_adcmp.c.

References ErrorInvalidParameter, MFT_ADCMP_CPCH_MAX, and Ok.

en_result_t Mft_Adcmp_Fm3_WriteAccpdn | ( | volatile FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8CoupleCh,
|  | uint16_t | u16AccpdnVal
| ) |  |

Mft Adcmp fm3 compatible mode, write Accpdn register.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance structure of Mft_Adcmp
  [in] | u8CoupleCh | Mft Adcmp channel MFT_ADCMP_CH10 The couple channel of ch.0 and ch.1 MFT_ADCMP_CH32 The couple channel of ch.2 and ch.3 MFT_ADCMP_CH54 The couple channel of ch.4 and ch.5
  [in] | u16AccpdnVal | data value of Accpdn

Return values:

  Ok | Accpdn is written
  ErrorInvalidParameter | If one of following conditions are met: pstcMftAdcmp == NULL u8CoupleCh > MFT_ADCMP_CPCH_MAX

Definition at line 591 of file mft_adcmp.c.

References ErrorInvalidParameter, MFT_ADCMP_CPCH_MAX, and Ok.

en_result_t Mft_Adcmp_Init | ( | volatile FM0P_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)

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8Ch | Mft adcmp channel MFT_ADCMP_CH0 ADCMP channel 0 MFT_ADCMP_CH1 ADCMP channel 1 MFT_ADCMP_CH2 ADCMP channel 2 MFT_ADCMP_CH3 ADCMP channel 3 MFT_ADCMP_CH4 ADCMP channel 4 MFT_ADCMP_CH5 ADCMP channel 5
  [in] | pstcConfig | Pointer to Mft adcmp config structure of Mft Adcmp configuration

Return values:

  Ok | Adcmp initialized
  ErrorInvalidParameter | If one of following conditions are met: pstcMftAdcmp == NULL pstcConfig == NULL u8Ch > MFT_ADCMP_CH_MAX

Definition at line 104 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 FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8Ch
| ) |  |

Read compare and offset value of ACMP.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8Ch | Mft Adcmp channel MFT_ADCMP_CH0 ADCMP channel 0 MFT_ADCMP_CH1 ADCMP channel 1 MFT_ADCMP_CH2 ADCMP channel 2 MFT_ADCMP_CH3 ADCMP channel 3 MFT_ADCMP_CH4 ADCMP channel 4 MFT_ADCMP_CH5 ADCMP channel 5

Returns:
  Value of register ACMP

Definition at line 324 of file mft_adcmp.c.

References ErrorInvalidParameter, and MFT_ADCMP_CH_MAX.

en_result_t Mft_Adcmp_WriteAcmp | ( | volatile FM0P_MFT_ADCMP_TypeDef * | pstcMftAdcmp,
|  | uint8_t | u8Ch,
|  | uint16_t | u16AdcmpVal
| ) |  |

Write compare or offset value to ADCMP.

Parameters:

  [in] | pstcMftAdcmp | Pointer to Mft instance
  [in] | u8Ch | Mft Adcmp channel MFT_ADCMP_CH0 ADCMP channel 0 MFT_ADCMP_CH1 ADCMP channel 1 MFT_ADCMP_CH2 ADCMP channel 2 MFT_ADCMP_CH3 ADCMP channel 3 MFT_ADCMP_CH4 ADCMP channel 4 MFT_ADCMP_CH5 ADCMP channel 5
  [in] | u16AdcmpVal | ADCMP compare value

Return values:

  Ok | Compare or offset value to ADCMP is set
  ErrorInvalidParameter | If one of following condiitons are met: pstcMftAdcmp == NULL u8Ch > MFT_ADCMP_CH_MAX

Definition at line 293 of file mft_adcmp.c.

References ErrorInvalidParameter, MFT_ADCMP_CH_MAX, and Ok.