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

Adc Driver More...

#include "Registers.h"
#include "Std_Types.h"

Go to the source code of this file.

Data Structures

struct  Adc_ConfigType
 Adc configuration structure More...
 
struct  _Adc_HwUnit
 Hardware control unit structure More...
 

Macros

#define ADC_ID_INIT   0x00u
 
#define ADC_RESULT_BUFFER   0x0Cu
 
#define ADC_ID_DE_INIT   0x01u
 
#define ADC_START_GROUP_CONVERSION   0x02u
 
#define ADC_STOP_GROUP_CONVERSION   0x03u
 
#define ADC_READ_GROUP   0x04u
 
#define ADC_ENABLE_HARDWARE_TRIGGER   0x05u
 
#define ADC_DISABLE_HARDWARE_TRIGGER   0x06u
 
#define ADC_ENABLE_GROUP_NOTIFICATION   0x07u
 
#define ADC_DISABLE_GROUP_NOTIFICATION   0x08u
 
#define ADC_GET_GROUP_STATUS   0x09u
 
#define ADC_GET_STREAM_LAST_POINTER   0x0Bu
 
#define ADC_GET_VERSION_INFO   0x0Au
 
#define ADC_SET_POWER_STATE   0x10u
 
#define ADC_GET_CURRENT_POWER_STATE   0x11u
 
#define ADC_GET_TARGET_POWER_STATE   0x12u
 
#define ADC_PREPARE_POWER_STATE   0x13u
 
#define ADC_MAIN_POWER_TRANSITION_MANAGER   0x14u
 
#define ADC_E_UNINIT   0x0Au
 
#define ADC_E_ALREADY_INITIALIZED   0x0Du
 
#define ADC_E_PARAM_POINTER   0x14u
 
#define ADC_E_PARAM_GROUP   0x15u
 
#define ADC_E_WRONG_CONV_MODE   0x16u
 
#define ADC_E_WRONG_TRIGG_SRC   0x17u
 
#define ADC_E_NOTIF_CAPABILITY   0x18u
 
#define ADC_E_BUFFER_UNINIT   0x19u
 
#define ADC_E_POWER_STATE_NOT_SUPPORTED   0x1Bu
 
#define ADC_E_PERIPHERAL_NOT_PREPARED   0x1Du
 
#define ADC_E_BUSY   0x0Bu
 
#define ADC_E_IDLE   0x0Cu
 
#define ADC_E_NOT_DISENGAGED   0x1Au
 
#define ADC_E_TRANSITION_NOT_POSSIBLE   0x1Cu
 

Typedefs

typedef uint8 Adc_ChannelType
 Numeric ID of an ADC channel. (Size tbd)
 
typedef uint8 Adc_GroupType
 Numeric ID of an ADC channel group. (Size tbd)
 
typedef uint8 Adc_ValueGroupType
 Type for reading the converted values of a channel group (raw, without further scaling, alignment according precompile switch ADC_RESULT_ALIGNMENT). (Size tbd)
 
typedef uint8 Adc_PrescaleType
 Type of clock prescaler factor. (Size tbd)
 
typedef uint8 Adc_ConversionTimeType
 Type of conversion time, i.e. the time during which the sampled analogue value is converted into digital representation. (Size tbd)
 
typedef uint8 Adc_SamplingTimeType
 Type of sampling time, i.e. the time during which the value is sampled, (in clock-cycles). (Size tbd)
 
typedef uint8 Adc_ResolutionType
 Type of channel resolution in number of bits.
 
typedef uint8 Adc_GroupPriorityType
 Priority level of the channel. Lowest priority is 0.
 
typedef uint8 Adc_GroupDefType
 Type for assignment of channels to a channel group. (size tbd)
 
typedef uint8 Adc_StreamNumSampleType
 Type for configuring the number of group conversions in streaming access mode (in single access mode, parameter is 1).
 
typedef uint8 Adc_HwTriggerTimerType
 Type for the reload value of the ADC module embedded timer (only if supported by the ADC hardware). (size tbd)
 
typedef struct _Adc_HwUnit Adc_HwUnit
 Hardware control unit structure
 

Enumerations

enum  Adc_StatusType { ADC_IDLE = 0 , ADC_BUSY , ADC_COMPLETED , ADC_STREAM_COMPLETED }
 Current status of the conversion of the requested ADC Channel group. More...
 
