Functions
Initialization and de-initialization Functions
Peripheral Driver » HAL Driver » GPADC » Functions

Initialization and Configuration functions. More...

## Functions
hal_status_t | hal_gpadc_init (gpadc_handle_t *p_gpadc)
| Initialize the GPADC according to the specified parameters in the gpadc_init_t and initialize the associated handle. More...
hal_status_t | hal_gpadc_deinit (gpadc_handle_t *p_gpadc)
| De-initialize the GPADC peripheral. More...
void | hal_gpadc_msp_init (gpadc_handle_t *p_gpadc)
| Initialize the GPADC MSP. More...
void | hal_gpadc_msp_deinit (gpadc_handle_t *p_gpadc)
| De-initialize the GPADC MSP. More...
hal_status_t | hal_gpadc_poll_for_conversion (gpadc_handle_t *p_gpadc, uint16_t *p_data, uint32_t length)
| Polling for conversion. More...
hal_status_t | hal_gpadc_start_dma (gpadc_handle_t *p_gpadc, uint16_t *p_data, uint32_t length)
| DMA for conversion. More...
hal_status_t | hal_gpadc_start_dma_sg_llp (gpadc_handle_t *p_gpadc, uint16_t *p_data, uint32_t length, dma_sg_llp_config_t *sg_llp_config)
| DMA for conversion. More...
hal_status_t | hal_gpadc_stop_dma (gpadc_handle_t *p_gpadc)
| Abort ongoing conversion (blocking mode). More...
void | hal_gpadc_conv_cplt_callback (gpadc_handle_t *p_gpadc)
| Conversion completed callback. More...
hal_gpadc_state_t | hal_gpadc_get_state (gpadc_handle_t *p_gpadc)
| Return the GPADC handle state. More...
uint32_t | hal_gpadc_get_error (gpadc_handle_t *p_gpadc)
| Return the GPADC error code. More...
hal_status_t | hal_gpadc_suspend_reg (gpadc_handle_t *p_gpadc)
| Suspend some registers related to GPADC configuration before sleep. More...
hal_status_t | hal_gpadc_resume_reg (gpadc_handle_t *p_gpadc)
| Restore some registers related to GPADC configuration after sleep. This function must be used in conjunction with the hal_gpadc_suspend_reg(). More...
void | hal_gr55xx_gpadc_code_to_voltage (gpadc_handle_t *p_gpadc, uint16_t *inbuf, float *outbuf, uint32_t buflen)
| Convert the GPADC conversion results to a voltage value. More...

## Detailed Description

Initialization and Configuration functions.

## Function Documentation

## ◆ hal_gpadc_conv_cplt_callback()

void hal_gpadc_conv_cplt_callback | ( | gpadc_handle_t * | p_gpadc | ) |

Conversion completed callback.

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

Parameters

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

## ◆ hal_gpadc_deinit()

hal_status_t hal_gpadc_deinit | ( | gpadc_handle_t * | p_gpadc | ) |

De-initialize the GPADC peripheral.

Parameters

  [in] | p_gpadc | Pointer to an GPADC handle which contains the configuration information for the specified GPADC 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_gpadc_get_error()

uint32_t hal_gpadc_get_error | ( | gpadc_handle_t * | p_gpadc | ) |

Return the GPADC error code.

Parameters

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

Returns
  GPADC error code in bitmap format

## ◆ hal_gpadc_get_state()

hal_gpadc_state_t hal_gpadc_get_state | ( | gpadc_handle_t * | p_gpadc | ) |

Return the GPADC handle state.

Parameters

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

Return values

  HAL_GPADC_STATE_RESET | Peripheral not initialized.
  HAL_GPADC_STATE_READY | Peripheral initialized and ready for use.
  HAL_GPADC_STATE_BUSY | An internal process is ongoing.
  HAL_GPADC_STATE_ERROR | Peripheral in error.

## ◆ hal_gpadc_init()

hal_status_t hal_gpadc_init | ( | gpadc_handle_t * | p_gpadc | ) |

Initialize the GPADC according to the specified parameters in the gpadc_init_t and initialize the associated handle.

Parameters

  [in] | p_gpadc | Pointer to an GPADC handle which contains the configuration information for the specified GPADC 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_gpadc_msp_deinit()

void hal_gpadc_msp_deinit | ( | gpadc_handle_t * | p_gpadc | ) |

De-initialize the GPADC MSP.

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

Parameters

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

## ◆ hal_gpadc_msp_init()

void hal_gpadc_msp_init | ( | gpadc_handle_t * | p_gpadc | ) |

Initialize the GPADC MSP.

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

Parameters

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

## ◆ hal_gpadc_poll_for_conversion()

hal_status_t hal_gpadc_poll_for_conversion | ( | gpadc_handle_t * | p_gpadc,
|  | uint16_t * | p_data,
|  | uint32_t | length
| ) |  |

Polling for conversion.

Parameters

  [in] | p_gpadc | Pointer to an GPADC handle.
  [in] | p_data | Pointer to data buffer which to store GPADC 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_gpadc_resume_reg()

hal_status_t hal_gpadc_resume_reg | ( | gpadc_handle_t * | p_gpadc | ) |

Restore some registers related to GPADC configuration after sleep. This function must be used in conjunction with the hal_gpadc_suspend_reg().

Parameters

  [in] | p_gpadc | Pointer to a GPADC handle which contains the configuration information for the specified GPADC 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_gpadc_start_dma()

hal_status_t hal_gpadc_start_dma | ( | gpadc_handle_t * | p_gpadc,
|  | uint16_t * | p_data,
|  | uint32_t | length
| ) |  |

DMA for conversion.

Parameters

  [in] | p_gpadc | Pointer to an GPADC handle.
  [in] | p_data | Pointer to data buffer which to store GPADC conversion results.
  [in] | length | Length of data buffer, ranging between 0 and 4095.

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

hal_status_t hal_gpadc_start_dma_sg_llp | ( | gpadc_handle_t * | p_gpadc,
|  | uint16_t * | p_data,
|  | uint32_t | length,
|  | dma_sg_llp_config_t * | sg_llp_config
| ) |  |

DMA for conversion.

Parameters

  [in] | p_gpadc | Pointer to an GPADC handle.
  [in] | p_data | Pointer to data buffer which to store GPADC 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_gpadc_stop_dma()

hal_status_t hal_gpadc_stop_dma | ( | gpadc_handle_t * | p_gpadc | ) |

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 GPADC 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_gpadc | GPADC 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.

## ◆ hal_gpadc_suspend_reg()

hal_status_t hal_gpadc_suspend_reg | ( | gpadc_handle_t * | p_gpadc | ) |

Suspend some registers related to GPADC configuration before sleep.

Parameters

  [in] | p_gpadc | Pointer to a GPADC handle which contains the configuration information for the specified GPADC 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_gr55xx_gpadc_code_to_voltage()

void hal_gr55xx_gpadc_code_to_voltage | ( | gpadc_handle_t * | p_gpadc,
|  | uint16_t * | inbuf,
|  | float * | outbuf,
|  | uint32_t | buflen
| ) |  |

Convert the GPADC conversion results to a voltage value.

Parameters

  [in] | p_gpadc | Pointer to a GPADC handle which contains the configuration information for the specified GPADC module.
  [in] | inbuf | Pointer to data buffer which storage GPADC conversion results.
  [out] | outbuf | Pointer to data buffer which to storage voltage results.
  [in] | buflen | Length of data buffer, ranging between 0 and 4095.

Returns
  Result of operation.