nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Types | Public Member Functions | Static Public Attributes
nrfcxx::gpio::instr_psel< PSEL > Class Template Reference

Instrumentation through toggling GPIOs. More...

#include <nrfcxx/gpio.hpp>

Public Types

using this_type = instr_psel< PSEL >
 

Public Member Functions

 instr_psel (const instr_psel &)=delete
 
instr_pseloperator= (const instr_psel &)=delete
 
 instr_psel (instr_psel &&)=delete
 
instr_pseloperator= (instr_psel &&)=delete
 
void enable (bool set=false) const
 Enable the instrumentation functionality. More...
 
void disable () const
 Disable the instrumentation functionality. More...
 
void assert () const
 Set the corresponding GPIO to logic 1.
 
void deassert () const
 Set the corresponding GPIO to logic 0.
 
void set (bool asserted) const
 Set the corresponding GPIO to a specific state. More...
 
void toggle () const
 Invert the state of the corresponding GPIO.
 

Static Public Attributes

constexpr static int global_psel = PSEL
 Index for the PSEL within all GPIO peripherals on the device.
 
constexpr static uint8_t psel = (PSEL - GPIO_Instance::begin_psel)
 Index for the PSEL within its GPIO instance.
 
constexpr static uint8_t gpio_instance = GPIO_Instance::peripheral.INSTANCE
 The GPIO instance ordinal.
 
constexpr static nrf5::GPIO_Type gpio = GPIO_Instance::peripheral
 The GPIO instance that provides access to #PSEL.
 
constexpr static bool psel_valid = (0 <= PSEL) && (psel < gpio.AUX)
 Valid GPIOs are non-negative values that are among the pins supported by the instance.
 
constexpr static uint32_t bit = (psel_valid ? (1U << psel) : 0)
 The bit mask corresponding to PSEL.
 

Detailed Description

template<int PSEL>
class nrfcxx::gpio::instr_psel< PSEL >

Instrumentation through toggling GPIOs.

This feature provides a relatively non-intrusive way to add compile-time optional instrumentation to a system. File-local instances of this class are defined, with #NRFCXX_GPIO_PSEL_SCOPEn or a non-disabled GPIO pin selection like #NRFCXX_GPIO_PSEL_SCOPE0. Prior to use the instances are enabled()d, then within the code the assert(), deassert(), set(), and toggle() methods may be invoked to signal context-specific state changes.

See also
make_scoped_instr()
Template Parameters
PSELthe GPIO pin number to use for the instrumentation. The value is a global ordinal with the peripheral instance represented by a multiple of 32 added to the GPIO pin within that instance. E.g. P1.23 is identified by PSEL (32 + 23). Use -1 to disable the instrumentation at compile-time. Attempts to reference a pin on a non-existent GPIO peripheral will fail at compile time with obscure messages about non-existent members.

Member Function Documentation

◆ disable()

template<int PSEL>
void nrfcxx::gpio::instr_psel< PSEL >::disable ( ) const
inline

Disable the instrumentation functionality.

Potentially useful for reducing power consumption or if the GPIO can be used for other purposes.

◆ enable()

template<int PSEL>
void nrfcxx::gpio::instr_psel< PSEL >::enable ( bool  set = false) const
inline

Enable the instrumentation functionality.

This must be invoked prior to using the object.

Parameters
setcontrol whether initial pin condition is high (true) or low (false).

◆ set()

template<int PSEL>
void nrfcxx::gpio::instr_psel< PSEL >::set ( bool  asserted) const
inline

Set the corresponding GPIO to a specific state.

Parameters
assertedtrue iff the GPIO should be set to logic 1.

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