enum  Adc_TriggerSourceType { ADC_TRIGG_SRC_SW = 0 , ADC_TRIGG_SRC_HW }
 Type for configuring the trigger source for an ADC Channel group. More...
 
enum  Adc_GroupConvModeType { ADC_CONV_MODE_ONESHOT = 0 , ADC_CONV_MODE_CONTINUOUS }
 Type for configuring the conversion mode of an ADC Channel group. More...
 
enum  Adc_StreamBufferModeType { ADC_STREAM_BUFFER_LINEAR = 0 , ADC_STREAM_BUFFER_CIRCULAR }
 Type for configuring the streaming access mode buffer type. More...
 
enum  Adc_GroupAccessModeType { ADC_ACCESS_MODE_SINGLE = 0 , ADC_ACCESS_MODE_STREAMING }
 Type for configuring the access mode to group conversion results. More...
 
enum  Adc_HwTriggerSignalType { ADC_HW_TRIG_RISING_EDGE = 0 , ADC_HW_TRIG_FALLING_EDGE , ADC_HW_TRIG_BOTH_EDGES }
 Type for configuring on which edge of the hardware trigger signal the driver should react, i.e. start the conversion (only if supported by the ADC hardware) More...
 
enum  Adc_PriorityImplementationType { ADC_PRIORITY_NONE = 0 , ADC_PRIORITY_HW , ADC_PRIORITY_HW_SW }
 Type for configuring the prioritization mechanism. More...
 
enum  Adc_GroupReplacementType { ADC_GROUP_REPL_ABORT_RESTART = 0 , ADC_GROUP_REPL_SUSPEND_RESUME }
 Replacement mechanism, which is used on ADC group level, if a group conversion is interrupted by a group which has a higher priority. More...
 
enum  Adc_ChannelRangeSelectType {
  ADC_RANGE_UNDER_LOW = 0 , ADC_RANGE_BETWEEN , ADC_RANGE_OVER_HIGH , ADC_RANGE_ALWAYS ,
  ADC_RANGE_NOT_UNDER_LOW , ADC_RANGE_NOT_BETWEEN , ADC_RANGE_NOT_OVER_HIGH
}
 In case of active limit checking: defines which conversion values are taken into account related to the boardes defineed with AdcChannelLowLimit and AdcChannelHighLimit. More...
 
enum  Adc_ResultAlignmentType { ADC_ALIGN_LEFT = 0 , ADC_ALIGN_RIGHT }
 Type for alignment of ADC raw results in ADC result buffer (left/right alignment). More...
 
enum  Adc_PowerStateType { ADC_FULL_POWER = 0 , DECREASING_POWER }
 Power state currently active or set as target power state. More...
 
enum  Adc_PowerStateRequestResultType {
  ADC_SERVICE_ACCEPTED = 0 , ADC_NOT_INIT , ADC_SEQUENCE_ERROR , ADC_HW_FAILURE ,
  ADC_POWER_STATE_NOT_SUPP , ADC_TRANS_NOT_POSSIBLE
}
 Result of the requests related to power state transitions. More...
 
enum  Group_IDType {
  GROUP_0 = 0 , GROUP_1 , GROUP_2 , GROUP_3 ,
  GROUP_4 , GROUP_5 , GROUP_6 , GROUP_7 ,
  GROUP_8 , GROUP_9 , GROUP_10
}
 For ennumarate the Ids of the different groups. More...
 
enum  PowerStateType {
  PWR_STATE_0 = 0 , PWR_STATE_1 , PWR_STATE_2 , PWR_STATE_3 ,
  PWR_STATE_4 , PWR_STATE_5 , PWR_STATE_6 , PWR_STATE_7 ,
  PWR_STATE_8 , PWR_STATE_9 , PWR_STATE_10
}
 For ennumarate the states of power for the ADC HW unit. More...
 

Detailed Description

Adc Driver

Author
Naim Leon

The header contains the type definitions for the Adc module. The file is implemnted 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 for upper layers.

Typedef Documentation

◆ Adc_ChannelType

Numeric ID of an ADC channel. (Size tbd)

Requirement
SWS_Adc_00506

◆ Adc_ConversionTimeType

Type of conversion time, i.e. the time during which the sampled analogue value is converted into digital representation. (Size tbd)

Requirement
SWS_Adc_00510

