Public Member Functions | Private Attributes | List of all members
AnalogPin Class Reference

A class to represent a single pin configured for analog input. More...

#include <analog_pin.h>

Public Member Functions

void init (AnalogDigitalConverter *adc, GPIO_TypeDef *basePort, uint16_t pin, uint8_t adc_channel)
 Initializes a pin to read analog values. More...
 
double read () const
 Get the last reading of the pin, in volts. More...
 
uint16_t read_raw () const
 Get the most recent reading of the pin, directly from the ADC. See AnalogDigitalConverter.read for the details on interpreting this value. More...
 

Private Attributes

AnalogDigitalConverteradc_
 
GPIO gpio_
 
uint8_t index_
 

Detailed Description

A class to represent a single pin configured for analog input.

This class manages the connection to the ADC, and does some of the math for reading. This class does not initialize the ADC.

Definition at line 44 of file analog_pin.h.

Member Function Documentation

void AnalogPin::init ( AnalogDigitalConverter adc,
GPIO_TypeDef basePort,
uint16_t  pin,
uint8_t  adc_channel 
)

Initializes a pin to read analog values.

This initialization includes configuring the GPIO, and adding a channel to the ADC. This does not configure the ADC. ADC configuration must happen before

Parameters
adcThe ADC this pin is to use
basePortThe GPIO definition for this pin to use
pinThe GPIO number for the pin
adc_channelThe ADC channel number for the pin, defined by the hardware

Definition at line 34 of file analog_pin.cpp.

double AnalogPin::read ( ) const

Get the last reading of the pin, in volts.

Returns
The most recent reading, in volts

Definition at line 41 of file analog_pin.cpp.

uint16_t AnalogPin::read_raw ( ) const

Get the most recent reading of the pin, directly from the ADC. See AnalogDigitalConverter.read for the details on interpreting this value.

Returns
The most recent raw reading

Definition at line 46 of file analog_pin.cpp.

Member Data Documentation

AnalogDigitalConverter* AnalogPin::adc_
private

Definition at line 71 of file analog_pin.h.

GPIO AnalogPin::gpio_
private

Definition at line 70 of file analog_pin.h.

uint8_t AnalogPin::index_
private

Definition at line 72 of file analog_pin.h.


The documentation for this class was generated from the following files:


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Fri Oct 9 2020 03:17:21