nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Namespace holding board-specific configuration data. More...
Data Structures | |
class | iox_pin |
Extension of gpio::generic_pin using the SX1509B IO extender. More... | |
class | power_monitor |
Support for the power source interface. More... | |
Functions | |
int | initialize (bool enable_hfxt=false) |
Perform board-specific initialization. More... | |
static constexpr unsigned int | default_lfclk_src () |
Provide the LFCLKSRC value preferred by the board. More... | |
misc::sx1509b & | iox () noexcept |
Access the SX1509B instance. More... | |
unsigned int | battery_level_pptt (unsigned int batt_mV) |
Estimated battery level from measured voltage. More... | |
int | led_setup_battery_display (unsigned int batt_mV) |
Configure to display the battery level. More... | |
int | enable_led_driver (unsigned int iox_mask=0, bool linear=false) noexcept |
Enable the SX1509B LED driver functionality. More... | |
int | disable_led_driver () noexcept |
Enable the SX1509B LED driver functionality. More... | |
bool | external_antenna (int on) |
Query or control use of external antenna. More... | |
periph::QSPI & | mx25l32 () noexcept |
Access the QSPI instance for the on-board MX25L32. | |
Namespace holding board-specific configuration data.
Most material is put into this namespace through the board-specific <nrfcxx/board.hpp> header.
unsigned int nrfcxx::board::battery_level_pptt | ( | unsigned int | batt_mV | ) |
Estimated battery level from measured voltage.
|
staticconstexpr |
Provide the LFCLKSRC value preferred by the board.
If the board has an installed 32 KiHz crystal this will be the crystal source; otherwise it will be the internal RC oscillator for which you probably want nrfcxx::clock to calibrate for you.
CLOCK_LFCLKSRC_SRC_Xtal
or CLOCK_LFCLKSRC_SRC_RC
depending on board::has_lfxt.
|
noexcept |
Enable the SX1509B LED driver functionality.
This disables the 2 MHz Clock and the LED clock. All six LED pins are configured as normal outputs, set.
|
noexcept |
Enable the SX1509B LED driver functionality.
This configures a 2 MHz Clock divided to 256 MHz for the LED driver.
iox_mask | optional mask specifying a subset of LED pins to be configured for LED driver control. If zero is passed all LED pins will be configured. |
linear | optionally use linear intensity interpretation. Default false produces logarithmic intensity, which suits human vision better for a graded sequence. |
bool nrfcxx::board::external_antenna | ( | int | on | ) |
Query or control use of external antenna.
The Xenon has a SPDT switch that selects between the PCB antenna and the uFL socket. On power-up the PCB antenna is used. This function may be used to switch between the PCB and uFL antennas.
on | positive to use the external antenna, zero to use the PCB antenna, negative to query current source without changing it. |
int nrfcxx::board::initialize | ( | bool | enable_hfxt = false | ) |
Perform board-specific initialization.
This function should be invoked at the start of main() to ensure the basic functionality expected of all boards is available.
Operations performed by the default implementation include:
enable_hfxt
. This ensures the clock::uptime infrastructure is present.
|
noexcept |
Access the SX1509B instance.
Certain assumptions are made about how the pins on this device will be used. All pins are configured in board::initialize() to the reference implementation defaults. LEDs function as expected, but do not support the SX1509B LED driver functionality.
Frequency information in the Clock and Misc registers is assumed to be under the complete control of enable_led_driver() and disable_led_driver().
int nrfcxx::board::led_setup_battery_display | ( | unsigned int | batt_mV | ) |
Configure to display the battery level.
This configures the lightwell red or green LEDs to display an estimate of battery level:
The configuration assumes the LED driver is enables, and sets the duration of the display is roughly 1 s. The positive return value is the bit mask, which should be used as:
rc = board::led_setup_battery_display(batt_mV); if (0 <= rc) { board::iox().output_sct(0, rc); // enable the LED // wait long enough for the driver to start board::iox().output_sct(rc, 0); // clear the LED }