STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Adc.h File Reference

ADC Driver More...

#include "Adc_Cfg.h"
#include "Adc_Types.h"

Go to the source code of this file.

Functions

void Adc_Init (const Adc_ConfigType *ConfigPtr)
 ADC Initialization
 
Std_ReturnType Adc_SetupResultBuffer (Adc_GroupType Group, Adc_ValueGroupType *DataBufferPtr)
 ADC Result Buffer
 
void Adc_DeInit (void)
 ADC Deinitialization
 
void Adc_StartGroupConversion (Adc_GroupType Group)
 ADC Start Group Conversion
 
void Adc_StopGroupConversion (Adc_GroupType Group)
 ADC Stop Group Conversion
 
Std_ReturnType Adc_ReadGroup (Adc_GroupType Group, Adc_ValueGroupType *DataBufferPtr)
 ADC Read Group
 
void Adc_EnableHardwareTrigger (Adc_GroupType Group)
 ADC Enable Hardware Trigger
 
void Adc_DisableHardwareTrigger (Adc_GroupType Group)
 ADC Disable Hardware Trigger
 
void Adc_EnableGroupNotification (Adc_GroupType Group)
 ADC Enable Group Notification
 
void Adc_DisableGroupNotification (Adc_GroupType Group)
 ADC Disable Group Notification
 
Adc_StatusType Adc_GetGroupStatus (Adc_GroupType Group)
 ADC Get Group Status
 
Adc_StreamNumSampleType Adc_GetStreamLastPointer (Adc_GroupType Group, Adc_ValueGroupType **PtrToSamplePtr)
 ADC Get Stream Last Pointer
 
void Adc_GetVersionInfo (Std_VersionInfoType *versioninfo)
 ADC Get Version Info
 
Std_ReturnType Adc_SetPowerState (Adc_PowerStateRequestResultType *Result)
 ADC Set Power State
 
Std_ReturnType Adc_GetCurrentPowerState (Adc_PowerStateType *CurrentPowerState, Adc_PowerStateRequestResultType *Result)
 ADC Get Current Power State
 
Std_ReturnType Adc_GetTargetPowerState (Adc_PowerStateType *TargetPowerState, Adc_PowerStateRequestResultType *Result)
 ADC Get Target Power State
 
Std_ReturnType Adc_PreparePowerState (Adc_PowerStateType PowerState, Adc_PowerStateRequestResultType *Result)
 ADC Prepare Power State
 

Detailed Description

ADC Driver

Author
Naim Leon

The ADC module provides the functionality API and the configuration of the AUTOSAR Basic Software module ADC Driver. The ADC driver is targeting Successive Approximation ADC Hardware. Delta Sigma ADC conversion use cases are out of scope of this module.

Function Documentation

◆ Adc_DeInit()

void Adc_DeInit ( void )

ADC Deinitialization

This function Returns all ADC HW Units to a state comparable to their power on reset state.

Requirement
SWS_Adc_00366 SWS_Adc_00228 SWS_Adc_00154

◆ Adc_DisableGroupNotification()

void Adc_DisableGroupNotification ( Adc_GroupType Group)

ADC Disable Group Notification

Disables the notification mechanism for the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Requirement
SWS_Adc_91004 SWS_Adc_00101 SWS_Adc_00131 SWS_Adc_00166 SWS_Adc_00300

◆ Adc_DisableHardwareTrigger()

void Adc_DisableHardwareTrigger ( Adc_GroupType Group)

ADC Disable Hardware Trigger

Disables the hardware trigger for the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Requirement
SWS_Adc_91002 SWS_Adc_00266 SWS_Adc_00129 SWS_Adc_00137 SWS_Adc_00282 SWS_Adc_00298

◆ Adc_EnableGroupNotification()

void Adc_EnableGroupNotification ( Adc_GroupType Group)

ADC Enable Group Notification

Enables the notification mechanism for the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Requirement
SWS_Adc_91003 SWS_Adc_00100 SWS_Adc_00130 SWS_Adc_00165 SWS_Adc_00299

◆ Adc_EnableHardwareTrigger()

void Adc_EnableHardwareTrigger ( Adc_GroupType Group)

ADC Enable Hardware Trigger

Enables the hardware trigger for the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Requirement
SWS_Adc_91001 SWS_Adc_00265 SWS_Adc_00128 SWS_Adc_00136 SWS_Adc_00281 SWS_Adc_00297 SWS_Adc_00425

◆ Adc_GetCurrentPowerState()

Std_ReturnType Adc_GetCurrentPowerState ( Adc_PowerStateType * CurrentPowerState,
Adc_PowerStateRequestResultType * Result )

ADC Get Current Power State

This API returns the current power state of the ADC HW unit.

Parameters
CurrentPowerStateThe current power mode of the ADC HW Unit is returned in this parameter.
ResultIf 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.
Return values
E_OKMode could be read E_NOT_OK: Service is rejected
Requirement
SWS_Adc_00476 SWS_Adc_00491

