nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Go to the documentation of this file. 8 #ifndef NRFCXX_NRF51_IMPL_HPP 9 #define NRFCXX_NRF51_IMPL_HPP 12 #include <nrf51_bitfields.h> 23 static constexpr IRQn_Type IRQn = ADC_IRQn;
26 static constexpr
unsigned int VBG_mV = 1200;
90 unsigned int prescale,
92 unsigned int extrefsel = ADC_CONFIG_EXTREFSEL_None)
95 | (ADC_CONFIG_RES_Msk & (res << ADC_CONFIG_RES_Pos))
96 | (ADC_CONFIG_INPSEL_Msk & (prescale << ADC_CONFIG_INPSEL_Pos))
97 | (ADC_CONFIG_REFSEL_Msk & (refsel << ADC_CONFIG_REFSEL_Pos))
98 | ((((0 <= ain) && (7 >= ain))
99 ? (ADC_CONFIG_PSEL_AnalogInput0 << ain)
100 : ADC_CONFIG_PSEL_Disabled) << ADC_CONFIG_PSEL_Pos)
101 | (ADC_CONFIG_EXTREFSEL_Msk & (extrefsel << ADC_CONFIG_EXTREFSEL_Pos));
104 static constexpr uint32_t inten = 0
105 | (ADC_INTENSET_END_Set << ADC_INTENSET_END_Pos);
110 return nrf5::ADC->BUSY;
120 nrf5::ADC->TASKS_START = 1;
123 static void enable_bi ()
125 nrf5::ADC->EVENTS_END = 0;
126 nrf5::ADC->INTENSET = inten;
129 nrf5::ADC->ENABLE = 1;
132 static void disable_bi ()
134 nrf5::ADC->ENABLE = 0;
136 nrf5::ADC->INTENCLR = inten;
139 static int calibrate_bi ()
144 static int start_bi ()
148 nrf5::ADC->TASKS_START = 1;
152 static void stopped_bi ()
161 static uint16_t result_idx_;
164 using ADC_Variant = ADC_Peripheral;
static constexpr bool near_zero(uint16_t v_adc16)
Test whether a value appears to be indistinguishable from zero.
Definition: impl.hpp:47
Constants and function specific to the nRF51 ADC peripheral.
Definition: impl.hpp:19
static constexpr auto IRQ_PRIORITY_APP_HIGH
NVIC IRQ priority reserved for critical application interrupts.
Definition: impl.hpp:173
static bool busy()
Return true iff the ADC has an in-progress conversion.
Definition: impl.hpp:108
Material common to all ADC peripheral implementations.
Definition: impl.hpp:22
static void trigger()
Initiate an ADC sample with the current configuration.
Definition: impl.hpp:118
nvic_BlockIRQ as a template type.
Definition: core.hpp:497
static void nvic_ClearPendingIRQ(int irqn)
Wrapper around NVIC_ClearPending to work around issues with peripheral::IRQn.
Definition: core.hpp:412
static void nvic_EnableIRQ(int irqn)
Wrapper around NVIC_EnableIRQ to work around issues with peripheral::IRQn.
Definition: core.hpp:376
static constexpr uint16_t TOLERANCE_adc16
ADC offset error is documented +/- 2%, with a 1.5% error for VBG.
Definition: impl.hpp:35
static constexpr auto IRQ_PRIORITY_SD_HIGH
NVIC IRQ priority reserved for critical soft-device interrupts.
Definition: impl.hpp:170
static constexpr unsigned int VBG_mV
nRF51 reference voltage is 1.2 V.
Definition: impl.hpp:26
static constexpr unsigned int make_config(int ain, unsigned int res, unsigned int prescale, unsigned int refsel, unsigned int extrefsel=ADC_CONFIG_EXTREFSEL_None)
Helper to build up a ADC CONFIG.
Definition: impl.hpp:88
static constexpr auto IRQ_PRIORITY_SD_LOW
NVIC IRQ priority reserved for non-critical soft-device interrupts.
Definition: impl.hpp:176
static constexpr auto IRQ_PRIORITY_APP_LOW
NVIC IRQ priority reserved for non-critical application interrupts.
Definition: impl.hpp:179
static void nvic_DisableIRQ(int irqn)
Wrapper around NVIC_DisableIRQ to work around issues with peripheral::IRQn.
Definition: core.hpp:385
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17