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

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Defines | Typedefs | Enumerations | Functions | Variables
12-Bit Analog Digital Converter (ADC)

## Data Structures
struct | stc_ad_channel_list
| ADC Channel list with same sort order as the ER32 registers. More...
struct | stc_adc_scan
| Scan Conversion configuration. More...
struct | stc_adc_prio
| Priority Conversion configuration. More...
struct | stc_adc_comapre
| Comparison configuration. More...
struct | stc_adc_range_compare
| Range comparison configuration. More...
struct | stc_adc_config
| ADC configuration. More...
struct | stc_adc_int_sel
| ADC interrupt selection. More...
struct | stc_scan_fifo_info
| Scan conversion FIFO information. More...
struct | stc_prio_fifo_info
| Priority conversion FIFO information. More...
struct | stc_adc_int_callback
| ADC interrupt callback function. More...
struct | stc_adc_intern_data
| ADC instance internal data, storing internal information for each enabled ADC instance. More...
struct | stc_adc_instance_data
| ADC instance data type. More...
## Defines
#define | stc_adcn_t FM0P_ADC_TypeDef
#define | ADC0 (*((volatile stc_adcn_t *) FM0P_ADC0_BASE))
#define | ADC1 (*((volatile stc_adcn_t *) FM0P_ADC1_BASE))
#define | ADC2 (*((volatile stc_adcn_t *) FM0P_ADC2_BASE))
#define | PDL_ADC_READY_WAIT_COUNT 1000000u
| Time-out counter value for ADC ready bit polling.
#define | ADC_INSTANCE_COUNT
#define | ADC0_SCAN_FIFO_ADDR (uint32_t)(&FM0P_ADC0->SCFD)
#define | ADC1_SCAN_FIFO_ADDR (uint32_t)(&FM0P_ADC1->SCFD)
#define | ADC2_SCAN_FIFO_ADDR (uint32_t)(&FM0P_ADC2->SCFD)
## Typedefs
typedef void(* | func_ptr_adc_parg32_t )(volatile uint32_t *pu32Argument)
typedef enum en_adc_scan_mode | en_adc_scan_mode_t
| Scan Conversion Mode.
typedef enum en_adc_sample_time_n | en_adc_sample_time_n_t
| Priority Conversion Stage Count.
typedef enum en_adc_fifo_status | en_adc_fifo_status_t
| FIFO Status (Scan, Priority Conversion)
typedef enum en_adc_timer_select | en_adc_timer_select_t
| ADC scan/priority conversion timer trigger selection.
typedef struct stc_ad_channel_list | stc_ad_channel_list_t
| ADC Channel list with same sort order as the ER32 registers.
typedef struct stc_adc_scan | stc_adc_scan_t
| Scan Conversion configuration.
typedef struct stc_adc_prio | stc_adc_prio_t
| Priority Conversion configuration.
typedef struct stc_adc_comapre | stc_adc_comapre_t
| Comparison configuration.
typedef struct stc_adc_range_compare | stc_adc_range_compare_t
| Range comparison configuration.
typedef struct stc_adc_config | stc_adc_config_t
| ADC configuration.
typedef struct stc_adc_int_sel | stc_adc_int_sel_t
| ADC interrupt selection.
typedef enum en_scan_start_cause | en_scan_start_cause_t
| Scan conversion start cause.
typedef struct stc_scan_fifo_info | stc_scan_fifo_info_t
| Scan conversion FIFO information.
typedef enum en_prio_start_cause | en_prio_start_cause_t
| Priority conversion start cause.
typedef struct stc_prio_fifo_info | stc_prio_fifo_info_t
| Priority conversion FIFO information.
typedef struct stc_adc_int_callback | stc_adc_int_callback_t
| ADC interrupt callback function.
typedef enum en_adc_status | en_adc_status_t
| ADC status list.
typedef enum en_adc_int | en_adc_int_t
| ADC interrupt type.
typedef enum en_adc_instance_index | en_adc_instance_index_t
| Enumeration to define an index for each enabled ADC instance.
typedef struct stc_adc_intern_data | stc_adc_intern_data_t
| ADC instance internal data, storing internal information for each enabled ADC instance.
typedef struct stc_adc_instance_data | stc_adc_instance_data_t
| ADC instance data type.
## Enumerations
enum | en_adc_scan_mode { ScanSingleConversion = 0, ScanRepeatConversion = 1 }
| Scan Conversion Mode. More...
enum | en_adc_sample_time_n { Value1 = 0, Value4 = 1, Value8 = 2, Value16 = 3, Value32 = 4, Value64 = 5, Value128 = 6, Value256 = 7 }
| Priority Conversion Stage Count. More...
enum | en_adc_fifo_status { AdcFifoEmpty = 0, AdcFifoFilled = 1, AdcFifoFull = 2, AdcFifoOverrun = 3, AdcFifoError = 4 }
| FIFO Status (Scan, Priority Conversion) More...
enum | en_adc_timer_select { AdcNoTimer = 0, AdcMft = 1, AdcBt0 = 2, AdcBt1 = 3, AdcBt2 = 4, AdcBt3 = 5, AdcBt4 = 6, AdcBt5 = 7, AdcBt6 = 8, AdcBt7 = 9 }
| ADC scan/priority conversion timer trigger selection. More...
enum | en_scan_start_cause { ScanStartBySw = 0, ScanStartByTimer = 1 }
| Scan conversion start cause. More...
enum | en_prio_start_cause { PrioStartBySw = 0, PrioStartByTimer = 1, PrioStartByExtTrig = 2 }
| Priority conversion start cause. More...
enum | en_adc_status { ScanFifoEmptyStatus = 0, ScanFifoFullStatus = 1, PrioFifoEmptyStatus = 2, PrioFifoFullStatus = 3, Prio2PendingStatus = 4, PrioStatus = 5, ScanStatus = 6, RangeThresholdExcessFlag = 7 }
| ADC status list. More...
enum | en_adc_int { AdcScanInt = 0, AdcPrioInt = 1, AdcScanFifoOverrunInt = 2, AdcPrioFifoOverrunInt = 3, AdcComparisonInt = 4, AdcRangeComparisonInt = 5 }
| ADC interrupt type. More...
enum | en_adc_instance_index { AdcInstanceIndexAdc0, AdcInstanceIndexAdc1, AdcInstanceIndexAdc2, AdcInstanceIndexMax }
| Enumeration to define an index for each enabled ADC instance. More...
## Functions
static void | Adc_InitNvic (volatile FM0P_ADC_TypeDef *pstcAdc)
| Set NVIC Interrupt depending on ADC instance.
static void | Adc_DeInitNvic (volatile FM0P_ADC_TypeDef *pstcAdc)
| Clear NVIC Interrupt depending on ADC instance.
static stc_adc_intern_data_t * | AdcGetInternDataPtr (volatile FM0P_ADC_TypeDef *pstcAdc)
| Return the internal data for a certain ADC instance.
void | AdcIrqHandler (volatile FM0P_ADC_TypeDef *pstcAdc, stc_adc_intern_data_t *pstcAdcInternData)
| ADC instance interrupt service routine.
en_result_t | Adc_Init (volatile FM0P_ADC_TypeDef *pstcAdc, stc_adc_config_t *pstcConfig)
| Initialize ADC.
en_result_t | Adc_DeInit (volatile FM0P_ADC_TypeDef *pstcAdc)
| De-Initialize ADC.
en_result_t | Adc_EnableInt (volatile FM0P_ADC_TypeDef *pstcAdc, stc_adc_int_sel_t *pstcIntSel, stc_adc_int_callback_t *pstcIntCallback)
| Enable ADC interrupt.
en_result_t | Adc_DisableInt (volatile FM0P_ADC_TypeDef *pstcAdc, stc_adc_int_sel_t *pstcIntSel)
| Disable ADC interrupt.
boolean_t | Adc_GetIntFlag (volatile FM0P_ADC_TypeDef *pstcAdc, en_adc_int_t enInt)
| Get ADC interrupt flag.
en_result_t | Adc_ClrIntFlag (volatile FM0P_ADC_TypeDef *pstcAdc, en_adc_int_t enInt)
| Clear ADC interrupt flag.
en_result_t | Adc_Enable (volatile FM0P_ADC_TypeDef *pstcAdc)
| Enable ADC and wait for ADC operation ready.
en_result_t | Adc_Disable (volatile FM0P_ADC_TypeDef *pstcAdc)
| Disable ADC.
en_result_t | Adc_SwTriggerScan (volatile FM0P_ADC_TypeDef *pstcAdc)
| ADC Scan Software Start Trigger.
en_result_t | Adc_StopScanRepeat (volatile FM0P_ADC_TypeDef *pstcAdc)
| Stop Scan conversion with repeat mode.
en_result_t | Adc_SwTriggerPrio (volatile FM0P_ADC_TypeDef *pstcAdc)
| ADC Priority Software Start Trigger.
en_result_t | Adc_ForceStop (volatile FM0P_ADC_TypeDef *pstcAdc)
| ADC Software Stop.
boolean_t | Adc_GetStatus (volatile FM0P_ADC_TypeDef *pstcAdc, en_adc_status_t enStatus)
| Get ADC conversion status.
uint32_t | Adc_GetScanFifo (volatile FM0P_ADC_TypeDef *pstcAdc)
| Reads out Scan Conversion FIFO.
en_result_t | Adc_ClrScanFifo (volatile FM0P_ADC_TypeDef *pstcAdc)
| Clear scan FIFO.
en_result_t | Adc_ExtractScanFifo (volatile FM0P_ADC_TypeDef *pstcAdc, uint32_t u32FifoData, stc_scan_fifo_info_t *pstcFifo)
| Extract scan conversion data information from FIFO data.
uint32_t | Adc_GetPrioFifo (volatile FM0P_ADC_TypeDef *pstcAdc)
| Reads out Priority Conversion FIFO.
en_result_t | Adc_ClrPrioFifo (volatile FM0P_ADC_TypeDef *pstcAdc)
| Clear priority FIFO.
en_result_t | Adc_ExtractPrioFifo (volatile FM0P_ADC_TypeDef *pstcAdc, uint32_t u32FifoData, stc_prio_fifo_info_t *pstcFifo)
| Extract priority conversion data information from FIFO data.
## Variables
stc_adc_instance_data_t | m_astcAdcInstanceDataLut [(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC0==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC1==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC2==PDL_ON)]
| Look-up table for all enabled ADC instances and their internal data.
stc_adc_instance_data_t | m_astcAdcInstanceDataLut [(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC0==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC1==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC2==PDL_ON)]
| Look-up table for all enabled ADC instances and their internal data.