◆ Adc_GetGroupStatus()

Adc_StatusType Adc_GetGroupStatus ( Adc_GroupType Group)

ADC Get Group Status

Returns the conversion status of the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Return values
Conversionstatus for the requested group.
Requirement
SWS_Adc_00374 SWS_Adc_00301

◆ Adc_GetStreamLastPointer()

Adc_StreamNumSampleType Adc_GetStreamLastPointer ( Adc_GroupType Group,
Adc_ValueGroupType ** PtrToSamplePtr )

ADC 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).

Parameters
GroupNumeric ID of requested ADC Channel group.
PtrToSamplePtrPointer to result buffer pointer.
Return values
Numberof valid samples per channel.
Requirement
SWS_Adc_00375 SWS_Adc_00218 SWS_Adc_00302

◆ Adc_GetTargetPowerState()

Std_ReturnType Adc_GetTargetPowerState ( Adc_PowerStateType * TargetPowerState,
Adc_PowerStateRequestResultType * Result )

ADC Get Target Power State

This API returns the Target power state of the ADC HW unit.

Parameters
TargetPowerStateThe Target power mode of the ADC HW Unit is returned in this parameter.
ResultIf 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.
Return values
E_OKMode could be read E_NOT_OK: Service is rejected
Requirement
SWS_Adc_00477 SWS_Adc_00493

◆ Adc_GetVersionInfo()

void Adc_GetVersionInfo ( Std_VersionInfoType * versioninfo)

ADC Get Version Info

Returns the version information of this module.

Parameters
versioninfoPointer to where to store the version information of this module.
Requirement
SWS_Adc_00376 SWS_Adc_00458

◆ Adc_Init()

void Adc_Init ( const Adc_ConfigType * ConfigPtr)

ADC Initialization

This function Initializes the ADC hardware units and driver.

Parameters
ConfigPtrPointer to configuration set in Variant PB (Variant PC requires a NULL_PTR).
Requirement
SWS_Adc_00365 SWS_Adc_00107

◆ Adc_PreparePowerState()

Std_ReturnType Adc_PreparePowerState ( Adc_PowerStateType PowerState,
Adc_PowerStateRequestResultType * Result )

ADC Prepare Power State

This API starts the needed process to allow the ADC HW module to enter the requested power state

Parameters
PowerStateThe target power state intended to be attained.
ResultIf 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.
Return values
E_OKMode could be read E_NOT_OK: Service is rejected
Requirement
SWS_Adc_00478 SWS_Adc_00496 SWS_Adc_00497

◆ Adc_ReadGroup()

Std_ReturnType Adc_ReadGroup ( Adc_GroupType Group,
Adc_ValueGroupType * DataBufferPtr )

ADC 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).

Parameters
GroupNumeric ID of requested ADC channel group.
DataBufferPtrADC results of all channels of the selected group are stored in the data buffer addressed with the pointer.
Return values
E_OKresults are available and written to the data buffer E_NOT_OK: no results are available or development error occured
Requirement
SWS_Adc_00369 SWS_Adc_00359 SWS_Adc_00152 SWS_Adc_00296

◆ Adc_SetPowerState()

Std_ReturnType Adc_SetPowerState ( Adc_PowerStateRequestResultType * Result)

ADC 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.

Parameters
ResultIf 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.
Return values
E_OKPower Mode changed E_NOT_OK: request rejected
Requirement
SWS_Adc_00475 SWS_Adc_00486 SWS_Adc_00488 SWS_Adc_00490

◆ Adc_SetupResultBuffer()

Std_ReturnType Adc_SetupResultBuffer ( Adc_GroupType Group,
Adc_ValueGroupType * DataBufferPtr )

ADC 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.

Parameters
GroupNumeric ID of requested ADC channel group.
DataBufferPtrPointer to result data buffer.
Return values
E_OKresult buffer pointer initialized correctly E_NOT_OK: operation failed or development error occured
Requirement
SWS_Adc_91000 SWS_Adc_00423 SWS_Adc_00434 SWS_Adc_00457

◆ Adc_StartGroupConversion()

void Adc_StartGroupConversion ( Adc_GroupType Group)

ADC Start Group Conversion

Starts the conversion of all channels of the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Requirement
SWS_Adc_00367 SWS_Adc_00259 SWS_Adc_00125 SWS_Adc_00133 SWS_Adc_00294 SWS_Adc_00424

◆ Adc_StopGroupConversion()

void Adc_StopGroupConversion ( Adc_GroupType Group)

ADC Stop Group Conversion

Stops the conversion of the requested ADC Channel group.

Parameters
GroupNumeric ID of requested ADC Channel group.
Requirement
SWS_Adc_00368 SWS_Adc_00260 SWS_Adc_00126 SWS_Adc_00164 SWS_Adc_00295