nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Data Structures | Functions
nrfcxx::board Namespace Reference

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::sx1509biox () 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::QSPImx25l32 () noexcept
 Access the QSPI instance for the on-board MX25L32.
 

Detailed Description

Namespace holding board-specific configuration data.

Most material is put into this namespace through the board-specific <nrfcxx/board.hpp> header.

Function Documentation

◆ battery_level_pptt()

unsigned int nrfcxx::board::battery_level_pptt ( unsigned int  batt_mV)

Estimated battery level from measured voltage.

Note
This is meaningful only when the there is no external power source. When V_USB is non-zero the measured battery voltage is high even when the actual capacity is low, regardless of whether the battery is charging or not.

◆ default_lfclk_src()

static constexpr unsigned int nrfcxx::board::default_lfclk_src ( )
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.

Returns
either CLOCK_LFCLKSRC_SRC_Xtal or CLOCK_LFCLKSRC_SRC_RC depending on board::has_lfxt.

◆ disable_led_driver()

int nrfcxx::board::disable_led_driver ( )
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.

◆ enable_led_driver()

int nrfcxx::board::enable_led_driver ( unsigned int  iox_mask = 0,
bool  linear = false 
)
noexcept

Enable the SX1509B LED driver functionality.

This configures a 2 MHz Clock divided to 256 MHz for the LED driver.

Parameters
iox_maskoptional mask specifying a subset of LED pins to be configured for LED driver control. If zero is passed all LED pins will be configured.
linearoptionally use linear intensity interpretation. Default false produces logarithmic intensity, which suits human vision better for a graded sequence.

◆ external_antenna()

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.

Parameters
onpositive to use the external antenna, zero to use the PCB antenna, negative to query current source without changing it.
Returns
true if the external antenna is being used, false if the PCB antenna is being used.

◆ initialize()

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:

Returns
zero in almost all cases. If a negative value is returned some applications may be able to enter a failsafe mode.

◆ iox()

misc::sx1509b& nrfcxx::board::iox ( )
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().

Warning
This function must not be invoked before board::initialize().

◆ led_setup_battery_display()

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:

  • Levels at or above 50% display as green, with dimmest display at 50% and brightest at 100%.
  • Levels below 50% display as red, with dimmest display at 0% and brightest at 49.99%.

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
}