Functions
IO Operation Functions
Peripheral Driver » HAL Driver » ADC » Functions

ADC polling and DMA conversion management functions. More...

## Functions
hal_status_t | hal_adc_set_dma_threshold (adc_handle_t *p_adc, uint32_t threshold)
| Set the FIFO threshold for DMA trigger. More...
uint32_t | hal_adc_get_dma_threshold (adc_handle_t *p_adc)
| Get the FIFO threshold for DMA trigger. More...
hal_status_t | hal_adc_poll_for_conversion (adc_handle_t *p_adc, uint16_t *p_data, uint32_t length)
| Polling for conversion. More...
hal_status_t | hal_adc_start_dma (adc_handle_t *p_adc, uint16_t *p_data, uint32_t length)
| DMA for conversion. More...
hal_status_t | hal_adc_start_dma_sg_llp (adc_handle_t *p_adc, uint16_t *p_data, uint32_t length, dma_sg_llp_config_t *sg_llp_config)
| DMA for conversion. More...
hal_status_t | hal_adc_stop_dma (adc_handle_t *p_adc)
| Abort ongoing conversion (blocking mode). More...
void | hal_adc_conv_cplt_callback (adc_handle_t *p_adc)
| Conversion completed callback. More...

## Detailed Description

ADC polling and DMA conversion management functions.

## Function Documentation

## ◆ hal_adc_conv_cplt_callback()

void hal_adc_conv_cplt_callback | ( | adc_handle_t * | p_adc | ) |

Conversion completed callback.

Note
  This function should not be modified. When the callback is needed, the hal_adc_conv_cplt_callback can be implemented in the user file.

Parameters

  [in] | p_adc | Pointer to an ADC handle which contains the configuration information for the specified ADC module.

## ◆ hal_adc_get_dma_threshold()

uint32_t hal_adc_get_dma_threshold | ( | adc_handle_t * | p_adc | ) |

Get the FIFO threshold for DMA trigger.

Parameters

  [in] | p_adc | Pointer to an ADC handle which contains the configuration information for the specified ADC module.

Returns
  FIFO threshold

## ◆ hal_adc_poll_for_conversion()

hal_status_t hal_adc_poll_for_conversion | ( | adc_handle_t * | p_adc,
|  | uint16_t * | p_data,
|  | uint32_t | length
| ) |  |

Polling for conversion.

Parameters

  [in] | p_adc | Pointer to an ADC handle.
  [in] | p_data | Pointer to data buffer which to store ADC conversion results.
  [in] | length | Length of data buffer.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_adc_set_dma_threshold()

hal_status_t hal_adc_set_dma_threshold | ( | adc_handle_t * | p_adc,
|  | uint32_t | threshold
| ) |  |

Set the FIFO threshold for DMA trigger.

Parameters

  [in] | p_adc | Pointer to an ADC handle which contains the configuration information for the specified ADC module.
  [in] | threshold | FIFO threshold value ranging bwtween 0x0U ~ 0x64U.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_adc_start_dma()

hal_status_t hal_adc_start_dma | ( | adc_handle_t * | p_adc,
|  | uint16_t * | p_data,
|  | uint32_t | length
| ) |  |

DMA for conversion.

Parameters

  [in] | p_adc | Pointer to an ADC handle.
  [in] | p_data | Pointer to data buffer which to store ADC conversion results.
  [in] | length | Length of data buffer, ranging between 0 and 4095. Note: Length must be aligned on a four-byte boundary.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_adc_start_dma_sg_llp()

hal_status_t hal_adc_start_dma_sg_llp | ( | adc_handle_t * | p_adc,
|  | uint16_t * | p_data,
|  | uint32_t | length,
|  | dma_sg_llp_config_t * | sg_llp_config
| ) |  |

DMA for conversion.

Parameters

  [in] | p_adc | Pointer to an ADC handle.
  [in] | p_data | Pointer to data buffer which to store ADC conversion results.
  [in] | length | Length of data buffer, ranging between 0 and 4095.
  [in] | sg_llp_config | The config of source and destination's SG and LLP functions.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_adc_stop_dma()

hal_status_t hal_adc_stop_dma | ( | adc_handle_t * | p_adc | ) |

Abort ongoing conversion (blocking mode).

Note
  This procedure could be only used for aborting conversion started in DMA mode. This procedure performs following operations:
  - Disable ADC clock, stop conversion
  - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
  - Set handle State to READY. This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.

Parameters

  [in] | p_adc | ADC handle.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.