◆ Adc_GroupDefType

Type for assignment of channels to a channel group. (size tbd)

Requirement
SWS_Adc_00517

◆ Adc_GroupPriorityType

Priority level of the channel. Lowest priority is 0.

Requirement
SWS_Adc_00516

◆ Adc_GroupType

Numeric ID of an ADC channel group. (Size tbd)

Requirement
SWS_Adc_00507

◆ Adc_HwTriggerTimerType

Type for the reload value of the ADC module embedded timer (only if supported by the ADC hardware). (size tbd)

Requirement
SWS_Adc_00521

◆ Adc_HwUnit

typedef struct _Adc_HwUnit Adc_HwUnit

Hardware control unit structure

This structure contains the hardware unit configuration and the state of the hardware unit pointers to control structures.

◆ Adc_PrescaleType

Type of clock prescaler factor. (Size tbd)

Requirement
SWS_Adc_00509

◆ Adc_ResolutionType

Type of channel resolution in number of bits.

Requirement
SWS_Adc_00512

◆ Adc_SamplingTimeType

Type of sampling time, i.e. the time during which the value is sampled, (in clock-cycles). (Size tbd)

Requirement
SWS_Adc_00511

◆ Adc_StreamNumSampleType

Type for configuring the number of group conversions in streaming access mode (in single access mode, parameter is 1).

Requirement
SWS_Adc_00518

◆ Adc_ValueGroupType

Type for reading the converted values of a channel group (raw, without further scaling, alignment according precompile switch ADC_RESULT_ALIGNMENT). (Size tbd)

Requirement
SWS_Adc_00508

Enumeration Type Documentation

◆ Adc_ChannelRangeSelectType

In case of active limit checking: defines which conversion values are taken into account related to the boardes defineed with AdcChannelLowLimit and AdcChannelHighLimit.

Requirement
SWS_Adc_00524
Enumerator
ADC_RANGE_UNDER_LOW 

Range below low limit - low limit value included

ADC_RANGE_BETWEEN 

Range between low limit and high limit - high limit value included

ADC_RANGE_OVER_HIGH 

Range above high limit

ADC_RANGE_ALWAYS 

Complete range - independent from channel limit settings

ADC_RANGE_NOT_UNDER_LOW 

Range above low limit

ADC_RANGE_NOT_BETWEEN 

Range above high limit or below low limit - low limit value included

ADC_RANGE_NOT_OVER_HIGH 

Range below high limit - high limit value included

◆ Adc_GroupAccessModeType

Type for configuring the access mode to group conversion results.

Requirement
SWS_Adc_00528
Enumerator
ADC_ACCESS_MODE_SINGLE 

Single value access mode.

ADC_ACCESS_MODE_STREAMING 

Streaming access mode.

◆ Adc_GroupConvModeType

Type for configuring the conversion mode of an ADC Channel group.

Requirement
SWS_Adc_00515
Enumerator
ADC_CONV_MODE_ONESHOT 

Exactly one conversion of each channel in an ADC channel group is performed after the configured trigger event. In case of ’group trigger source software’, a started One-Shot conversion can be stopped by a software API call. In case of ’group trigger source hardware’, a started One-Shot conversion can be stopped by disabling the trigger event (if supported by hardware).

ADC_CONV_MODE_CONTINUOUS 

Repeated conversions of each ADC channel in an ADC channel group are performed. ’Continuous conversion mode’ is only available for ’group trigger source software’. A started ’Continuous conversion’ can be stopped by a software API call.

◆ Adc_GroupReplacementType

Replacement mechanism, which is used on ADC group level, if a group conversion is interrupted by a group which has a higher priority.

Requirement
SWS_Adc_00523
Enumerator
ADC_GROUP_REPL_ABORT_RESTART 

Abort/Restart mechanism is used on group level, if a group is interrupted by a higher priority group. The complete conversion round of the interrupted group (all group channels)is restarted after the higher priority group conversion is finished. If the group is configured in streaming access mode, only the results of the interrupted conversion round are discarded. Results of previous conversion rounds which are already written to the result buffer are not affected.

ADC_GROUP_REPL_SUSPEND_RESUME 

Suspend/Resume mechanism is used on group level, if a group is interrupted by a higher priority group. The conversion round of the interrupted group is completed after the higher priority group conversion is finished. Results of previous conversion rounds which are already written to the result buffer are not affected.

