39 #include <px4_platform_common/px4_config.h> 42 #include <nuttx/arch.h> 43 #include <arch/stm32/chip.h> 56 #define REG(_reg) (*(volatile uint32_t *)(STM32_ADC1_BASE + _reg)) 58 #define rSR REG(STM32_ADC_SR_OFFSET) 59 #define rCR1 REG(STM32_ADC_CR1_OFFSET) 60 #define rCR2 REG(STM32_ADC_CR2_OFFSET) 61 #define rSMPR1 REG(STM32_ADC_SMPR1_OFFSET) 62 #define rSMPR2 REG(STM32_ADC_SMPR2_OFFSET) 63 #define rJOFR1 REG(STM32_ADC_JOFR1_OFFSET) 64 #define rJOFR2 REG(STM32_ADC_JOFR2_OFFSET) 65 #define rJOFR3 REG(STM32_ADC_JOFR3_OFFSET) 66 #define rJOFR4 REG(STM32_ADC_JOFR4_OFFSET) 67 #define rHTR REG(STM32_ADC_HTR_OFFSET) 68 #define rLTR REG(STM32_ADC_LTR_OFFSET) 69 #define rSQR1 REG(STM32_ADC_SQR1_OFFSET) 70 #define rSQR2 REG(STM32_ADC_SQR2_OFFSET) 71 #define rSQR3 REG(STM32_ADC_SQR3_OFFSET) 72 #define rJSQR REG(STM32_ADC_JSQR_OFFSET) 73 #define rJDR1 REG(STM32_ADC_JDR1_OFFSET) 74 #define rJDR2 REG(STM32_ADC_JDR2_OFFSET) 75 #define rJDR3 REG(STM32_ADC_JDR3_OFFSET) 76 #define rJDR4 REG(STM32_ADC_JDR4_OFFSET) 77 #define rDR REG(STM32_ADC_DR_OFFSET) 87 rCR2 &= ~ADC_CR2_ADON;
96 rCR2 |= ADC_CR2_RSTCAL;
99 if (
rCR2 & ADC_CR2_RSTCAL) {
106 if (
rCR2 & ADC_CR2_CAL) {
120 rSMPR1 = 0b00000000011011011011011011011011;
121 rSMPR2 = 0b00011011011011011011011011011011;
123 rCR2 |= ADC_CR2_TSVREFE;
148 rCR2 |= ADC_CR2_ADON;
153 while (!(
rSR & ADC_SR_EOC)) {
163 uint16_t result =
rDR;
measure the time elapsed performing an event
High-resolution timer with callouts and timekeeping.
static hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
Compute the delta between a timestamp taken in the past and now.
void perf_end(perf_counter_t handle)
End a performance event.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
General defines and structures for the PX4IO module firmware.
int adc_init(void)
Sensors/misc inputs.
void perf_begin(perf_counter_t handle)
Begin a performance event.
uint16_t adc_measure(unsigned channel)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
Performance measuring tools.