| BlueNRG-1 Peripherals drivers APIs

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

BlueNRG1_adc.h
Go to the documentation of this file.
1
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef BLUENRG1_ADC_H
25 #define BLUENRG1_ADC_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Includes ------------------------------------------------------------------*/
32 #include "BlueNRG1.h"
33
49 typedef struct {
50 uint8_t ADC_DecimationRate;
53 uint8_t ADC_Input;
56 uint8_t ADC_ConversionMode;
59 uint8_t ADC_Attenuation;
62 uint8_t ADC_ReferenceVoltage;
64 } ADC_InitType;
65
80 #define ADC_DecimationRate_200 ((uint8_t)0x00)
81 #define ADC_DecimationRate_100 ((uint8_t)0x01)
82 #define ADC_DecimationRate_64 ((uint8_t)0x02)
83 #define ADC_DecimationRate_32 ((uint8_t)0x03)
84
85 #define IS_ADC_DECIMATIONRATE(DECIMATIONRATE) (((DECIMATIONRATE) == ADC_DecimationRate_200) || \
86 ((DECIMATIONRATE) == ADC_DecimationRate_100) || \
87 ((DECIMATIONRATE) == ADC_DecimationRate_64) || \
88 ((DECIMATIONRATE) == ADC_DecimationRate_32))
89
97 #define ADC_Input_None ((uint8_t)0x00)
98 #define ADC_Input_AdcPin2 ((uint8_t)0x01)
99 #define ADC_Input_AdcPin1 ((uint8_t)0x02)
100 #define ADC_Input_AdcPin12 ((uint8_t)0x03)
101 #define ADC_Input_TempSensor ((uint8_t)0x04)
102 #define ADC_Input_BattSensor ((uint8_t)0x05)
103 #define ADC_Input_Internal0V60V6 ((uint8_t)0x06)
104 #define ADC_Input_Internal1V20V0 ((uint8_t)0x07)
105 #define ADC_Input_Microphone ((uint8_t)0x0F)
106
107 #define IS_ADC_INPUT(INPUT) (((INPUT) == ADC_Input_None) || \
108 ((INPUT) == ADC_Input_AdcPin1) || \
109 ((INPUT) == ADC_Input_AdcPin2) || \
110 ((INPUT) == ADC_Input_AdcPin12) || \
111 ((INPUT) == ADC_Input_TempSensor) || \
112 ((INPUT) == ADC_Input_BattSensor) || \
113 ((INPUT) == ADC_Input_Internal0V60V6) || \
114 ((INPUT) == ADC_Input_Internal1V20V0) || \
115 ((INPUT) == ADC_Input_Microphone))
116
125 #define ADC_ConversionMode_Single ((uint8_t)0x00)
126 #define ADC_ConversionMode_Continuous ((uint8_t)0x08)
127
128 #define IS_ADC_CONVERSIONMODE(CONVERSIONMODE) (((CONVERSIONMODE) == ADC_ConversionMode_Single) || \
129 ((CONVERSIONMODE) == ADC_ConversionMode_Continuous))
130
139 #define ADC_Attenuation_0dB ((uint8_t)0x00)
140 #define ADC_Attenuation_6dB02 ((uint8_t)0x01)
141 #define ADC_Attenuation_9dB54 ((uint8_t)0x02)
142
143 #define IS_ADC_ATTENUATION(ATTENUATION) (((ATTENUATION) == ADC_Attenuation_0dB) || \
144 ((ATTENUATION) == ADC_Attenuation_6dB02) || \
145 ((ATTENUATION) == ADC_Attenuation_9dB54))
146
155 #define ADC_ReferenceVoltage_0V ((uint8_t)0x00)
156 #define ADC_ReferenceVoltage_0V4 ((uint8_t)0x01)
157 #define ADC_ReferenceVoltage_0V6 ((uint8_t)0x02)
158 #define ADC_ReferenceVoltage_1V2 ((uint8_t)0x03)
159
160 #define IS_ADC_REFERENCEVOLTAGE(REFERENCEVOLTAGE) (((REFERENCEVOLTAGE) == ADC_ReferenceVoltage_0V) || \
161 ((REFERENCEVOLTAGE) == ADC_ReferenceVoltage_0V4) || \
162 ((REFERENCEVOLTAGE) == ADC_ReferenceVoltage_0V6) || \
163 ((REFERENCEVOLTAGE) == ADC_ReferenceVoltage_1V2))
164
172 #define ADC_MIC_800KHZ ((uint8_t)0x00)
173 #define ADC_MIC_1600KHZ ((uint8_t)0x01)
175 #define IS_ADC_MIC_FREQ_SEL(FREQ) (((FREQ) == ADC_MIC_800KHZ) || ((FREQ) == ADC_MIC_1600KHZ))
176
185 #define ADC_FLAG_CAL ((uint8_t)0x01)
186 #define ADC_FLAG_BUSY ((uint8_t)0x02)
187 #define ADC_FLAG_EOC ((uint8_t)0x04)
188 #define ADC_FLAG_WDG ((uint8_t)0x08)
190 #define IS_ADC_GET_FLAG(FLAG) ((FLAG & 0x0F) != 0)
191
205 void ADC_Init(ADC_InitType* ADC_InitStruct);
206 void ADC_DeInit(void);
207 void ADC_StructInit(ADC_InitType* ADC_InitStruct);
208 void ADC_Cmd(FunctionalState NewState);
209 void ADC_DmaCmd(FunctionalState NewState);
210 void ADC_Calibration(FunctionalState NewState);
211 void ADC_AutoOffsetUpdate(FunctionalState NewState);
212 void ADC_ThresholdCheck(FunctionalState NewState);
213 void ADC_ThresholdConfig(uint32_t ThresholdLow, uint32_t ThresholdHigh);
214 void ADC_ConversionMode(uint8_t ConvertionMode);
215 void ADC_SelectFrequencyMic(uint8_t Frequency);
216 void ADC_RoundConvertedData(FunctionalState NewState);
217 float ADC_GetConvertedData(uint8_t DataType, uint8_t Vref);
218 FlagStatus ADC_GetFlagStatus(uint8_t ADC_Flag);
219 ITStatus ADC_GetITStatus(uint8_t ADC_Flag);
220 void ADC_ITConfig(uint8_t ADC_Flag, FunctionalState NewState);
221
222 float ADC_ConvertDifferentialVoltage(int32_t raw_value, uint8_t attenuation);
223 float ADC_ConvertSingleEndedVoltage(int32_t raw_value, uint8_t channel, uint8_t vRef, uint8_t attenuation);
224 float ADC_ConvertBatterySensor(int32_t raw_value, uint8_t vRef);
225 float ADC_ConvertTemperatureSensor(int32_t raw_value, uint8_t vRef, uint8_t attenuation);
226
232 #define ADC_GetRawData() READ_REG(ADC->DATA_CONV)
233
234
235
248 #ifdef __cplusplus
249 }
250 #endif
251
252 #endif /*BLUENRG1_ADC_H */
253
254 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
ADC_Cmd
void ADC_Cmd(FunctionalState NewState)
Enable disable the ADC conversion.
Definition: BlueNRG1_adc.c:284
ADC_InitType::ADC_ReferenceVoltage
uint8_t ADC_ReferenceVoltage
Definition: BlueNRG1_adc.h:62
ADC_SelectFrequencyMic
void ADC_SelectFrequencyMic(uint8_t Frequency)
Select the frequency of the clock signal for an external MEMS microphone (through IO0) ...
Definition: BlueNRG1_adc.c:445
ADC_ConvertSingleEndedVoltage
float ADC_ConvertSingleEndedVoltage(int32_t raw_value, uint8_t channel, uint8_t vRef, uint8_t attenuation)
Convert raw ADC value in converted single ended voltage value.
Definition: BlueNRG1_adc.c:117
ADC_ConversionMode
void ADC_ConversionMode(uint8_t ConvertionMode)
Configure the ADC conversion mode.
Definition: BlueNRG1_adc.c:406
ADC_InitType::ADC_DecimationRate
uint8_t ADC_DecimationRate
Definition: BlueNRG1_adc.h:50
ADC_InitType::ADC_Attenuation
uint8_t ADC_Attenuation
Definition: BlueNRG1_adc.h:59
ADC_InitType::ADC_Input
uint8_t ADC_Input
Definition: BlueNRG1_adc.h:53
ADC_ConvertTemperatureSensor
float ADC_ConvertTemperatureSensor(int32_t raw_value, uint8_t vRef, uint8_t attenuation)
Convert raw ADC value in temperature level.
Definition: BlueNRG1_adc.c:182
ADC_GetITStatus
ITStatus ADC_GetITStatus(uint8_t ADC_Flag)
Get the status of the masked IT flag. The read operation will clear the flags.
Definition: BlueNRG1_adc.c:499
ADC_ThresholdCheck
void ADC_ThresholdCheck(FunctionalState NewState)
Enable disable the ADC threshold check.
Definition: BlueNRG1_adc.c:371
ADC_AutoOffsetUpdate
void ADC_AutoOffsetUpdate(FunctionalState NewState)
Enable disable the ADC automatic update of the offset.
Definition: BlueNRG1_adc.c:351
ADC_ConvertDifferentialVoltage
float ADC_ConvertDifferentialVoltage(int32_t raw_value, uint8_t attenuation)
Convert raw ADC value in converted differential voltage value.
Definition: BlueNRG1_adc.c:81
ADC_StructInit
void ADC_StructInit(ADC_InitType *ADC_InitStruct)
Fills the ADC_InitStruct with default values.
Definition: BlueNRG1_adc.c:214
ADC_GetFlagStatus
FlagStatus ADC_GetFlagStatus(uint8_t ADC_Flag)
Get the status flag of ADC.
Definition: BlueNRG1_adc.c:471
ADC_ConvertBatterySensor
float ADC_ConvertBatterySensor(int32_t raw_value, uint8_t vRef)
Convert raw ADC value in battery level.
Definition: BlueNRG1_adc.c:171
ADC_RoundConvertedData
void ADC_RoundConvertedData(FunctionalState NewState)
Enable disable the ADC auto round output data.
Definition: BlueNRG1_adc.c:425
ADC_InitType
Structure definition of ADC initialization.
Definition: BlueNRG1_adc.h:49
ADC_DeInit
void ADC_DeInit(void)
Deinitializes ADC peripheral registers to their default reset values.
Definition: BlueNRG1_adc.c:202
ADC_Calibration
void ADC_Calibration(FunctionalState NewState)
Enable disable the ADC calibration procedure.
Definition: BlueNRG1_adc.c:330
ADC_InitType::ADC_ConversionMode
uint8_t ADC_ConversionMode
Definition: BlueNRG1_adc.h:56
ADC_DmaCmd
void ADC_DmaCmd(FunctionalState NewState)
Enable disable the ADC DMA feature.
Definition: BlueNRG1_adc.c:309
ADC_GetConvertedData
float ADC_GetConvertedData(uint8_t DataType, uint8_t Vref)
Get the ADC converted value in Volt.
Definition: BlueNRG1_adc.c:562
ADC_Init
void ADC_Init(ADC_InitType *ADC_InitStruct)
Initializes the ADC peripheral according to the specified parameters in the ADC_InitStruct.
Definition: BlueNRG1_adc.c:240
ADC_ThresholdConfig
void ADC_ThresholdConfig(uint32_t ThresholdLow, uint32_t ThresholdHigh)
Configure the ADC threshold.
Definition: BlueNRG1_adc.c:391
ADC_ITConfig
void ADC_ITConfig(uint8_t ADC_Flag, FunctionalState NewState)
Enable disable the ADC IT flag.
Definition: BlueNRG1_adc.c:529