|
static constexpr int | instance_for_psel (int psel) |
| Determine the GPIO instance associated with a given pin selector. More...
|
|
template<typename INSTR_PSEL > |
instr_psel_scoped< INSTR_PSEL > | make_scoped_instr (const INSTR_PSEL &instance, bool start_set=true) |
| Create an RAII-style object that instruments a code block. More...
|
|
constexpr uint32_t | pin_config (unsigned int dir=GPIO_PIN_CNF_DIR_Input, unsigned int input=GPIO_PIN_CNF_INPUT_Disconnect, unsigned int pull=GPIO_PIN_CNF_PULL_Disabled, unsigned int drive=GPIO_PIN_CNF_DRIVE_S0S1, unsigned int sense=GPIO_PIN_CNF_SENSE_Disabled) |
| Helper to build up a GPIO PIN_CNF . More...
|
|
template<typename mutex_type = null_mutex> |
void | clear_sense (unsigned int psel) |
| Function to clear the SENSE field of a GPIO pin configuration. More...
|
|
unsigned int | update_sense_bi (unsigned int psel, bool assume_change=false) |
| Function to set the SENSE field of a GPIO pin configuration to detect a change in the input signal. More...
|
|
Abstractions and constants around GPIO capability.
template<typename INSTR_PSEL >
instr_psel_scoped<INSTR_PSEL> nrfcxx::gpio::make_scoped_instr |
( |
const INSTR_PSEL & |
instance, |
|
|
bool |
start_set = true |
|
) |
| |
Create an RAII-style object that instruments a code block.
Use this in cases where there's no need for cross-block instrumentation, especially in cases where there's no convenient code site where instrumentation instances can be enabled.
{
auto scope = nrfcxx::gpio::make_scoped_instr(scope1);
// region marked by scope1 high
}
- Template Parameters
-
INSTR_PSEL | the type of the instrumentation instance. Generally this will be inferred. |
- Parameters
-
start_set | whether the instrumentation signal should be set on construction (default true ) or left unset (false ). Note that the default here is not the same as in instr_psel::enable(). |
unsigned int nrfcxx::gpio::update_sense_bi |
( |
unsigned int |
psel, |
|
|
bool |
assume_change = false |
|
) |
| |
Function to set the SENSE field of a GPIO pin configuration to detect a change in the input signal.
This function reads the IN signal of a GPIO and configures its SENSE field to detect a change from that state. The function ensures that the IN signal state after pin configuration is complete matches the original state.
The as-configured state of the pin is specified in the low bit of the return value, while bits 1 and higher count the number of times the state changed during the configuration. For example, the value 3 indicates that the final observed state of the pin was set; on completion the GPIO was configured to emit a SENSE event on a falling edge (transition to clear), and that at least one state change occurred while setting the pin configuration.
The caller is responsible for determining what, if anything, should be recorded about state changes observed during configuration.
- Note
- This function must be invoked in an approriate mutex type context to ensure the pin configuration is not changed and DETECT events are not processed while the configuration operation is in progress. If not invoked within a mutex region periph::GPIOTE::mutex_type might be appropriate.
- Parameters
-
psel | the pin index for which sense is to be updated |
assume_change | if false and the sense matches the input signal the return value will indicate that no changes occurred. If true and the sense matches the input signal the return value will indicate that two changes occurred. If the sense does not match the input signal at least one change will occur. |
- Returns
- an unsigned integer value as described above.