## Detailed Description

Provided functions of ADC module:

- Adc_Init()
- Adc_DeInit()
- Adc_Enable()
- Adc_Disable()
- Adc_SwTriggerScan()
- Adc_StopScanRepeat()
- Adc_SwTriggerPrio()
- Adc_ForceStop()
- Adc_EnableInt()
- Adc_DisableInt()
- Adc_GetIntFlag()
- Adc_ClrIntFlag()
- Adc_GetScanFifo()
- Adc_ClrScanFifo()
- Adc_GetStatus()
- Adc_ExtractScanFifo()
- Adc_GetPrioFifo()
- Adc_ClrPrioFifo()
- Adc_ExtractPrioFifo()
- AdcIrqHandler()

Adc_Init() initializes an ADC instance according the configuration of the structure type stc_adc_config_t. Adc_DeInit() de-initializes an ADC instance.

For using the ADC instnace Adc_Enable() can be used first to enable ADC operation.

Adc_EnableInt() is used to enable ADC interrupts selected by the structure type stc_adc_int_sel_t, the interrupt callback functions can also be set according to structure type stc_adc_int_callback_t.

Adc_Disable() is used to disable ADC interrupts also selected by the structure type stc_adc_int_sel_t

Adc_SwTriggerScan() and Adc_SwTriggerPrio() can be used for software trigger start for scan and priority conversion.

