PX4 Firmware
PX4 Autopilot Software http://px4.io
adc.c File Reference

Simple ADC support for PX4IO on STM32. More...

#include <px4_platform_common/px4_config.h>
#include <stdint.h>
#include <nuttx/arch.h>
#include <arch/stm32/chip.h>
#include <stm32.h>
#include <drivers/drv_hrt.h>
#include <perf/perf_counter.h>
#include "px4io.h"
Include dependency graph for adc.c:

Go to the source code of this file.

Macros

#define DEBUG
 
#define REG(_reg)   (*(volatile uint32_t *)(STM32_ADC1_BASE + _reg))
 
#define rSR   REG(STM32_ADC_SR_OFFSET)
 
#define rCR1   REG(STM32_ADC_CR1_OFFSET)
 
#define rCR2   REG(STM32_ADC_CR2_OFFSET)
 
#define rSMPR1   REG(STM32_ADC_SMPR1_OFFSET)
 
#define rSMPR2   REG(STM32_ADC_SMPR2_OFFSET)
 
#define rJOFR1   REG(STM32_ADC_JOFR1_OFFSET)
 
#define rJOFR2   REG(STM32_ADC_JOFR2_OFFSET)
 
#define rJOFR3   REG(STM32_ADC_JOFR3_OFFSET)
 
#define rJOFR4   REG(STM32_ADC_JOFR4_OFFSET)
 
#define rHTR   REG(STM32_ADC_HTR_OFFSET)
 
#define rLTR   REG(STM32_ADC_LTR_OFFSET)
 
#define rSQR1   REG(STM32_ADC_SQR1_OFFSET)
 
#define rSQR2   REG(STM32_ADC_SQR2_OFFSET)
 
#define rSQR3   REG(STM32_ADC_SQR3_OFFSET)
 
#define rJSQR   REG(STM32_ADC_JSQR_OFFSET)
 
#define rJDR1   REG(STM32_ADC_JDR1_OFFSET)
 
#define rJDR2   REG(STM32_ADC_JDR2_OFFSET)
 
#define rJDR3   REG(STM32_ADC_JDR3_OFFSET)
 
#define rJDR4   REG(STM32_ADC_JDR4_OFFSET)
 
#define rDR   REG(STM32_ADC_DR_OFFSET)
 

Functions

int adc_init (void)
 Sensors/misc inputs. More...
 
uint16_t adc_measure (unsigned channel)
 

Variables

perf_counter_t adc_perf
 

Detailed Description

Simple ADC support for PX4IO on STM32.

Definition in file adc.c.

Macro Definition Documentation

◆ DEBUG

#define DEBUG

Definition at line 49 of file adc.c.

◆ rCR1

#define rCR1   REG(STM32_ADC_CR1_OFFSET)

Definition at line 59 of file adc.c.

◆ rCR2

#define rCR2   REG(STM32_ADC_CR2_OFFSET)

Definition at line 60 of file adc.c.

Referenced by adc_init(), and adc_measure().

◆ rDR

#define rDR   REG(STM32_ADC_DR_OFFSET)

Definition at line 77 of file adc.c.

Referenced by adc_measure().

◆ REG

#define REG (   _reg)    (*(volatile uint32_t *)(STM32_ADC1_BASE + _reg))

Definition at line 56 of file adc.c.

◆ rHTR

#define rHTR   REG(STM32_ADC_HTR_OFFSET)

Definition at line 67 of file adc.c.

◆ rJDR1

#define rJDR1   REG(STM32_ADC_JDR1_OFFSET)

Definition at line 73 of file adc.c.

◆ rJDR2

#define rJDR2   REG(STM32_ADC_JDR2_OFFSET)

Definition at line 74 of file adc.c.

◆ rJDR3

#define rJDR3   REG(STM32_ADC_JDR3_OFFSET)

Definition at line 75 of file adc.c.

◆ rJDR4

#define rJDR4   REG(STM32_ADC_JDR4_OFFSET)

Definition at line 76 of file adc.c.

◆ rJOFR1

#define rJOFR1   REG(STM32_ADC_JOFR1_OFFSET)

Definition at line 63 of file adc.c.

◆ rJOFR2

#define rJOFR2   REG(STM32_ADC_JOFR2_OFFSET)

Definition at line 64 of file adc.c.

◆ rJOFR3

#define rJOFR3   REG(STM32_ADC_JOFR3_OFFSET)

Definition at line 65 of file adc.c.

◆ rJOFR4

#define rJOFR4   REG(STM32_ADC_JOFR4_OFFSET)

Definition at line 66 of file adc.c.

◆ rJSQR

#define rJSQR   REG(STM32_ADC_JSQR_OFFSET)

Definition at line 72 of file adc.c.

◆ rLTR

#define rLTR   REG(STM32_ADC_LTR_OFFSET)

Definition at line 68 of file adc.c.

◆ rSMPR1

#define rSMPR1   REG(STM32_ADC_SMPR1_OFFSET)

Definition at line 61 of file adc.c.

Referenced by adc_init().

◆ rSMPR2

#define rSMPR2   REG(STM32_ADC_SMPR2_OFFSET)

Definition at line 62 of file adc.c.

Referenced by adc_init().

◆ rSQR1

#define rSQR1   REG(STM32_ADC_SQR1_OFFSET)

Definition at line 69 of file adc.c.

Referenced by adc_init().

◆ rSQR2

#define rSQR2   REG(STM32_ADC_SQR2_OFFSET)

Definition at line 70 of file adc.c.

Referenced by adc_init().

◆ rSQR3

#define rSQR3   REG(STM32_ADC_SQR3_OFFSET)

Definition at line 71 of file adc.c.

Referenced by adc_init(), and adc_measure().

◆ rSR

#define rSR   REG(STM32_ADC_SR_OFFSET)

Definition at line 58 of file adc.c.

Referenced by adc_measure().

Function Documentation

◆ adc_init()

int adc_init ( void  )

Sensors/misc inputs.

Definition at line 82 of file adc.c.

References PC_ELAPSED, perf_alloc, rCR2, rSMPR1, rSMPR2, rSQR1, rSQR2, and rSQR3.

Referenced by user_start().

Here is the caller graph for this function:

◆ adc_measure()

uint16_t adc_measure ( unsigned  channel)

Definition at line 137 of file adc.c.

References hrt_absolute_time(), hrt_abstime, hrt_elapsed_time(), perf_begin(), perf_end(), rCR2, rDR, rSQR3, and rSR.

Referenced by controls_tick(), and registers_get().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ adc_perf

perf_counter_t adc_perf

Definition at line 79 of file adc.c.