STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
Adc Architecture Driver More...
Adc Architecture Driver
Adc driver implementation for the STM32G0xx family of microcontrollers. This file contains the hardware specific implementation of the Adc driver. The file is implemented as a means of abstraction from the hardware, this way we can avoid to include Arch headers in the actual driver header, making the low level interfaces available only for the inmediate upper layer.
void Adc_Arch_DeInit | ( | Adc_HwUnit * | HwUnit | ) |
ADC low level Deinitialization
This function Returns all ADC HW Units to a state comparable to their power on reset state.
HwUnit | Pointer to the hardware unit configuration |
void Adc_Arch_DisableGroupNotification | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Disable Group Notification
Disables the notification mechanism for the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
void Adc_Arch_DisableHardwareTrigger | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Disable Hardware Trigger
Disables the hardware trigger for the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
void Adc_Arch_EnableGroupNotification | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Enable Group Notification
Enables the notification mechanism for the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
void Adc_Arch_EnableHardwareTrigger | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Enable Hardware Trigger
Enables the hardware trigger for the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
Std_ReturnType Adc_Arch_GetCurrentPowerState | ( | Adc_HwUnit * | HwUnit, |
Adc_PowerStateType * | CurrentPowerState, | ||
Adc_PowerStateRequestResultType * | Result ) |
ADC low level Get Current Power State
This API returns the current power state of the ADC HW unit.
HwUnit | Pointer to the hardware unit configuration |
CurrentPowerState | The current power mode of the ADC HW Unit is returned in this parameter. |
Result | If the API returns E_OK: ADC_SERVICE_ACCEPTED: Current power mode was returned. If the API returns E_NOT_OK: ADC_NOT_INIT: ADC Module not initialized. |
E_OK | Mode could be read E_NOT_OK: Service is rejected |
Adc_StatusType Adc_Arch_GetGroupStatus | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Get Group Status
Returns the conversion status of the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
Conversion | status for the requested group. |
Adc_StreamNumSampleType Adc_Arch_GetStreamLastPointer | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group, | ||
Adc_ValueGroupType ** | PtrToSamplePtr ) |
ADC low level Get Stream Last Pointer
Returns the number of valid samples per channel, stored in the result buffer. Reads a pointer, pointing to a position in the group result buffer. With the pointer position, the results of all group channels of the last completed conversion round can be accessed. With the pointer and the return value, all valid group conversion results can be accessed (the user has to take the layout of the result buffer into account).
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
PtrToSamplePtr | Pointer to result buffer pointer. |
Number | of valid samples per channel. |
Std_ReturnType Adc_Arch_GetTargetPowerState | ( | Adc_HwUnit * | HwUnit, |
Adc_PowerStateType * | TargetPowerState, | ||
Adc_PowerStateRequestResultType * | Result ) |
ADC low level Get Target Power State
This API returns the Target power state of the ADC HW unit.
HwUnit | Pointer to the hardware unit configuration |
TargetPowerState | The Target power mode of the ADC HW Unit is returned in this parameter. |
Result | If the API returns E_OK: ADC_SERVICE_ACCEPTED:Target power mode was returned. If the API returns E_NOT_OK: ADC_NOT_INIT: ADC Module not initialized. |
E_OK | Mode could be read E_NOT_OK: Service is rejected |
void Adc_Arch_Init | ( | Adc_HwUnit * | HwUnit, |
const Adc_ConfigType * | Config ) |
Adc low level Initialization
This function Initializes the ADC hardware units and driver.
HwUnit | Pointer to the hardware unit configuration |
Config | Pointer to driver configuration |
Std_ReturnType Adc_Arch_PreparePowerState | ( | Adc_HwUnit * | HwUnit, |
Adc_PowerStateType | PowerState, | ||
Adc_PowerStateRequestResultType * | Result ) |
ADC low level Prepare Power State
This API starts the needed process to allow the ADC HW module to enter the requested power state
HwUnit | Pointer to the hardware unit configuration |
PowerState | The target power state intended to be attained. |
Result | If the API returns E_OK: ADC_SERVICE_ACCEPTED: ADC Module power state preparation was started. If the API returns E_NOT_OK: ADC_NOT_INIT: ADC Module not initialized. ADC_SEQUENCE_ERROR: wrong API call sequence (Current Power State = Target Power State). ADC_POWER_STATE_NOT_SUPP: ADC Module does not support the requested power state. ADC_TRANS_NOT_POSSIBLE: ADC Module cannot transition directly from the current power state to the requested power state or the HW peripheral is still busy. |
E_OK | Mode could be read E_NOT_OK: Service is rejected |
Std_ReturnType Adc_Arch_ReadGroup | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group, | ||
Adc_ValueGroupType * | DataBufferPtr ) |
ADC low level Read Group
Reads the group conversion result of the last completed conversion round of the requested group and stores the channel values starting at the DataBufferPtr address. The group channel values are stored in ascending channel number order (in contrast to the storage layout of the result buffer if streaming access is configured).
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC channel group. |
DataBufferPtr | ADC results of all channels of the selected group are stored in the data buffer addressed with the pointer. |
E_OK | results are available and written to the data buffer E_NOT_OK: no results are available or development error occured |
Std_ReturnType Adc_Arch_SetPowerState | ( | Adc_HwUnit * | HwUnit, |
Adc_PowerStateRequestResultType * | Result ) |
ADC low level Set Power State
This API configures the Adc module so that it enters the already prepared power state, chosen between a predefined set of configured ones.
HwUnit | Pointer to the hardware unit configuration |
Result | If the API returns E_OK: ADC_SERVICE_ACCEPTED: Power state change executed. If the API returns E_NOT_OK: ADC_NOT_INIT: ADC Module not initialized. ADC_SEQUENCE_ERROR: wrong API call sequence. ADC_HW_FAILURE: the HW module has a failure which prevents it to enter the required power state. |
E_OK | Power Mode changed E_NOT_OK: request rejected |
Std_ReturnType Adc_Arch_SetupResultBuffer | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group, | ||
Adc_ValueGroupType * | DataBufferPtr ) |
ADC low level Result Buffer
This function initializes ADC driver with the group specific result buffer start address where the conversion results will be stored. The application has to ensure that the application buffer, where DataBufferPtr points to, can hold all the conversion results of the specified group. The initialization with Adc_SetupResultBuffer is required after reset, before a group conversion can be started.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC channel group. |
DataBufferPtr | Pointer to result data buffer. |
E_OK | result buffer pointer initialized correctly E_NOT_OK: operation failed or development error occured |
void Adc_Arch_StartGroupConversion | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Start Group Conversion
Starts the conversion of all channels of the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |
void Adc_Arch_StopGroupConversion | ( | Adc_HwUnit * | HwUnit, |
Adc_GroupType | Group ) |
ADC low level Stop Group Conversion
Stops the conversion of the requested ADC Channel group.
HwUnit | Pointer to the hardware unit configuration |
Group | Numeric ID of requested ADC Channel group. |