Adc_ForceStop() stops both ADC scan and priority conversion forcely.

Adc_GetIntFlag() can get the interrupt flag in the interrupt-polling mode and Adc_ClrIntFlag() can clear the interrupt flag. The interrupt type can be selected by the enumeration type en_adc_int_t.

Adc_GetStatus() return the status of ADC selected by the structure type en_adc_status_t.

Adc_ClrScanFifo() and Adc_ClrPrioFifo() clear the FIFOs.

Adc_GetScanFifo() and Adc_GetPrioFifo() read out the FIFOs.

Adc_ExtractScanFifo() and Adc_ExtractPrioFifo() extracts 32-bits FIFO data.

AdcIrqHandler() is ADC IRQ handler function, which is called in the interrupts.c file.

Note:
  The callback arguments for the scan and priority result point to the according FIFO registers of the recent instance. The application must take care of emptying these FIFOs. Either the FIFO depth of the configuration can be used for counting or the function Adc_GetStatus() can be used to check if the FIFO is empty or not.

## Define Documentation

#define ADC0 (*((volatile stc_adcn_t *) FM0P_ADC0_BASE))

Definition at line 143 of file adc.h.

Referenced by ADC0_IRQHandler(), Adc_DeInitNvic(), and Adc_InitNvic().

#define ADC0_SCAN_FIFO_ADDR (uint32_t)(&FM0P_ADC0->SCFD)

Definition at line 154 of file adc.h.

#define ADC1 (*((volatile stc_adcn_t *) FM0P_ADC1_BASE))

Definition at line 144 of file adc.h.

Referenced by ADC1_IRQHandler(), Adc_DeInitNvic(), and Adc_InitNvic().

#define ADC1_SCAN_FIFO_ADDR (uint32_t)(&FM0P_ADC1->SCFD)

Definition at line 155 of file adc.h.

#define ADC2 (*((volatile stc_adcn_t *) FM0P_ADC2_BASE))

Definition at line 145 of file adc.h.

Referenced by ADC2_LCD_IRQHandler(), Adc_DeInitNvic(), and Adc_InitNvic().

#define ADC2_SCAN_FIFO_ADDR (uint32_t)(&FM0P_ADC2->SCFD)

Definition at line 156 of file adc.h.

#define ADC_INSTANCE_COUNT

Value:

    (uint8_t)(PDL_PERIPHERAL_ENABLE_ADC0 == PDL_ON) + \
            (uint8_t)(PDL_PERIPHERAL_ENABLE_ADC1 == PDL_ON) + \
            (uint8_t)(PDL_PERIPHERAL_ENABLE_ADC2 == PDL_ON)

Definition at line 149 of file adc.h.

Referenced by AdcGetInternDataPtr().

#define PDL_ADC_READY_WAIT_COUNT 1000000u

Time-out counter value for ADC ready bit polling.

Definition at line 147 of file adc.h.

Referenced by Adc_Enable().

#define stc_adcn_t FM0P_ADC_TypeDef

Definition at line 142 of file adc.h.