◆ Adc_HwTriggerSignalType

Type for configuring on which edge of the hardware trigger signal the driver should react, i.e. start the conversion (only if supported by the ADC hardware)

Requirement
SWS_Adc_00520
Enumerator
ADC_HW_TRIG_RISING_EDGE 

React on the rising edge of the hardware trigger signal (only if supported by the ADC hardware).

ADC_HW_TRIG_FALLING_EDGE 

React on the falling edge of the hardware trigger signal (only if supported by the ADC hardware).

ADC_HW_TRIG_BOTH_EDGES 

React on both edges of the hardware trigger signal (only if supported by the ADC hardware).

◆ Adc_PowerStateRequestResultType

Result of the requests related to power state transitions.

Requirement
SWS_Adc_00527
Enumerator
ADC_SERVICE_ACCEPTED 

Power state change executed.

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.

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.

◆ Adc_PowerStateType

Power state currently active or set as target power state.

Requirement
SWS_Adc_00526
Enumerator
ADC_FULL_POWER 

Full Power

DECREASING_POWER 

Power modes with decreasing power consumptions. Other 254 values tdb

◆ Adc_PriorityImplementationType

Type for configuring the prioritization mechanism.

Requirement
SWS_Adc_00522
Enumerator
ADC_PRIORITY_NONE 

Priority mechanism is not available

ADC_PRIORITY_HW 

Hardware priority mechanism is available only

ADC_PRIORITY_HW_SW 

Hardware and software priority mechanism is available

◆ Adc_ResultAlignmentType

Type for alignment of ADC raw results in ADC result buffer (left/right alignment).

Requirement
SWS_Adc_00525
Enumerator
ADC_ALIGN_LEFT 

left alignment

ADC_ALIGN_RIGHT 

right alignment

◆ Adc_StatusType

Current status of the conversion of the requested ADC Channel group.

Requirement
SWS_Adc_00513
Enumerator
ADC_IDLE 

The conversion of the specified group has not been started. No result is available.

ADC_BUSY 

The conversion of the specified group has been started and is still going on. So far no result is available.

ADC_COMPLETED 

A conversion round (which is not the final one) of the specified group has been finished. A result is available for all channels of the group.

ADC_STREAM_COMPLETED 

The result buffer is completely filled. For each channel of the selected group the number of samples to be acquired is available

◆ Adc_StreamBufferModeType

Type for configuring the streaming access mode buffer type.

Requirement
SWS_Adc_00519
Enumerator
ADC_STREAM_BUFFER_LINEAR 

The ADC Driver stops the conversion as soon as the stream buffer is full (number of samples reached).

ADC_STREAM_BUFFER_CIRCULAR 

The ADC Driver continues the conversion even if the stream buffer is full (number of samples reached) by wrapping around the stream buffer itself.

◆ Adc_TriggerSourceType

Type for configuring the trigger source for an ADC Channel group.

Requirement
SWS_Adc_00514
Enumerator
ADC_TRIGG_SRC_SW 

Group is triggered by a software API call.

ADC_TRIGG_SRC_HW 

Group is triggered by a hardware event.

◆ Group_IDType

For ennumarate the Ids of the different groups.

Enumerator
GROUP_0 

ID 0 ADC Channel group

GROUP_1 

ID 1 ADC Channel group

GROUP_2 

ID 2 ADC Channel group

GROUP_3 

ID 3 ADC Channel group

GROUP_4 

ID 4 ADC Channel group

GROUP_5 

ID 5 ADC Channel group

GROUP_6 

ID 6 ADC Channel group

GROUP_7 

ID 7 ADC Channel group

GROUP_8 

ID 8 ADC Channel group

GROUP_9 

ID 9 ADC Channel group

GROUP_10 

ID 10 ADC Channel group

◆ PowerStateType

For ennumarate the states of power for the ADC HW unit.

Enumerator
PWR_STATE_0 

Power state 0

PWR_STATE_1 

Power state 1

PWR_STATE_2 

Power state 2

PWR_STATE_3 

Power state 3

PWR_STATE_4 

Power state 4

PWR_STATE_5 

Power state 5

PWR_STATE_6 

Power state 6

PWR_STATE_7 

Power state 7

PWR_STATE_8 

Power state 8

PWR_STATE_9 

Power state 9

PWR_STATE_10 

Power state 10