Functions
Peripheral State and Errors Functions
Peripheral Driver » HAL Driver » ADC » Functions

ADC control functions. More...

Collaboration diagram for Peripheral State and Errors Functions:

## Functions
hal_adc_state_t | hal_adc_get_state (adc_handle_t *p_adc)
| Return the ADC handle state. More...
uint32_t | hal_adc_get_error (adc_handle_t *p_adc)
| Return the ADC error code. More...
hal_status_t | hal_adc_suspend_reg (adc_handle_t *p_adc)
| Suspend some registers related to ADC configuration before sleep. More...
hal_status_t | hal_adc_resume_reg (adc_handle_t *p_adc)
| Restore some registers related to ADC configuration after sleep. More...
hal_status_t | hal_adc_change_channels (adc_handle_t *p_adc)
| Set the new channels parameter to ADC. More...
hal_status_t | hal_adc_clock_start (adc_handle_t *p_adc)
| Start the ADC clock. More...
hal_status_t | hal_adc_get_avg_voltage (adc_handle_t *p_adc, float *p_data, uint32_t length)
| Get the ADC sampling code by polling, and convert sampling code of the specified length to the average voltage. More...

## Detailed Description

ADC control functions.

     ===============================================================================
                          ##### Peripheral State and Errors functions #####
     ===============================================================================
        [..]
        This subsection provides a set of functions allowing to control the ADC.
         (+) hal_adc_get_state() API can be helpful to check in run-time the state of the ADC peripheral.
         (+) hal_adc_get_error() check in run-time Errors occurring during communication.

## Function Documentation

## ◆ hal_adc_change_channels()

hal_status_t hal_adc_change_channels | ( | adc_handle_t * | p_adc | ) |

Set the new channels parameter to ADC.

Parameters

  [in] | p_adc | Pointer to a ADC handle which contains the new channels parameter.

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_clock_start()

hal_status_t hal_adc_clock_start | ( | adc_handle_t * | p_adc | ) |

Start the ADC clock.

Parameters

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

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_get_avg_voltage()

hal_status_t hal_adc_get_avg_voltage | ( | adc_handle_t * | p_adc,
|  | float * | p_data,
|  | uint32_t | length
| ) |  |

Get the ADC sampling code by polling, and convert sampling code of the specified length to the average voltage.

Parameters

  [in] | p_adc | Pointer to a ADC handle which contains the new channels parameter.
  [in] | p_data | Pointer to data which to storage average voltage results.
  [in] | length | Length of the ADC sample values to be averaged.

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_get_error()

uint32_t hal_adc_get_error | ( | adc_handle_t * | p_adc | ) |

Return the ADC error code.

Parameters

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

Returns
  ADC error code in bitmap format

## ◆ hal_adc_get_state()

hal_adc_state_t hal_adc_get_state | ( | adc_handle_t * | p_adc | ) |

Return the ADC handle state.

Parameters

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

Return values

  HAL_ADC_STATE_RESET | Peripheral not initialized.
  HAL_ADC_STATE_READY | Peripheral initialized and ready for use.
  HAL_ADC_STATE_BUSY | An internal process is ongoing.
  HAL_ADC_STATE_ERROR | Peripheral in error.

## ◆ hal_adc_resume_reg()

hal_status_t hal_adc_resume_reg | ( | adc_handle_t * | p_adc | ) |

Restore some registers related to ADC configuration after sleep.

This function must be used in conjunction with the hal_adc_suspend_reg().

Parameters

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

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_suspend_reg()

hal_status_t hal_adc_suspend_reg | ( | adc_handle_t * | p_adc | ) |

Suspend some registers related to ADC configuration before sleep.

Parameters

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

Return values

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