Referenced by ADC0_IRQHandler(), ADC1_IRQHandler(), ADC2_LCD_IRQHandler(), Adc_DeInitNvic(), and Adc_InitNvic().

## Typedef Documentation

typedef enum en_adc_fifo_status en_adc_fifo_status_t

FIFO Status (Scan, Priority Conversion)

typedef enum en_adc_instance_index en_adc_instance_index_t

Enumeration to define an index for each enabled ADC instance.

typedef enum en_adc_int en_adc_int_t

ADC interrupt type.

typedef enum en_adc_sample_time_n en_adc_sample_time_n_t

Priority Conversion Stage Count.

typedef enum en_adc_scan_mode en_adc_scan_mode_t

Scan Conversion Mode.

typedef enum en_adc_status en_adc_status_t

ADC status list.

typedef enum en_adc_timer_select en_adc_timer_select_t

ADC scan/priority conversion timer trigger selection.

Note:
  Do not change the numbering.

typedef enum en_prio_start_cause en_prio_start_cause_t

Priority conversion start cause.

typedef enum en_scan_start_cause en_scan_start_cause_t

Scan conversion start cause.

typedef void(* func_ptr_adc_parg32_t)(volatile uint32_t *pu32Argument)

Definition at line 161 of file adc.h.

typedef struct stc_ad_channel_list stc_ad_channel_list_t

ADC Channel list with same sort order as the ER32 registers.

typedef struct stc_adc_comapre stc_adc_comapre_t

Comparison configuration.

typedef struct stc_adc_config stc_adc_config_t

ADC configuration.

typedef struct stc_adc_instance_data stc_adc_instance_data_t

ADC instance data type.

typedef struct stc_adc_int_callback stc_adc_int_callback_t

ADC interrupt callback function.

typedef struct stc_adc_int_sel stc_adc_int_sel_t

ADC interrupt selection.

typedef struct stc_adc_intern_data stc_adc_intern_data_t

ADC instance internal data, storing internal information for each enabled ADC instance.

typedef struct stc_adc_prio stc_adc_prio_t

Priority Conversion configuration.

typedef struct stc_adc_range_compare stc_adc_range_compare_t

Range comparison configuration.

typedef struct stc_adc_scan stc_adc_scan_t

Scan Conversion configuration.

typedef struct stc_prio_fifo_info stc_prio_fifo_info_t

Priority conversion FIFO information.

typedef struct stc_scan_fifo_info stc_scan_fifo_info_t

Scan conversion FIFO information.

## Enumeration Type Documentation

enum en_adc_fifo_status

FIFO Status (Scan, Priority Conversion)

Enumerator:

  AdcFifoEmpty | Scan FIFO empty.
  AdcFifoFilled | Scan FIFO (partly) filled.
  AdcFifoFull | Scan FIFO full.
  AdcFifoOverrun | Scan FIFO overrun.
  AdcFifoError | Unknown Fifo Error (no bit set) or pstcAdc == NULL.

Definition at line 193 of file adc.h.

enum en_adc_instance_index

Enumeration to define an index for each enabled ADC instance.

Enumerator:

  AdcInstanceIndexAdc0 |
  AdcInstanceIndexAdc1 |
  AdcInstanceIndexAdc2 |
  AdcInstanceIndexMax |

Definition at line 466 of file adc.h.

enum en_adc_int

ADC interrupt type.

Enumerator:

  AdcScanInt | Scan conversion interrupt.
  AdcPrioInt | Priority conversion interrupt.
  AdcScanFifoOverrunInt | Scan FIFO overrun interrupt.
  AdcPrioFifoOverrunInt | Priority FIFO overrun interrupt.
  AdcComparisonInt | ADC comparison interrupt.
  AdcRangeComparisonInt | ADC range comparison interrupt.

Definition at line 454 of file adc.h.

enum en_adc_sample_time_n

Priority Conversion Stage Count.

Enumerator:

  Value1 | Set value * 1.
  Value4 | Set value * 4.
  Value8 | Set value * 8.
  Value16 | Set value * 16.
  Value32 | Set value * 32.
  Value64 | Set value * 64.
  Value128 | Set value * 128.
  Value256 | Set value * 256.

Definition at line 177 of file adc.h.

enum en_adc_scan_mode

Scan Conversion Mode.

Enumerator:

  ScanSingleConversion | Single mode of scan conversion.
  ScanRepeatConversion | Repeat mode of scan conversion.

Definition at line 167 of file adc.h.

enum en_adc_status

ADC status list.

Enumerator:

  ScanFifoEmptyStatus | Scan FIFO empty status.
  ScanFifoFullStatus | Scan FIFO full status.
  PrioFifoEmptyStatus | Priority FIFO empty status.
  PrioFifoFullStatus | Priority FIFO full status.
  Prio2PendingStatus | Priority conversion (level 2) pending status.
  PrioStatus | Priority conversion status.
  ScanStatus | Scan conversion status.
  RangeThresholdExcessFlag | Range comparison threshold exceed status.

Definition at line 437 of file adc.h.

