46#ifdef HIERODULE_ADC_SMOOTHENING_FILTER
68 void (*ISR)(uint16_t))
72 uint32_t ADC_Address = (uint32_t)_ADC;
75 case ( (uint32_t)ADC1 ):
79 #ifdef __STM32F103xB_H
80 case ( (uint32_t)ADC2 ):
92 (*Wrapper)->_ADC = _ADC;
96 #ifdef HIERODULE_ADC_SMOOTHENING_FILTER
97 (*Wrapper)->FilterWeight = 0.5;
101 (*Wrapper)->Data_Handler = ISR;
121 #if ( (defined __STM32F103xB_H) || (defined __STM32F401xC_H) )
122 SET_BIT(
Wrapper->_ADC->CR1, ADC_CR1_EOCIE);
123 CLEAR_BIT(
Wrapper->_ADC->SR, ADC_SR_EOC);
124 SET_BIT(
Wrapper->_ADC->CR2, ADC_CR2_ADON);
127 #ifdef __STM32F103xB_H
128 SET_BIT(
Wrapper->_ADC->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));
130 #elif defined __STM32F401xC_H
131 SET_BIT(
Wrapper->_ADC->CR2, ADC_CR2_SWSTART);
135 #elif defined __STM32F030x6_H
136 SET_BIT(
Wrapper->_ADC->IER, ADC_IER_EOCIE);
137 CLEAR_BIT(
Wrapper->_ADC->ISR, ADC_ISR_EOC);
138 SET_BIT(
Wrapper->_ADC->CR, ADC_CR_ADEN);
139 SET_BIT(
Wrapper->_ADC->CR, ADC_CR_ADSTART);
149 #if ( (defined __STM32F103xB_H) || (defined __STM32F401xC_H) )
150 CLEAR_BIT(
Wrapper->_ADC->CR1, ADC_CR1_EOCIE);
151 CLEAR_BIT(
Wrapper->_ADC->CR2, ADC_CR2_ADON);
154 #ifdef __STM32F103xB_H
155 CLEAR_BIT(
Wrapper->_ADC->CR2, (ADC_CR2_SWSTART | ADC_CR2_EXTTRIG));
157 #elif defined __STM32F401xC_H
158 CLEAR_BIT(
Wrapper->_ADC->CR2, ADC_CR2_SWSTART);
162 #elif defined __STM32F030x6_H
163 SET_BIT(
Wrapper->_ADC->CR, ADC_CR_ADDIS);
164 SET_BIT(
Wrapper->_ADC->CR, ADC_CR_ADSTP);
175#ifdef __STM32F103xB_H
185 #ifdef HIERODULE_ADC_SMOOTHENING_FILTER
208 #ifdef HIERODULE_ADC_SMOOTHENING_FILTER
227#ifdef __STM32F401xC_H
242 #ifdef HIERODULE_ADC_SMOOTHENING_FILTER
261#ifdef __STM32F030x6_H
276 #ifdef HIERODULE_ADC_SMOOTHENING_FILTER
void Smoothen(HIERODULE_ADC_Wrapper *Wrapper)
Applies a cumulative-smoothening filter before updating the wrapper data field.
static HIERODULE_ADC_Wrapper * ADC2_Wrapper
ADC wrapper pointer meant for ADC2. Requires the device specific macro __STM32F103xB_H to be defined.
static HIERODULE_ADC_Wrapper * ADC1_Wrapper
ADC wrapper pointer meant for ADC1.
void ADC_IRQHandler(void)
ADC IRQ implementation. Requires the device specific macro __STM32F401xC_H to be defined.
HIERODULE_ADC_Wrapper ** HIERODULE_ADC_InitWrapper(ADC_TypeDef *_ADC, void(*ISR)(uint16_t))
Initializes a wrapper for the specified ADC peripheral.
void ADC1_2_IRQHandler(void)
ADC1_2 IRQ implementation. Requires the device specific macro __STM32F103xB_H to be defined.
void HIERODULE_ADC_Enable(HIERODULE_ADC_Wrapper *Wrapper)
Updates relevant control register bits to start ADC action.
void ADC1_IRQHandler(void)
ADC1 IRQ implementation. Requires the device specific macro __STM32F030x6_H to be defined.
void HIERODULE_ADC_ReleaseWrapper(HIERODULE_ADC_Wrapper *Wrapper)
Frees the memory allocated to an ADC wrapper.
void HIERODULE_ADC_Disable(HIERODULE_ADC_Wrapper *Wrapper)
Updates relevant control register bits to stop ADC action.
HIERODULE_USB_Wrapper Wrapper
Extern declaration for the wrapper instance in the source file.
: Header file for the ADC module.
Struct that keeps variables for the ADC data, a pointer to the ADC peripheral and a pointer to the IS...
ADC_TypeDef * _ADC
Pointer to the ADC peripheral.
void(* Data_Handler)(uint16_t)
Pointer to the ISR for EOC.
uint16_t Data
Variable to assign the received ADC data.