nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Go to the documentation of this file. 7 #ifndef NRFCXX_PERIPH_HPP 8 #define NRFCXX_PERIPH_HPP 12 #include <pabigot/container.hpp> 20 #ifndef NRFCXX_PERIPH_UART0_RXB_SIZE 23 #define NRFCXX_PERIPH_UART0_RXB_SIZE 8 26 #ifndef NRFCXX_PERIPH_UART0_TXB_SIZE 29 #define NRFCXX_PERIPH_UART0_TXB_SIZE 32 46 using fifo_type = pabigot::container::rr_adaptor<uint8_t>;
90 void enable (uint32_t cfg_baudrate = UART_BAUDRATE_BAUDRATE_Baud115200,
101 bool enabled (
bool live =
false)
const;
209 void set_enabled_bi_ (
bool on,
210 bool from_autoenable);
212 const nrf5::UART_Type& uart_;
215 statistics_type statistics_{};
217 uint8_t
volatile flags_ = 0;
218 int8_t
const rxd_pin_;
219 int8_t
const txd_pin_;
220 int8_t
const cts_pin_;
221 int8_t
const rts_pin_;
262 return rtc_->COUNTER;
312 timer_->TASKS_CAPTURE[ccidx] = 1;
318 return timer_->CC[ccidx];
342 unsigned int bitmode)
346 return ((TIMER_BITMODE_BITMODE_24Bit > bitmode)
382 unsigned int bitmode = TIMER_BITMODE_BITMODE_16Bit,
383 bool use_constlat =
true);
397 timer_->TASKS_START = 1;
403 timer_->TASKS_CLEAR = 1;
409 timer_->TASKS_STOP = 1;
415 timer_->TASKS_SHUTDOWN = 1;
444 unsigned int counter (
unsigned int ccidx = 0)
const 454 unsigned int b)
const 456 return mask_ & (b - a);
487 unsigned int ccidx) :
571 #ifndef NRFCXX_PERIPH_RNG_BUFFER_SIZE 574 #define NRFCXX_PERIPH_RNG_BUFFER_SIZE 8 596 static void*
fill (
void* dest,
605 template <
typename T,
606 typename = std::enable_if<std::is_integral<T>::value>>
611 uint8_t u8[
sizeof(T)];
613 fill(u.u8,
sizeof(u.u8));
643 using registry_type = uint8_t;
833 instance_->listener_ =
nullptr;
866 using chain_type = pabigot::container::forward_chain<sense_listener, ref_next>;
934 chain_type::pointer_type
next_ = chain_type::unlinked_ptr();
977 unsigned int polarity = GPIOTE_CONFIG_POLARITY_Toggle)
979 nrf5::GPIOTE->CONFIG[
channel] = (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos)
980 | (GPIOTE_CONFIG_PSEL_Msk & (psel << GPIOTE_CONFIG_PSEL_Pos))
981 | (GPIOTE_CONFIG_POLARITY_Msk & (polarity << GPIOTE_CONFIG_POLARITY_Pos));
997 unsigned int polarity = GPIOTE_CONFIG_POLARITY_Toggle)
999 nrf5::GPIOTE->CONFIG[
channel] = (GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos)
1000 | (GPIOTE_CONFIG_PSEL_Msk & (psel << GPIOTE_CONFIG_PSEL_Pos))
1001 | (GPIOTE_CONFIG_POLARITY_Msk & (polarity << GPIOTE_CONFIG_POLARITY_Pos));
1012 nrf5::GPIOTE->CONFIG[
channel] = 0;
1049 nrf5::GPIOTE->EVENTS_IN[
channel] = 0;
1050 nrf5::GPIOTE->INTENSET = (GPIOTE_INTENSET_IN0_Enabled << (GPIOTE_INTENSET_IN0_Pos +
channel));
1063 nrf5::GPIOTE->INTENCLR = (GPIOTE_INTENCLR_IN0_Clear << (GPIOTE_INTENCLR_IN0_Pos +
channel));
1131 nrf5::GPIOTE->INTENCLR = (GPIOTE_INTENCLR_PORT_Clear << GPIOTE_INTENCLR_PORT_Pos);
1158 constexpr
GPIOTE (uint8_t channel_) :
1163 void config_disabled_bi_ ()
1165 auto listener = listener_;
1167 listener->disable_bi_();
1171 event_listener *
volatile listener_;
1173 static sense_listener::chain_type sense_chain_;
1175 static registry_type in_use_;
1226 return configure_(ppidx, eep, tep);
1248 static uint32_t CHENSET_ (uint32_t v)
1250 nrf5::PPI->CHENSET = v;
1254 static uint32_t CHENCLR_ (uint32_t v)
1256 nrf5::PPI->CHENCLR = v;
1260 static uint32_t CHEN_ ()
1262 return nrf5::PPI->CHEN;
1265 static uint32_t configure_ (
int ppidx,
1269 nrf5::PPI->CH[ppidx].EEP = reinterpret_cast<uintptr_t>(&eep);
1270 nrf5::PPI->CH[ppidx].TEP = reinterpret_cast<uintptr_t>(&tep);
1304 if (gpiote_ && (0 > ppi_idx_)) {
1307 }
else if ((!gpiote_) && (0 <= ppi_idx_)) {
1323 if (0 <= ppi_idx_) {
1332 operator bool ()
const 1441 return (0 <= rc) ? 0 : (static_cast<unsigned int>(-rc) - 1);
1451 return ec ? -(1 + ec) : 0;
1467 template <
typename PERIPH>
1470 using ssize_type =
typename PERIPH::ssize_type;
1486 operator bool()
const 1488 return (0 <= result_);
1507 if (!periph.enabled()) {
1508 result_ = periph.enable();
1516 ssize_type result_ = 0;
1543 return ((TWI_ENABLE_ENABLE_Enabled << TWI_ENABLE_ENABLE_Pos)
1544 == (TWI_ENABLE_ENABLE_Msk & twi_->ENABLE));
1594 unsigned int timeout_us);
1610 set_enabled_(
false);
1660 const uint8_t* sbuf,
1667 rv =
write(addr, sbuf, scount);
1670 rv =
read(addr, dbuf, dcount);
1770 return ((SPI_ENABLE_ENABLE_Enabled << SPI_ENABLE_ENABLE_Pos)
1771 == (SPI_ENABLE_ENABLE_Msk & spi_->ENABLE));
1838 unsigned int multiplier = 125000;
1839 uint32_t rv = SPI_FREQUENCY_FREQUENCY_K125;
1842 if ((multiplier > freq_Hz)
1843 || (SPI_FREQUENCY_FREQUENCY_M8 == rv)) {
1861 bool lsb_first =
false)
1864 return ((lsb_first?1:0) << SPI_CONFIG_ORDER_Pos)
1865 | ((mode & 3) << SPI_CONFIG_CPHA_Pos);
1876 return set_enabled_(
true);
1882 set_enabled_(
false);
1916 uint8_t tx_dummy = 0);
1936 uint32_t frequency = 0;
1937 uint32_t config = 0;
1938 int8_t psel_sck = -1;
1939 int8_t psel_mosi = -1;
1940 int8_t psel_miso = -1;
1997 #elif (NRF52832 - 0) || (NRF52840 - 0) 2063 return static_cast<uint8_t>(state_);
2070 static int claim_bi_ (
ADCClient* client);
2073 static int release_bi_ (
ADCClient* client);
2076 static int try_calibrate_bi_ (
ADCClient* client,
2080 static int try_sample_bi_ (
ADCClient* client,
2091 static void complete_notify_bi_ (
bool calibrating);
2161 pointer_type& operator() (
ADCClient& cl) noexcept
2167 using queue_type = pabigot::container::forward_chain<ADCClient, ref_next>;
2168 static queue_type queue_;
2170 queue_type::pointer_type next_ = queue_type::unlinked_ptr();
2203 return ADC::claim_bi_(
this);
2212 return ADC::release_bi_(
this);
2235 return ADC::try_calibrate_bi_(
this, notify);
2359 return ADC::try_sample_bi_(
this, notify);
2362 static void process_queue_bi_ ();
2363 void complete_queue_bi_ ();
2418 #if (NRF52840 - 0) || (NRFCXX_DOXYGEN - 0) 2479 return (16U * dur_us + 255U) / 256U;
2536 QSPI& operator= (
const QSPI&) =
delete;
2560 return configuration_;
2568 return (QSPI_STATUS_SREG_Msk & nrf5::QSPI->STATUS) >> QSPI_STATUS_SREG_Pos;
2586 return (((QSPI_STATUS_READY_READY << QSPI_STATUS_READY_Pos)
2587 | (QSPI_STATUS_DPM_Disabled << QSPI_STATUS_DPM_Pos))
2588 == ((QSPI_STATUS_READY_Msk | QSPI_STATUS_DPM_Msk)
2589 & nrf5::QSPI->STATUS));
2623 return (QSPI_STATUS_DPM_Msk & nrf5::QSPI->STATUS);
2632 return (QSPI_STATUS_READY_Msk & nrf5::QSPI->STATUS);
2682 static constexpr
auto ERASE_4_KB = static_cast<uint8_t>(QSPI_ERASE_LEN_LEN_4KB) << QSPI_ERASE_LEN_LEN_Pos;
2688 static constexpr
auto ERASE_64_KB = static_cast<uint8_t>(QSPI_ERASE_LEN_LEN_64KB) << QSPI_ERASE_LEN_LEN_Pos;
2694 static constexpr
auto ERASE_CHIP = static_cast<uint8_t>(QSPI_ERASE_LEN_LEN_All) << QSPI_ERASE_LEN_LEN_Pos;
2714 int erase (uint8_t type,
2743 return this == owner_;
2789 static QSPI* owner_;
2791 const configuration_type& configuration_;
2792 unsigned int jedec_id_ = 0;
2793 bool activated_ =
false;
ADC is being calibrated via ADCClient::calibrate()
mutex_irq< GPIOTE_IRQn > mutex_type
An RAII type for mutex access to state that must be protected from GPIOTE interrupts.
Definition: periph.hpp:741
virtual int nrf51_next_bi_(size_t ci)
Function used to reconfigure ADC for next sample within the collection.
Definition: periph.hpp:2412
static constexpr auto ERASE_CHIP
Flag value denoting intent to erase the entire chip.
Definition: periph.hpp:2694
Object used to manage event callbacks.
Definition: periph.hpp:766
int queue(const notifier_type ¬ify, const queued_callback_type &qnotify={}, bool calibrate=false)
Queue an operation to be initiated as soon as the ADC becomes available.
int erase(uint8_t type, offset_type addr=-1)
Initiate an erase of a single flash storage item.
int calibrate(const notifier_type ¬ify={})
Calibrate the ADC.
Definition: periph.hpp:2232
event_set & events()
Reference the UART events.
std::function< void(GPIOTE &instance)> event_callback_bi
Signature for a event callback.
Definition: periph.hpp:668
uint32_t addrconf
The value for the ADDRCONF register.
Definition: periph.hpp:2501
ADC is in the process of stopping in the final stages of ADCClient::calibrate() or ADCClient::sample(...
constexpr static error_type error_decoded(ssize_type rc)
Extract an encoded error value from an API return value.
Definition: periph.hpp:1439
static GPIOTE * allocate()
Allocate a GPIOTE instance.
nrf5::series::ADC_Variant peripheral
The underlying variant traits class.
Definition: periph.hpp:1991
task_reference_type TASKS_OUT()
Reference the channel-specific TASKS_OUT register.
void disable()
Disable the SPI peripheral.
Definition: periph.hpp:1880
statistics_type statistics() const
Get a snapshot of the UART statistics.
bool autoenable(int on)
Query or control whether the UART self-enables for output.
const nrf5::TIMER_Type & peripheral() const
Reference the nRF5 TIMER peripheral instance used by the abstraction.
Definition: periph.hpp:553
unsigned int captured_(unsigned int ccidx) const
Return the captured value in CC ccidx (unvalidated).
Definition: periph.hpp:316
constexpr static size_t CHANNEL_COUNT
The number of GPIOTE channels available.
Definition: periph.hpp:655
unsigned int ccidx_
Validated capture/compare index used for timestamp operations.
Definition: periph.hpp:479
Constants and function specific to the nRF51 ADC peripheral.
Definition: impl.hpp:19
int8_t psel_io[4]
Pin selectors for IO0 through IO3.
Definition: periph.hpp:2507
Bit set in flags_ when the client is queued to invoke calibrate().
Definition: periph.hpp:2148
unsigned int flags_type
Type for client-specific flags.
Definition: periph.hpp:2127
static int request()
Allocate a PPI channel for application use.
ADC is in the process of starting via ADCClient::sample()
int ssize_type
The type used for transfer sizes or errors (signed)
Definition: periph.hpp:50
ssize_type enable()
Enable the SPI peripheral.
Definition: periph.hpp:1874
int ssize_type
The type used for transfer sizes (non-negative) or errors (negative).
Definition: periph.hpp:1380
static bool busy()
Return true iff the ADC has an in-progress conversion.
Definition: impl.hpp:108
static constexpr unsigned int convert_us_dpmdur(unsigned int dur_us)
Convert a duration expressed in microseconds to the units of the DPMDUR register.
Definition: periph.hpp:2477
pabigot::container::rr_adaptor< uint8_t > fifo_type
The type used for transmission and reception buffers.
Definition: periph.hpp:46
Definition: periph.hpp:1934
int8_t psel_csn
Pin selector for CSn.
Definition: periph.hpp:2513
static QSPI * owner()
Get a pointer to the instance that owns the QSPI peripheral.
Definition: periph.hpp:2729
std::function< void(const sense_status_type *sp)> sense_callback_bi
Signature for a sense callback.
Definition: periph.hpp:729
constexpr static unsigned int ERR_CLEAR
Bit set in an error code when the TWI bus could not be cleared.
Definition: periph.hpp:1414
virtual void sample_teardown()
Reverse the effects of sample_setup_().
Definition: periph.hpp:2271
static void irq_handler(void)
Implementation for GPIOTE_IRQHandler required by this module.
ssize_type bus_configure(int psel_sck, int psel_mosi, int psel_miso, uint32_t frequency, uint32_t config)
Configure the SPI bus.
unsigned int rx_break_errors
The number of break errors detected.
Definition: periph.hpp:66
unsigned int size_type
The type used for transfer sizes (unsigned)
Definition: periph.hpp:1753
void reset()
Capture the current time.
Definition: periph.hpp:501
constexpr static unsigned int ERR_ANACK
NRF_TWI_Type::ERRORSRC bit indicating NACK received during address transmission.
Definition: periph.hpp:1402
instr_psel_gpiote(unsigned int psel, PPI::event_reference_type eep, bool enable=true)
Construct the instance.
Definition: periph.hpp:1296
ssize_type write_read(unsigned int addr, const uint8_t *sbuf, size_type scount, uint8_t *dbuf, size_type dcount)
Write to then read from an I2C device.
Definition: periph.hpp:1659
unsigned int captured() const
Return the captured counter.
Definition: periph.hpp:495
flags_type flags_
Flags for use by the core infrastructure and client specifications.
Definition: periph.hpp:2354
constexpr static unsigned int cc_mask
Mask to create a valid CC index from a non-negative integer.
Definition: periph.hpp:334
unsigned int rx_frame_errors
The number of frame errors detected.
Definition: periph.hpp:69
sense_listener(sense_callback_bi callback_bi)
Construct a sense listener.
Definition: periph.hpp:878
virtual int configure_bi_()
Method to be invoked to configure the ADC for the next collection.
Definition: periph.hpp:2377
constexpr static unsigned int ERR_CHECKSUM
Bit set in an error code to indicate a checksum error.
Definition: periph.hpp:1425
Wrapper around the nRF51 SPI peripheral.
Definition: periph.hpp:1748
const nrf5::UART_Type & peripheral() const
Reference the nRF5 UART peripheral instance used by the abstraction.
Definition: periph.hpp:186
Object used to manage sense callbacks.
Definition: periph.hpp:854
error_type clear_error_()
Invoked when a read or write operation detects a bus error.
Resource allocation manager for PPI module.
Definition: periph.hpp:1184
int8_t psel_scl
Pin selector for SCL, or -1 if not known.
Definition: periph.hpp:1702
unsigned int size_type
The type used for transfer sizes (unsigned)
Definition: periph.hpp:1374
int sample(const notifier_type ¬ify={})
Trigger a client-specific collection.
Definition: periph.hpp:2286
unsigned int jedec_id() const
Return the JEDEC ID cached on the first activation of the instance.
Definition: periph.hpp:2723
int sample_bi_(const notifier_type ¬ify)
Implements sample() given that the mutex is already held.
Definition: periph.hpp:2357
int deactivate()
Deactivate the QSPI peripheral.
virtual void complete_bi_()
Method invoked when the collection completes.
Definition: periph.hpp:2394
constexpr static uint32_t counter_mask
Mask for the 24-bit RTC counter.
Definition: periph.hpp:241
unsigned int delta(unsigned int counter) const
Return counts between captured counter and counter.
Definition: periph.hpp:514
Class supporting GPIO task and event operations.
Definition: periph.hpp:639
bool is_powerdown() const
Returns the peripheral flag value indicating whether the device is in deep power-down mode.
Definition: periph.hpp:2621
unsigned int frequency_Hz() const
Get the configured clock frequency in Hz.
int ssize_type
The type used for transfer sizes (non-negative) or errors (negative).
Definition: periph.hpp:1759
static TWI & instance(int idx)
Reference the abstraction instance for a specific peripheral instance.
nvic_BlockIRQ as a template type.
Definition: core.hpp:497
chain_type::pointer_type next_
Pointer used to link this listener into the enabled sense listeners.
Definition: periph.hpp:934
constexpr static unsigned int ERR_TIMEOUT
Bit set in an error code when the TWI bus transaction timed out.
Definition: periph.hpp:1410
static constexpr uint8_t SR_SWRD
Bit flag for status register write protect bit.
Definition: periph.hpp:2463
void deconfigure()
Deconfigure the TIMER.
Definition: periph.hpp:386
constexpr static unsigned int ERR_UNKNOWN
Bit set in an error code to indicate an undescribable error.
Definition: periph.hpp:1429
task_reference_type TASKS_SET()
Reference the channel-specific TASKS_SET register.
Wrapper around the nRF51 TWI peripheral.
Definition: periph.hpp:1528
static RTC & instance(int idx)
Reference the abstraction instance for a specific peripheral instance.
void start()
Invoke TASKS_START.
Definition: periph.hpp:395
unsigned int size_type
The type used for transfer sizes (unsigned)
Definition: periph.hpp:48
void capture_(unsigned int ccidx) const
Capture the current counter into CC ccidx (unvalidated).
Definition: periph.hpp:310
static uint32_t configure(int ppidx, event_reference_type eep, task_reference_type tep)
Configure a PPI channel.
Definition: periph.hpp:1222
uint8_t enter_dpmdur
The value of the DPMDUR.ENTER field.
Definition: periph.hpp:2518
ADC is collecting a sample via ADCClient::sample()
void config_task(unsigned int psel, unsigned int polarity=GPIOTE_CONFIG_POLARITY_Toggle)
Configure the instance to change pin level.
Definition: periph.hpp:996
uint8_t exit_dpmdur
The value of the DPMDUR.EXIT field.
Definition: periph.hpp:2523
static uint32_t CHENCLR(uint32_t v)
Abstraction to disable a set of PPI channels.
Definition: periph.hpp:1236
void disable_event()
Disable event callbacks for this instance.
Definition: periph.hpp:1061
static constexpr uint32_t config_from_mode(uint8_t mode, bool lsb_first=false)
Determine the value for the CONFIG register.
Definition: periph.hpp:1860
Capture information about an nRF5 peripheral instance.
Definition: core.hpp:165
constexpr static bool bitmode_supported(const nrf5::TIMER_Type &timer, unsigned int bitmode)
Verify a specific timer can support the requested bitmode.
Definition: periph.hpp:341
uint8_t counter_state
Pin state and count of confirmed changes.
Definition: periph.hpp:686
unsigned int delta() const
Return counts since the captured value.
Definition: periph.hpp:507
void disable()
Dissociate this listener from any instance.
Definition: periph.hpp:807
static void disable_sense()
Stop monitoring sense events.
Definition: periph.hpp:1129
static UART UART0
A reference to a board-specific standard UART instance.
Definition: periph.hpp:171
void disable()
Disable the link from the event to the GPIO.
Definition: periph.hpp:1348
Wrapper around the nRF5 TIMER peripheral.
Definition: periph.hpp:301
~event_listener()
Disable listener on destruction.
Definition: periph.hpp:788
bool is_ready() const
Returns the isolated peripheral flag value indicating whether the device is ready to receive new task...
Definition: periph.hpp:2630
constexpr static unsigned int ERR_DNACK
NRF_TWI_Type::ERRORSRC bit indicating NACK received during data transmission.
Definition: periph.hpp:1406
void release()
Release the instance.
__O uint32_t & event_reference_type
Type for a reference to a peripheral event.
Definition: periph.hpp:647
void disable()
Disable the TWI peripheral.
Definition: periph.hpp:1608
void enable_event()
Enable event callbacks for this instance.
Definition: periph.hpp:1047
const unsigned int ccr_count() const
The number of capture/compare registers on the device.
Definition: periph.hpp:559
Wrapper around the nRF52 QSPI peripheral.
Definition: periph.hpp:2429
ssize_t write(offset_type addr, const void *src, size_type count)
Write data to the device at a specified address.
unsigned int counter(unsigned int ccidx=0) const
Read the current timer value.
Definition: periph.hpp:444
event_callback_bi const callback_bi
The callback invoked from the GPIOTE IRQ handler.
Definition: periph.hpp:824
error_type clear_bus_()
Reset the I2C bus to idle state if a secondary device is holding it active.
const uint8_t AUX
Auxiliary information relevant to the specific peripheral and type.
Definition: core.hpp:245
uint32_t xipoffset
The value for the XIPOFFSET register.
Definition: periph.hpp:2504
const nrf5::RTC_Type & peripheral() const
Reference the nRF5 RTC peripheral instance used by the abstraction.
Definition: periph.hpp:277
Base for subclass use of flags_.
Definition: periph.hpp:2154
static constexpr uint8_t SR_BP0
Bit flag for status register protected area block bit 0.
Definition: periph.hpp:2450
sense_callback_bi const callback_bi
The callback invoked from the GPIOTE IRQ handler.
Definition: periph.hpp:928
static constexpr event_set::event_type EVT_TXDONE
Event set in events() when transmission completes.
Definition: periph.hpp:154
unsigned int error_type
The type used to encode TWI peripheral errors.
Definition: periph.hpp:1394
void disable()
Disable the UART.
static uint32_t CHENSET(uint32_t v)
Abstraction to enable a set of PPI channels.
Definition: periph.hpp:1230
uint8_t latest_sr() const
Return the most recent cached flash device status register value.
Definition: periph.hpp:2566
static constexpr uint8_t SR_BP3
Bit flag for status register protected area block bit 3.
Definition: periph.hpp:2456
unsigned int tx_count
The number of octets transmitted.
Definition: periph.hpp:56
bool is_write_complete(int sr) const
Test a status register value for completion of all write activities.
Definition: periph.hpp:2605
constexpr static unsigned int counter_delta(uint32_t a, uint32_t b)
Calculate the tick-count between two counter values.
Definition: periph.hpp:251
static constexpr auto & INSTANCE
Reference to the variant-specific instance characteristics.
Definition: periph.hpp:1994
Base class for a client of ADC.
Definition: periph.hpp:2123
void capture(unsigned int ccidx) const
Capture the current counter using CC ccidx.
Definition: periph.hpp:425
static constexpr uint8_t SR_BP1
Bit flag for status register protected area block bit 1.
Definition: periph.hpp:2452
uint32_t ifconfig[2]
The values for the IFCONFIG0 and IFCONFIG1 registers.
Definition: periph.hpp:2498
const nrf5::SPI_Type & peripheral() const
Reference the underlying peripheral.
Definition: periph.hpp:1762
static constexpr uint8_t SR_WIP
Bit flag for status register write-in-progress bit.
Definition: periph.hpp:2446
unsigned int rx_overrun_errors
The number of overrun errors detected.
Definition: periph.hpp:75
bool is_owner() const
Test whether this instance has control of the QSPI peripheral.
Definition: periph.hpp:2741
void shutdown()
Invoke TASKS_SHUTDOWN.
Definition: periph.hpp:413
int ssize_type
Signed type holding transfer sizes or error codes.
Definition: periph.hpp:2443
Definition: periph.hpp:1691
Structure used to convey information about pin levels to sense_listener callbacks.
Definition: periph.hpp:672
constexpr static uint32_t counter_modulus
Modulus for the 24-bit RTC counter.
Definition: periph.hpp:238
static uint8_t state()
Return the current ADC state.
Definition: periph.hpp:2061
Wrapper around the nRF51 RNG peripheral.
Definition: periph.hpp:583
unsigned int rx_count
The number of octets received.
Definition: periph.hpp:59
Mask to isolate queue state flags().
Definition: periph.hpp:2151
__O uint32_t & event_reference_type
Type for a reference to a peripheral event.
Definition: periph.hpp:1188
void enable(uint32_t cfg_baudrate=UART_BAUDRATE_BAUDRATE_Baud115200, bool hwfc=false)
Enable the UART.
int release()
Release the QSPI peripheral if held by this instance.
const TIMER & timer_
Reference to timer used for timestamp operations.
Definition: periph.hpp:477
unsigned int size_type
Unsigned type holding size of transfers.
Definition: periph.hpp:2440
unsigned int delta(unsigned int a, unsigned int b) const
Calculate the count distance from a to b.
Definition: periph.hpp:453
ssize_type read(unsigned int addr, uint8_t *buf, size_type count)
Read a block of data from an I2C device.
static SPI & instance(int idx)
Reference the abstraction instance for a specific peripheral instance.
static constexpr auto ERASE_64_KB
Flag value denoting intent to erase a single 64 KiBy block.
Definition: periph.hpp:2688
bool drive_high
Set to use high drive for the control and IO pins.
Definition: periph.hpp:2528
void enable()
Enable the link from the event to the GPIO.
Definition: periph.hpp:1338
const uint8_t channel
The channel index for this GPIOTE instance.
Definition: periph.hpp:658
void stop()
Invoke TASKS_STOP.
Definition: periph.hpp:407
RAII instance that ensures the an instance is enabled within a scope.
Definition: periph.hpp:1468
ssize_type result() const
The result of attempting to enable the peripheral.
Definition: periph.hpp:1496
const configuration_type & configuration() const
Reference the QSPI configuration provided on construction.
Definition: periph.hpp:2558
static T generate()
Generate a random value of the specified type.
Definition: periph.hpp:607
int configure(unsigned int freq_Hz, unsigned int bitmode=TIMER_BITMODE_BITMODE_16Bit, bool use_constlat=true)
Configure the TIMER to run as a timer.
int read_sr() const
Read the current device status register value.
static constexpr event_set::event_type EVT_RXAVAIL
Event set in events() when data is received.
Definition: periph.hpp:144
constexpr static unsigned int ERR_INVALID
Bit set in an error code to indicate that the bus was not properly configured or a parameter was inva...
Definition: periph.hpp:1418
unsigned int timeout
Maximum duration to wait for a single-byte transaction to complete, in us.
Definition: periph.hpp:1695
Primary header for nrfcxx implementation dependencies.
std::function< void()> notifier_type
Type used to hold a notifier.
Definition: core.hpp:514
int8_t ppidx
PPI index used for PAN 36 workaround, if enabled.
Definition: periph.hpp:1708
unsigned int offset_type
Unsigned type specifying flash memory addresses.
Definition: periph.hpp:2437
bool enabled(bool live=false) const
Indicate whether UART is enabled.
constexpr static ssize_type error_encoded(error_type ec)
Pack an error value into a negative return value.
Definition: periph.hpp:1449
ssize_t read(offset_type addr, void *dest, size_type count)
Read data from the device at a specified address.
ssize_type enable()
Enable the TWI peripheral.
Definition: periph.hpp:1602
unsigned int delta_reset()
Return counts since the captured time and reset captured counter to current counter.
Definition: periph.hpp:521
unsigned int captured(unsigned int ccidx) const
Return the captured counter in CC ccidx.
Definition: periph.hpp:431
unsigned int aggregate_state(unsigned int previous=0) const
Update an external aggregate state with new material.
Definition: periph.hpp:696
event_reference_type EVENTS_IN()
Reference the channel-specific EVENTS_IN register.
void config_event(unsigned int psel, unsigned int polarity=GPIOTE_CONFIG_POLARITY_Toggle)
Configure the instance to monitor edge events.
Definition: periph.hpp:976
static constexpr event_set::event_type EVT_ERROR
Event set in events() when an error is detected.
Definition: periph.hpp:160
unsigned int rx_parity_errors
The number of parity errors detected.
Definition: periph.hpp:72
static void irq_handler()
Implementation for ADCSeriesVariant_IRQHandler required by this module.
task_reference_type TASKS_CLR()
Reference the channel-specific TASKS_CLR register.
event_listener(event_callback_bi callback_bi)
Construct an event listener.
Definition: periph.hpp:782
virtual int sample_setup()
Overridable function to set up for an ADC measurement.
Definition: periph.hpp:2263
flags_e
Defined values for flags.
Definition: periph.hpp:2142
bool enabled() const
Return true iff the device is enabled.
Definition: periph.hpp:1768
ssize_type write(unsigned int addr, const uint8_t *buf, size_type count)
Write a block of data to an I2C device.
unsigned int counter_(unsigned int ccidx) const
Capture and return the current counter using ccidx (unvalidated).
Definition: periph.hpp:322
ssize_type bus_configure(int psel_scl, int psel_sda, uint32_t frequency, unsigned int timeout_us)
Configure the TWI bus.
scoped_enabler scoped_enable() noexcept
Construct an RAII object that controls whether the instance is enabled.
Definition: periph.hpp:1791
int activate()
Activate the QSPI peripheral to interact with this device.
int8_t psel_sck
Pin selector for SCK.
Definition: periph.hpp:2510
timestamp_type timestamp(unsigned int ccidx=0) const
Create a timestamp instance using this timer.
Definition: periph.hpp:537
scoped_enabler scoped_enable() noexcept
Construct an RAII object that controls whether the instance is enabled.
Definition: periph.hpp:1563
static void enable_sense()
Enable sense callbacks.
unsigned int capture_
Captured counter value used for timestamp delta calculations.
Definition: periph.hpp:481
unsigned int rx_dropped
The number of received octets dropped due to lack of buffer space.
Definition: periph.hpp:63
static UART & instance()
Reference the abstraction instance for UART0.
void enable(GPIOTE &instance)
Associate this listener with a specific instance.
const nrf5::TWI_Type & peripheral() const
Reference the underlying peripheral.
Definition: periph.hpp:1535
constexpr static unsigned int minimum_timeout_us
The minimum allowed per-byte bus timeout, in microseconds.
Definition: periph.hpp:1532
unsigned int event_type
The type used to represent a (set of) event(s).
Definition: core.hpp:547
static uint32_t CHEN()
Abstraction to read the set of enabled PPI channels.
Definition: periph.hpp:1242
std::function< void(int rc)> queued_callback_type
Signature for application notification of completed queue operation.
Definition: periph.hpp:2138
bool is_qspi_available() const
Determine whether the QSPI peripheral is available for new commands.
Definition: periph.hpp:2584
int8_t psel
The global pin selector index, or a negative value to indicate the end of the sense-enabled pins.
Definition: periph.hpp:676
void irq_handler()
Implementation for UART#_IRQHandler required by this module.
static int group_request()
Allocate a PPI channel group for application use.
constexpr static unsigned int ERR_OVERRUN
NRF_TWI_Type::ERRORSRC bit indicating incomplete reception at start.
Definition: periph.hpp:1398
int claim()
Attempt to claim exclusive use of the ADC peripheral.
Definition: periph.hpp:2200
peripheral::mutex_type mutex_type
Mutex required to inhibit ADC interrupts.
Definition: periph.hpp:2178
void clear()
Invoke TASKS_CLEAR.
Definition: periph.hpp:401
Configuration parameters for QSPI peripheral.
Definition: periph.hpp:2487
virtual ~ADCClient()
Release the peripheral when the client is destructed.
Definition: periph.hpp:2192
int release()
Release the ADC peripheral.
Definition: periph.hpp:2209
int8_t psel_sda
Pin selector for SDA, or -1 if not known.
Definition: periph.hpp:1705
~sense_listener()
Destruct a sense listener.
Definition: periph.hpp:887
Class supporting GPIO instrumentation triggered by peripheral events.
Definition: periph.hpp:1284
static constexpr uint8_t SR_QE
Bit flag for status register quad-enabled bit.
Definition: periph.hpp:2458
Statistics on the UART operation.
Definition: periph.hpp:53
int claim()
Attempt to claim use of the QSPI peripheral.
Wrapper around the nRF51 UART peripheral.
Definition: periph.hpp:42
ADC is owned by a client but is not started.
Class supporting (high-resolution) timing.
Definition: periph.hpp:473
uint32_t frequency
Encoded value for FREQUENCY register, e.g.
Definition: periph.hpp:1699
uint32_t counter() const
Return the underlying 24-bit counter value.
Definition: periph.hpp:260
static constexpr event_set::event_type EVT_TXAVAIL
Event set in events() when there is space in the transmit buffer.
Definition: periph.hpp:147
Bit set in flags_ when the client is queued to invoke sample().
Definition: periph.hpp:2145
ssize_type read(uint8_t *dp, size_type count)
Read data from the UART.
static int release(int ppi)
Release a previously allocated PPI channel.
const unsigned int ccr_count() const
The number of capture/compare registers on the device.
Definition: periph.hpp:283
state_type
Genericized states of the ADC.
Definition: periph.hpp:2009
QSPI(const configuration_type &configuration)
Construct a new QSPI interface.
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17
static void synchronize_sense()
Process as though a PORT event had been received.
const uint8_t INSTANCE
The peripheral instance, for peripherals like TIMER that have multiple instances.
Definition: core.hpp:228
ssize_type tx_rx(const uint8_t *tx_data, size_type tx_len, size_type rx_len, uint8_t *rx_data, uint8_t tx_dummy=0)
Transmit and/or receive data over the SPI bus.
static TIMER & instance(int idx)
Reference the abstraction instance for a specific peripheral instance.
__IO uint32_t & task_reference_type
Type for a reference to a peripheral task.
Definition: periph.hpp:650
bool is_activated() const
Test whether this instance is already activated.
Definition: periph.hpp:2735
A record of events that occur asynchonously.
Definition: core.hpp:541
static constexpr uint32_t frequency_from_Hz(unsigned int freq_Hz)
Calculate the appropriate frequency assignment for a requested rate.
Definition: periph.hpp:1836
static constexpr auto ERASE_4_KB
Flag value denoting intent to erase a single 4 KiBy sector.
Definition: periph.hpp:2682
static void * fill(void *dest, size_t count)
Fill a block of memory with random bytes.
Wrapper around the nRF51 RTC peripheral.
Definition: periph.hpp:229
Abstracted support for error returns.
Definition: periph.hpp:1369
int queue(bool calibrate=false)
Overload when no notifications are required.
Definition: periph.hpp:2340
__IO uint32_t & task_reference_type
Type for a reference to a peripheral task.
Definition: periph.hpp:1191
void enable()
Enable event processing for this instance.
error_type reset_periph_()
Power cycle the peripheral and re-initialize it.
void config_disabled()
Deconfigure the instance.
Definition: periph.hpp:1010
static int group_release(int ppi)
Release a previously allocated PPI channel group.
static constexpr uint8_t SR_WEL
Bit flag for status register write-enable-latch bit.
Definition: periph.hpp:2448
ssize_type write(const uint8_t *sp, size_type count)
Write data to the UART.
bool enabled() const
Return true iff the device is enabled.
Definition: periph.hpp:1541
void disable()
Disable event processing for this instance.
static constexpr uint8_t SR_BP2
Bit flag for status register protected area block bit 2.
Definition: periph.hpp:2454
Wrapper around the ADC or SAADC peripheral.
Definition: periph.hpp:1987