enum en_adc_timer_select

ADC scan/priority conversion timer trigger selection.

Note:
  Do not change the numbering.

Enumerator:

  AdcNoTimer | No selected trigger.
  AdcMft | Trigger by Multifunction Timer.
  AdcBt0 | Trigger with Base Timer 0.
  AdcBt1 | Trigger with Base Timer 1.
  AdcBt2 | Trigger with Base Timer 2.
  AdcBt3 | Trigger with Base Timer 3.
  AdcBt4 | Trigger with Base Timer 4.
  AdcBt5 | Trigger with Base Timer 5.
  AdcBt6 | Trigger with Base Timer 6.
  AdcBt7 | Trigger with Base Timer 7.

Definition at line 207 of file adc.h.

enum en_prio_start_cause

Priority conversion start cause.

Enumerator:

  PrioStartBySw | Priority conversion started by software.
  PrioStartByTimer | Priority conversion started by timer.
  PrioStartByExtTrig | Priority conversion started by external trigger.

Definition at line 397 of file adc.h.

enum en_scan_start_cause

Scan conversion start cause.

Enumerator:

  ScanStartBySw | Scan converisons triggered by software.
  ScanStartByTimer | Scan converisons triggered by timer.

Definition at line 373 of file adc.h.

## Function Documentation

en_result_t Adc_ClrIntFlag | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | en_adc_int_t | enInt
| ) |  |

Clear ADC interrupt flag.

This function clears the ADC interrupt which is selected.

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | enInt | Interrupt type AdcScanInt Scan conversion interrupt flag AdcPrioInt Priority scan conversion interrupt flag AdcScanFifoOverrunInt Scan FIFO overrun interrupt flag AdcPrioFifoOverrunInt Priority FIFO overrun interrupt flag AdcComparisonInt Comparison interrupt flag AdcRangeComparisonInt Range comparison interrupt flag

Return values:

  Ok | Disable interrupt normally
  ErrorInvalidParameter | pstcAdc == NULL Other invalid configuration

Definition at line 881 of file adc.c.

References AdcComparisonInt, AdcPrioFifoOverrunInt, AdcPrioInt, AdcRangeComparisonInt, AdcScanFifoOverrunInt, AdcScanInt, ErrorInvalidParameter, and Ok.

en_result_t Adc_ClrPrioFifo | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Clear priority FIFO.

This function clears the FIFO for priority conversion

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | Priority FIFO cleared
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 1290 of file adc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Adc_ClrScanFifo | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Clear scan FIFO.

This function clears the FIFO for scan conversion

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | Scan FIFO cleared
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 1184 of file adc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Adc_DeInit | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

De-Initialize ADC.

This function deinitializes an ADC module

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC instance fully disabled and reset
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 611 of file adc.c.

References ErrorInvalidParameter, and Ok.

static void Adc_DeInitNvic | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) | `[static]`

Clear NVIC Interrupt depending on ADC instance.

Parameters:

  pstcAdc | Pointer to ADC instance

Definition at line 269 of file adc.c.

References ADC0, ADC1, ADC2, PDL_DEFAULT_INTERRUPT_LEVEL, and stc_adcn_t.

Referenced by Adc_DisableInt().

Here is the caller graph for this function:

en_result_t Adc_Disable | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Disable ADC.

This function disables an ADC operation

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC instance disabled
  ErrorTimeout | ADC instance not ready
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 967 of file adc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Adc_DisableInt | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | stc_adc_int_sel_t * | pstcIntSel
| ) |  |

Disable ADC interrupt.

This function disable the ADC interrupts which are selected.

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | pstcIntSel | ADC interrupt selection

Return values:

  Ok | Disable interrupt normally
  ErrorInvalidParameter | pstcAdc == NULL pstcIntSel == NULL pstcIntCallback == NULL Other invalid configuration

Definition at line 745 of file adc.c.

References Adc_DeInitNvic(), AdcGetInternDataPtr(), stc_adc_int_sel::bComparisonIrq, stc_adc_int_sel::bFifoOverrunIrq, stc_adc_int_sel::bPrioIrq, stc_adc_int_sel::bRangeComparisonIrq, stc_adc_int_sel::bScanIrq, ErrorInvalidParameter, Ok, stc_adc_intern_data::pfnComparisonCallback, stc_adc_intern_data::pfnPrioCallback, stc_adc_intern_data::pfnPrioErrorCallback, stc_adc_intern_data::pfnRangeComparisonCallback, stc_adc_intern_data::pfnScanCallback, stc_adc_intern_data::pfnScanErrorCallback, and TRUE.

Here is the call graph for this function:

en_result_t Adc_Enable | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Enable ADC and wait for ADC operation ready.

This function enables an ADC instance and waits for readiness

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC instance enabled and ready
  ErrorTimeout | ADC instance not ready
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 928 of file adc.c.

References ErrorInvalidParameter, ErrorTimeout, Ok, PDL_ADC_READY_WAIT_COUNT, and TRUE.

en_result_t Adc_EnableInt | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | stc_adc_int_sel_t * | pstcIntSel,
|  | stc_adc_int_callback_t * | pstcIntCallback
| ) |  |

Enable ADC interrupt.

This function enable the ADC interrupts which are selected.

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | pstcIntSel | ADC interrupt selection
  [in] | pstcIntCallback | ADC interrupt callback functions

Return values:

  Ok | Enable interrupt normally
  ErrorInvalidParameter | pstcAdc == NULL pstcIntSel == NULL pstcIntCallback == NULL Other invalid configuration

Definition at line 672 of file adc.c.

References Adc_InitNvic(), AdcGetInternDataPtr(), stc_adc_int_sel::bComparisonIrq, stc_adc_int_sel::bFifoOverrunIrq, stc_adc_int_sel::bPrioIrq, stc_adc_int_sel::bRangeComparisonIrq, stc_adc_int_sel::bScanIrq, ErrorInvalidParameter, Ok, stc_adc_int_callback::pfnComparisonCallback, stc_adc_intern_data::pfnComparisonCallback, stc_adc_int_callback::pfnPrioCallback, stc_adc_intern_data::pfnPrioCallback, stc_adc_int_callback::pfnPrioErrorCallback, stc_adc_intern_data::pfnPrioErrorCallback, stc_adc_int_callback::pfnRangeComparisonCallback, stc_adc_intern_data::pfnRangeComparisonCallback, stc_adc_int_callback::pfnScanCallback, stc_adc_intern_data::pfnScanCallback, stc_adc_int_callback::pfnScanErrorCallback, stc_adc_intern_data::pfnScanErrorCallback, and TRUE.

Here is the call graph for this function:

en_result_t Adc_ExtractPrioFifo | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | uint32_t | u32FifoData,
|  | stc_prio_fifo_info_t * | pstcFifo
| ) |  |

Extract priority conversion data information from FIFO data.

This function extracts the priority conversion data information from FIFO data

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | u32FifoData | FIFO data
  [out] | pstcFifo | Pointer to FIFO information structure

Return values:

  Ok | Priority FIFO data extracted
  ErrorInvalidParameter | If one of following conditions are met: pstcAdc == NULL pstcFifo == NULL

Definition at line 1318 of file adc.c.

References stc_prio_fifo_info::bInValid, stc_prio_fifo_info::enStartCause, ErrorInvalidParameter, Ok, PrioStartByExtTrig, PrioStartBySw, PrioStartByTimer, stc_prio_fifo_info::u16Data, and stc_prio_fifo_info::u8Ch.

en_result_t Adc_ExtractScanFifo | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | uint32_t | u32FifoData,
|  | stc_scan_fifo_info_t * | pstcFifo
| ) |  |

Extract scan conversion data information from FIFO data.

This function extracts the scan conversion data information from FIFO data

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | u32FifoData | FIFO data
  [out] | pstcFifo | Pointer to FIFO information structure

Return values:

  Ok | Scan FIFO data extracted
  ErrorInvalidParameter | If one of following conditions are met: pstcAdc == NULL pstcFifo == NULL

Definition at line 1212 of file adc.c.

References stc_scan_fifo_info::bInValid, stc_scan_fifo_info::enStartCause, ErrorInvalidParameter, Ok, ScanStartBySw, ScanStartByTimer, stc_scan_fifo_info::u16Data, and stc_scan_fifo_info::u8Ch.

en_result_t Adc_ForceStop | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

ADC Software Stop.

This function requests a stop of the ADC

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC instance stop request
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 1064 of file adc.c.

References ErrorInvalidParameter, and Ok.

boolean_t Adc_GetIntFlag | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | en_adc_int_t | enInt
| ) |  |

Get ADC interrupt flag.

This function gets the ADC interrupt flag which is selected.

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | enInt | ADC interrupt type AdcScanInt Scan conversion interrupt flag AdcPrioInt Priority scan conversion interrupt flag AdcScanFifoOverrunInt Scan FIFO overrun interrupt flag AdcPrioFifoOverrunInt Priority FIFO overrun interrupt flag AdcComparisonInt Comparison interrupt flag AdcRangeComparisonInt Range comparison interrupt flag

Return values:

  TRUE | The data count in scan FIFO match scan FIFO stage [AdcScanInt] The data count in priority FIFO match priority FIFO stage [AdcPrioInt] Scan FIFO overruns [AdcScanFifoOverrunInt] Priority FIFO overruns [AdcPrioFifoOverrunInt] The comparison result match the condition set in the Adc_Init() [AdcComparisonInt] The range comparison result match the condition set in the Adc_Init() [AdcRangeComparisonInt]
  FALSE | The data count in scan FIFO don't match scan FIFO stage [AdcScanInt] The data count in priority FIFO don't match priority FIFO stage [AdcPrioInt] Scan FIFO don't overrun [AdcScanFifoOverrunInt] Priority FIFO don't overrun [AdcPrioFifoOverrunInt] The comparison result don't match the condition set in the Adc_Init() [AdcComparisonInt] The range comparison result don't match the condition set in the Adc_Init() [AdcRangeComparisonInt]

Definition at line 832 of file adc.c.

References AdcComparisonInt, AdcPrioFifoOverrunInt, AdcPrioInt, AdcRangeComparisonInt, AdcScanFifoOverrunInt, AdcScanInt, and FALSE.

uint32_t Adc_GetPrioFifo | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Reads out Priority Conversion FIFO.

This function reads out the Priority Conversion FIFO.

Precondition:
  Adc_PrioFifioStatus() should be called before

Parameters:

  [in] | pstcAdc | ADC instance

Returns:
  Recent Priority Conversion FIFO value including INVL, RS2, RS1, RS0, and Channel data as is. If pstcAdc == NULL 0xFFFFFFFF is returned.

Definition at line 1268 of file adc.c.

uint32_t Adc_GetScanFifo | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Reads out Scan Conversion FIFO.

This function reads out the Scan Conversion FIFO.

Precondition:
  Adc_ScanFifioStatus() should be called before

Parameters:

  [in] | pstcAdc | ADC instance

Returns:
  Recent Scan Conversion FIFO value including INVL, RS1, RS0, and Channel data as is. If pstcAdc == NULL 0xFFFFFFFF is returned.

Definition at line 1162 of file adc.c.

boolean_t Adc_GetStatus | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | en_adc_status_t | enStatus
| ) |  |

Get ADC conversion status.

This function gets the status when ADC is in conversion

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | enStatus | ADC status type ScanFifoEmptyStatus Scan FIFO empty status ScanFifoFullStatus Scan FIFO full status PrioFifoEmptyStatus Priority FIFO empty status PrioFifoFullStatus Priority FIFO full status Prio2PendingStatus Priority conversion (level 2) pending status PrioStatus Priority conversion status ScanStatus Scan conversion status RangeThresholdExcessFlag Range comparison threshold exceed status

Return values:

  TRUE | If one of following cases match: The Scan FIFO is empty [enStatus = ScanFifoEmptyStatus] The Scan FIFO is full [enStatus = ScanFifoFullStatus] Priority FIFO is empty [enStatus = PrioFifoEmptyStatus] Priority FIFO is full [enStatus = PrioFifoFullStatus] Priority level 2 conversion is pending [enStatus = Prio2PendingStatus] Priority conversion is in progress [enStatus = PrioStatus] Scan conversion is in progress [enStatus = ScanStatus] The sample data beyond the upper limit threshold [enStatus = RangeThresholdExcessFlag]
  FALSE | If one of following cases match: The Scan FIFO isn't empty [enStatus = ScanFifoEmptyStatus] The Scan FIFO isn't full [enStatus = ScanFifoFullStatus] Priority FIFO isn't empty [enStatus = PrioFifoEmptyStatus] Priority FIFO isn't full [enStatus = PrioFifoFullStatus] Priority level 2 conversion isn't pending [enStatus = Prio2PendingStatus] Priority conversion isn't in progress [enStatus = PrioStatus] The sample data below the lower limit threshold [enStatus = RangeThresholdExcessFlag]

Definition at line 1112 of file adc.c.

References FALSE, Prio2PendingStatus, PrioFifoEmptyStatus, PrioFifoFullStatus, PrioStatus, RangeThresholdExcessFlag, ScanFifoEmptyStatus, ScanFifoFullStatus, ScanStatus, and TRUE.

en_result_t Adc_Init | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | stc_adc_config_t * | pstcConfig
| ) |  |

Initialize ADC.

This function initializes an ADC module

Parameters:

  [in] | pstcAdc | ADC instance
  [in] | pstcConfig | ADC module configuration

Return values:

  Ok | ADC initialized normally
  ErrorInvalidParameter | if one of following cases matchs: pstcAdc == NULL pstcConfig == NULL Other invalid configuration

Definition at line 330 of file adc.c.

References stc_adc_comapre::bCompareAllChannels, stc_adc_config::bComparisonEnable, stc_adc_comapre::bCompIrqEqualGreater, stc_adc_config::bLsbAlignment, stc_adc_prio::bPrioExtTrigStartEnable, stc_adc_config::bPrioInit, stc_adc_prio::bPrioTimerStartEnable, stc_adc_range_compare::bRangeCompareAllChannels, stc_adc_config::bRangeComparisonEnable, stc_adc_config::bScanInit, stc_adc_scan::bScanTimerStartEnable, stc_adc_range_compare::bWithinRange, stc_adc_prio::enPrioTimerTrigger, stc_adc_config::enSamplingTimeN0, stc_adc_config::enSamplingTimeN1, stc_adc_scan::enScanMode, stc_adc_scan::enScanTimerTrigger, ErrorInvalidParameter, Ok, PDL_ZERO_STRUCT, ScanRepeatConversion, ScanSingleConversion, stc_adc_config::stcComparisonInit, stc_adc_config::stcPrioInit, stc_adc_config::stcRangeComparisonInit, stc_adc_config::stcScanInit, TRUE, stc_adc_comapre::u16CompareValue, stc_adc_range_compare::u16LowerLimitRangeValue, stc_adc_range_compare::u16UpperLimitRangeValue, stc_adc_config::u32SamplingTimeSelect, stc_adc_scan::u32ScanCannelSelect, stc_adc_comapre::u8CompareChannel, stc_adc_config::u8EnableTime, stc_adc_prio::u8PrioFifoDepth, stc_adc_prio::u8PrioLevel1AnalogChSel, stc_adc_prio::u8PrioLevel2AnalogChSel, stc_adc_range_compare::u8RangeComapreChannel, stc_adc_range_compare::u8RangeCountValue, stc_adc_config::u8SamplingMultiplier, stc_adc_config::u8SamplingTime0, stc_adc_config::u8SamplingTime1, stc_adc_scan::u8ScanFifoDepth, Value1, Value128, Value16, Value256, Value32, Value4, Value64, and Value8.

static void Adc_InitNvic | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) | `[static]`

Set NVIC Interrupt depending on ADC instance.

Parameters:

  pstcAdc | Pointer to ADC instance

Definition at line 234 of file adc.c.

References ADC0, ADC1, ADC2, PDL_IRQ_LEVEL_ADC0, PDL_IRQ_LEVEL_ADC1, PDL_IRQ_LEVEL_ADC2_LCD, and stc_adcn_t.

Referenced by Adc_EnableInt().

Here is the caller graph for this function:

en_result_t Adc_StopScanRepeat | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

Stop Scan conversion with repeat mode.

This function stops an AD Scan Conversion with repeat mode

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC scan conversion stopped
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 1016 of file adc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Adc_SwTriggerPrio | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

ADC Priority Software Start Trigger.

This function starts an AD Priority Conversion by Software trigger

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC instance triggered (or re-triggered)
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 1040 of file adc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Adc_SwTriggerScan | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) |

ADC Scan Software Start Trigger.

This function starts an AD Scan Conversion by Software trigger

Parameters:

  [in] | pstcAdc | ADC instance

Return values:

  Ok | ADC instance triggered (or re-triggered)
  ErrorInvalidParameter | pstcAdc == NULL

Definition at line 992 of file adc.c.

References ErrorInvalidParameter, and Ok.

static stc_adc_intern_data_t * AdcGetInternDataPtr | ( | volatile FM0P_ADC_TypeDef * | pstcAdc | ) | `[static]`

Return the internal data for a certain ADC instance.

Parameters:

  pstcAdc | Pointer to ADC instance

Returns:
  Pointer to internal data or NULL if instance is not enabled (or not known)

Definition at line 132 of file adc.c.

References ADC_INSTANCE_COUNT, and stc_adc_instance_data::stcInternData.

Referenced by Adc_DisableInt(), and Adc_EnableInt().

Here is the caller graph for this function:

void AdcIrqHandler | ( | volatile FM0P_ADC_TypeDef * | pstcAdc,
|  | stc_adc_intern_data_t * | pstcAdcInternData
| ) |  |

ADC instance interrupt service routine.

ADC instance interrupt service routine, clear interrupt cause and

Parameters:

  pstcAdc | Pointer to ADC instance
  pstcAdcInternData | Pointer to ADC intern data

Definition at line 157 of file adc.c.

References stc_adc_intern_data::pfnComparisonCallback, stc_adc_intern_data::pfnPrioCallback, stc_adc_intern_data::pfnPrioErrorCallback, stc_adc_intern_data::pfnRangeComparisonCallback, stc_adc_intern_data::pfnScanCallback, and stc_adc_intern_data::pfnScanErrorCallback.

Referenced by ADC0_IRQHandler(), ADC1_IRQHandler(), and ADC2_LCD_IRQHandler().

Here is the caller graph for this function:

## Variable Documentation

stc_adc_instance_data_t m_astcAdcInstanceDataLut[(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC0==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC1==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC2==PDL_ON)]

Initial value:

    {

      {
         & (*((volatile  FM0P_ADC_TypeDef  *) FM0P_ADC0_BASE)) ,
         {0, 0 ,0, 0, 0 ,0}
      },

      {
         & (*((volatile  FM0P_ADC_TypeDef  *) FM0P_ADC1_BASE)) ,
         {0, 0 ,0, 0, 0 ,0}
      },

      {
         & (*((volatile  FM0P_ADC_TypeDef  *) FM0P_ADC2_BASE)) ,
         {0, 0 ,0, 0, 0 ,0}
      }

    }

Look-up table for all enabled ADC instances and their internal data.

Definition at line 74 of file adc.c.

Referenced by ADC0_IRQHandler(), ADC1_IRQHandler(), and ADC2_LCD_IRQHandler().

stc_adc_instance_data_t m_astcAdcInstanceDataLut[(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC0==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC1==PDL_ON)+(uint8_t)(PDL_PERIPHERAL_ENABLE_ADC2==PDL_ON)]

Look-up table for all enabled ADC instances and their internal data.

Definition at line 74 of file adc.c.

Referenced by ADC0_IRQHandler(), ADC1_IRQHandler(), and ADC2_LCD_IRQHandler().