nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
gpio.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0 */
2 /* Copyright 2015-2019 Peter A. Bigot */
3 
7 #ifndef NRFCXX_GPIO_HPP
8 #define NRFCXX_GPIO_HPP
9 #pragma once
10 
11 #include <nrfcxx/impl.hpp>
12 
13 namespace nrfcxx {
14 
16 namespace gpio {
17 
22 constexpr uint32_t PIN_CNF_RDONLY = ((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
23  | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
24  | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
25  | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos));
26 
31 constexpr uint32_t PIN_CNF_WRONLY = ((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
32  | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
33  | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
34  | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos));
35 
40 constexpr uint32_t PIN_CNF_RDWR = ((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
41  | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
42  | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
43  | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos));
44 
54 constexpr uint32_t PIN_CNF_PWRUP = ((GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
55  | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
56  | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos)
57  | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos));
58 
60 constexpr uint32_t PIN_CNF_PULLUP = (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos);
61 
63 constexpr uint32_t PIN_CNF_PULLDOWN = (GPIO_PIN_CNF_PULL_Pulldown << GPIO_PIN_CNF_PULL_Pos);
64 
70  | (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos));
71 
77 
83  | (GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos));
84 
90 
95 static constexpr int instance_for_psel (int psel)
96 {
99  return 0;
100  }
101 #if (NRF52840 - 0)
103  && (psel < nrf5::GPIO_Instance<1>::end_psel)) {
104  return 1;
105  }
106 #endif
107  return -1;
108 }
109 
129 template <int PSEL>
131 {
139  using GPIO_Instance = nrf5::GPIO_Instance<PSEL / 32>;
140 
141 public:
142  using this_type = instr_psel<PSEL>;
143 
145  constexpr static int global_psel = PSEL;
146 
148  constexpr static uint8_t psel = (PSEL - GPIO_Instance::begin_psel);
149 
151  constexpr static uint8_t gpio_instance = GPIO_Instance::peripheral.INSTANCE;
152 
154  constexpr static nrf5::GPIO_Type gpio = GPIO_Instance::peripheral;
155 
158  constexpr static bool psel_valid = (0 <= PSEL) && (psel < gpio.AUX);
159 
161  constexpr static uint32_t bit = (psel_valid ? (1U << psel) : 0);
162  /* No-op constructor and destructor, as these objects are generally
163  * statically allocated in an anonymous namespace. This means the
164  * application must enable() them explicitly. */
165  instr_psel ()
166  { }
167 
168  ~instr_psel ()
169  { }
170 
171  /* No copying or moving these things */
172  instr_psel (const instr_psel&) = delete;
173  instr_psel& operator= (const instr_psel&) = delete;
174  instr_psel (instr_psel&&) = delete;
175  instr_psel& operator= (instr_psel&&) = delete;
176 
183  void enable (bool set = false) const
184  {
185  if (psel_valid) {
186  if (set) {
187  gpio->OUTSET = bit;
188  } else {
189  gpio->OUTCLR = bit;
190  }
191  gpio->PIN_CNF[psel] = PIN_CNF_WRONLY;
192  }
193  }
194 
199  void disable () const
200  {
201  if (psel_valid) {
202  gpio->PIN_CNF[psel] = PIN_CNF_PWRUP;
203  }
204  }
205 
207  void assert () const
208  {
209  if (psel_valid) {
210  gpio->OUTSET = bit;
211  }
212  }
213 
215  void deassert () const
216  {
217  if (psel_valid) {
218  gpio->OUTCLR = bit;
219  }
220  }
221 
225  void set (bool asserted) const
226  {
227  if (psel_valid) {
228  if (asserted) {
229  gpio->OUTSET = bit;
230  } else {
231  gpio->OUTCLR = bit;
232  }
233  }
234  }
235 
237  void toggle () const
238  {
239  if (psel_valid) {
240  if (gpio->OUT & bit) {
241  gpio->OUTCLR = bit;
242  } else {
243  gpio->OUTSET = bit;
244  }
245  }
246  }
247 
248 };
249 
257 template <typename INSTR_PSEL>
259 {
260 public:
261  using instr_psel_type = INSTR_PSEL;
262 
263  constexpr instr_psel_scoped (const instr_psel_type& instance_,
264  bool start_set) :
265  instance{instance_}
266  {
267  instance.enable(start_set);
268  }
269 
271  {
272  instance.deassert();
273  instance.disable();
274  }
275 
276  /* You can't copy or assign scoped instances but you can
277  * move-construct them. */
278  instr_psel_scoped (const instr_psel_scoped&) = delete;
279  instr_psel_scoped& operator= (const instr_psel_scoped&) = delete;
280  instr_psel_scoped (instr_psel_scoped&&) = default;
281  instr_psel_scoped& operator= (instr_psel_scoped&&) = delete;
282 
284  void assert () const
285  {
286  instance.assert();
287  }
288 
290  void deassert () const
291  {
292  instance.deassert();
293  }
294 
296  void set (bool asserted) const
297  {
298  instance.set(asserted);
299  }
300 
302  void toggle () const
303  {
304  instance.toggle();
305  }
306 
307  const instr_psel_type& instance;
308 };
309 
329 template <typename INSTR_PSEL>
330 instr_psel_scoped<INSTR_PSEL>
331 make_scoped_instr (const INSTR_PSEL& instance,
332  bool start_set = true)
333 {
334  return {instance, start_set};
335 }
336 
345 {
346 public:
348  uint8_t const global_psel;
349 
351  uint8_t const local_psel;
352 
355  uint32_t const local_bit;
356 
361 
371  static pin_reference create (int psel);
372 
374  void set () const
375  {
376  peripheral->OUTSET = local_bit;
377  }
378 
380  void clear () const
381  {
382  peripheral->OUTCLR = local_bit;
383  }
384 
386  void toggle () const
387  {
388  if (is_set()) {
389  clear();
390  } else {
391  set();
392  }
393  }
394 
397  uint32_t configuration () const
398  {
399  return peripheral->PIN_CNF[local_psel];
400  }
401 
403  void configure (uint32_t pin_cnf) const
404  {
405  peripheral->PIN_CNF[local_psel] = pin_cnf;
406  }
407 
410  bool read () const
411  {
412  return local_bit & peripheral->IN;
413  }
414 
417  bool is_set () const
418  {
419  return (local_bit & peripheral->OUT);
420  }
421 
422 private:
424  int psel,
425  int begin_psel);
426 };
427 
440 {
441 public:
442  generic_pin () = default;
443  virtual ~generic_pin () = default;
444 
450  virtual bool valid () const
451  {
452  return false;
453  }
454 
456  virtual void set ()
457  { }
458 
460  virtual void clear ()
461  { }
462 
464  virtual void toggle ()
465  { }
466 
480  virtual void configure (unsigned int pin_cnf)
481  { }
482 
486  virtual unsigned int configuration () const
487  {
488  return 0;
489  }
490 
493  virtual bool read () const
494  {
495  return false;
496  }
497 
500  virtual bool is_set () const
501  {
502  return false;
503  }
504 };
505 
507 class gpio_pin : public generic_pin
508 {
509 public:
514  gpio_pin (int psel) :
515  pr_{pin_reference::create(psel)}
516  { }
517 
520  {
521  return pr_;
522  }
523 
524  bool valid () const override
525  {
526  return true;
527  }
528 
529  void set () override
530  {
531  pr_.set();
532  }
533 
534  void clear () override
535  {
536  pr_.clear();
537  }
538 
539  void toggle () override
540  {
541  pr_.toggle();
542  }
543 
544  unsigned int configuration () const override
545  {
546  return pr_.configuration();
547  }
548 
549  void configure (unsigned int pin_cnf) override
550  {
551  pr_.configure(pin_cnf);
552  }
553 
554  bool read () const override
555  {
556  return pr_.read();
557  }
558 
559  bool is_set () const override
560  {
561  return pr_.is_set();
562  }
563 
564 private:
565  pin_reference pr_;
566 };
567 
577 template <bool ACTIVE_HIGH = false>
579 {
580 public:
581  static constexpr bool active_high = ACTIVE_HIGH;
583 
584  generic_pin& pin;
585 
590  {
591  ~scoped_assert ()
592  {
593  al_.deassert();
594  }
595 
596  private:
597  friend this_type;
598 
599  scoped_assert (const this_type& al) :
600  al_{al}
601  {
602  al_.assert();
603  }
604 
605  const this_type& al_;
606  };
607 
610  {
611  return scoped_assert{*this};
612  }
613 
622  pin{pin}
623  {
624  deassert();
625  }
626 
628  bool valid () const
629  {
630  return true;
631  }
632 
634  bool asserted () const
635  {
636  return active_high == pin.is_set();
637  }
638 
640  void assert () const
641  {
642  return active_high ? pin.set() : pin.clear();
643  }
644 
646  void deassert () const
647  {
648  return active_high ? pin.clear() : pin.set();
649  }
650 
656  void enable (unsigned int aux = 0) const
657  {
658  pin.configure(PIN_CNF_WRONLY | aux);
659  }
660 
662  void disable () const
663  {
665  }
666 };
667 
670 
709 inline
710 constexpr
711 uint32_t
712 pin_config (unsigned int dir = GPIO_PIN_CNF_DIR_Input,
713  unsigned int input = GPIO_PIN_CNF_INPUT_Disconnect,
714  unsigned int pull = GPIO_PIN_CNF_PULL_Disabled,
715  unsigned int drive = GPIO_PIN_CNF_DRIVE_S0S1,
716  unsigned int sense = GPIO_PIN_CNF_SENSE_Disabled)
717 {
718  return (GPIO_PIN_CNF_DIR_Msk & (dir << GPIO_PIN_CNF_DIR_Pos))
719  | (GPIO_PIN_CNF_INPUT_Msk & (input << GPIO_PIN_CNF_INPUT_Pos))
720  | (GPIO_PIN_CNF_PULL_Msk & (input << GPIO_PIN_CNF_PULL_Pos))
721  | (GPIO_PIN_CNF_DRIVE_Msk & (input << GPIO_PIN_CNF_DRIVE_Pos))
722  | (GPIO_PIN_CNF_SENSE_Msk & (input << GPIO_PIN_CNF_SENSE_Pos));
723 }
724 
733 template <typename mutex_type = null_mutex>
734 void
735 clear_sense (unsigned int psel)
736 {
737  mutex_type mutex;
738 
739  const uint32_t pin_cnf = nrf5::GPIO->PIN_CNF[psel];
740  nrf5::GPIO->PIN_CNF[psel] = pin_cnf & ~GPIO_PIN_CNF_SENSE_Msk;
741 }
742 
779 unsigned int
780 update_sense_bi (unsigned int psel,
781  bool assume_change = false);
782 
783 } // namespace gpio
784 } // namespace nrfcxx
785 
786 #endif /* NRFCXX_GPIO_HPP */
nrfcxx::gpio::PIN_CNF_RDWR
constexpr uint32_t PIN_CNF_RDWR
GPIO pin configuration for input and output.
Definition: gpio.hpp:40
nrfcxx::gpio::generic_pin::clear
virtual void clear()
Set the pin to drive the output low.
Definition: gpio.hpp:460
nrfcxx::gpio::PIN_CNF_PULLUP
constexpr uint32_t PIN_CNF_PULLUP
Addition to no-pull GPIO pin configuration to pull up.
Definition: gpio.hpp:60
nrfcxx::gpio::update_sense_bi
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.
nrfcxx::gpio::instr_psel
Instrumentation through toggling GPIOs.
Definition: gpio.hpp:130
nrfcxx::gpio::active_signal::make_scoped
scoped_assert make_scoped() const
Construct an RAII object that asserts the signal while it exists.
Definition: gpio.hpp:609
nrfcxx::gpio::gpio_pin::is_set
bool is_set() const override
Return true iff the pin is valid and is configured to drive the output high.
Definition: gpio.hpp:559
nrfcxx::gpio::gpio_pin::configuration
unsigned int configuration() const override
Return implementation-specific information about the pin configuration.
Definition: gpio.hpp:544
nrfcxx::gpio::pin_reference::configuration
uint32_t configuration() const
Return the PIN_CNF entry for the pin, or zero if the reference is invalid.
Definition: gpio.hpp:397
nrfcxx::gpio::instr_psel::bit
constexpr static uint32_t bit
The bit mask corresponding to PSEL.
Definition: gpio.hpp:161
nrfcxx::gpio::instr_psel::gpio_instance
constexpr static uint8_t gpio_instance
The GPIO instance ordinal.
Definition: gpio.hpp:151
nrfcxx::gpio::instr_psel_scoped::assert
void assert() const
Forward to instr_psel::assert().
Definition: gpio.hpp:284
nrfcxx::gpio::generic_pin
Class supporting a generic GPIO pin interface.
Definition: gpio.hpp:439
nrfcxx::gpio::instr_psel::enable
void enable(bool set=false) const
Enable the instrumentation functionality.
Definition: gpio.hpp:183
nrfcxx::gpio::instr_psel::set
void set(bool asserted) const
Set the corresponding GPIO to a specific state.
Definition: gpio.hpp:225
nrfcxx::gpio::instr_psel_scoped::toggle
void toggle() const
Forward to instr_psel::toggle().
Definition: gpio.hpp:302
nrfcxx::gpio::active_signal::asserted
bool asserted() const
Indicate whether the signal is currently asserted.
Definition: gpio.hpp:634
nrfcxx::gpio::instr_psel_scoped
RAII class for scoped instrumentation.
Definition: gpio.hpp:258
nrfcxx::gpio::gpio_pin
Extension of generic_pin using an owned pin_reference.
Definition: gpio.hpp:507
nrfcxx::gpio::pin_reference::global_psel
uint8_t const global_psel
The pin selector index across all GPIO instances.
Definition: gpio.hpp:348
nrfcxx::gpio::generic_pin::valid
virtual bool valid() const
Indicate whether the pin is functional.
Definition: gpio.hpp:450
nrfcxx::gpio::active_signal::scoped_assert
RAII instance used to assert the signal within a scope.
Definition: gpio.hpp:589
nrfcxx::gpio::pin_reference::is_set
bool is_set() const
Return true iff the pin is valid and is configured to drive the output high.
Definition: gpio.hpp:417
nrfcxx::gpio::gpio_pin::valid
bool valid() const override
Indicate whether the pin is functional.
Definition: gpio.hpp:524
nrfcxx::gpio::clear_sense
void clear_sense(unsigned int psel)
Function to clear the SENSE field of a GPIO pin configuration.
Definition: gpio.hpp:735
nrfcxx::gpio::instr_psel::deassert
void deassert() const
Set the corresponding GPIO to logic 0.
Definition: gpio.hpp:215
nrfcxx::nrf5::peripheral
Capture information about an nRF5 peripheral instance.
Definition: core.hpp:165
nrfcxx::gpio::active_signal
Wrapper supporting GPIO control of output signals by explicit or scoped assertion.
Definition: gpio.hpp:578
nrfcxx::gpio::PIN_CNF_WRONLY
constexpr uint32_t PIN_CNF_WRONLY
GPIO pin configuration for output only.
Definition: gpio.hpp:31
nrfcxx::gpio::instr_psel_scoped::deassert
void deassert() const
Forward to instr_psel::deassert().
Definition: gpio.hpp:290
nrfcxx::nrf5::peripheral::AUX
const uint8_t AUX
Auxiliary information relevant to the specific peripheral and type.
Definition: core.hpp:245
nrfcxx::gpio::gpio_pin::read
bool read() const override
Return the input signal observed at the pin, or zero if the reference is invalid.
Definition: gpio.hpp:554
nrfcxx::gpio::generic_pin::is_set
virtual bool is_set() const
Return true iff the pin is valid and is configured to drive the output high.
Definition: gpio.hpp:500
nrfcxx::gpio::active_signal::assert
void assert() const
Clear the associated GPIO to assert the active-low signal.
Definition: gpio.hpp:640
nrfcxx::gpio::PIN_CNF_PULLDOWN
constexpr uint32_t PIN_CNF_PULLDOWN
Addition to no-pull GPIO pin configuration to pull down.
Definition: gpio.hpp:63
nrfcxx::gpio::PIN_CNF_ACTIVE_LOW_NOPULL
constexpr uint32_t PIN_CNF_ACTIVE_LOW_NOPULL
GPIO pin configuration to detect active-low signals without pulling to inactive.
Definition: gpio.hpp:69
nrfcxx::gpio::PIN_CNF_RDONLY
constexpr uint32_t PIN_CNF_RDONLY
GPIO pin configuration for input only.
Definition: gpio.hpp:22
nrfcxx::gpio::active_signal::valid
bool valid() const
Indicate whether the signal is configured with a valid pin reference.
Definition: gpio.hpp:628
nrfcxx::gpio::pin_reference::local_psel
uint8_t const local_psel
The pin selector index within peripheral.
Definition: gpio.hpp:351
nrfcxx::gpio::instance_for_psel
static constexpr int instance_for_psel(int psel)
Determine the GPIO instance associated with a given pin selector.
Definition: gpio.hpp:95
nrfcxx::gpio::gpio_pin::gpio_pin
gpio_pin(int psel)
Construct the instance.
Definition: gpio.hpp:514
nrfcxx::gpio::gpio_pin::implementation
const pin_reference & implementation() const
Access the underlying pin_reference instance.
Definition: gpio.hpp:519
nrfcxx::gpio::instr_psel::gpio
constexpr static nrf5::GPIO_Type gpio
The GPIO instance that provides access to #PSEL.
Definition: gpio.hpp:154
nrfcxx::nrf5::GPIO_Instance
A traits type identifying GPIO peripheral instances.
Definition: core.hpp:260
nrfcxx::gpio::generic_pin::read
virtual bool read() const
Return the input signal observed at the pin, or zero if the reference is invalid.
Definition: gpio.hpp:493
nrfcxx::gpio::active_signal::deassert
void deassert() const
Set the associated GPIO to deassert the active-low signal.
Definition: gpio.hpp:646
nrfcxx::gpio::PIN_CNF_ACTIVE_HIGH
constexpr uint32_t PIN_CNF_ACTIVE_HIGH
GPIO pin configuration to detect active-low signals with pull to inactive.
Definition: gpio.hpp:89
nrfcxx::gpio::active_signal::enable
void enable(unsigned int aux=0) const
Configure the associated GPIO to control the signal output.
Definition: gpio.hpp:656
nrfcxx::gpio::gpio_pin::configure
void configure(unsigned int pin_cnf) override
Set the PIN_CNF entry for the pin if the reference is valid.
Definition: gpio.hpp:549
nrfcxx::gpio::gpio_pin::set
void set() override
Set the pin to drive the output high.
Definition: gpio.hpp:529
nrfcxx::gpio::active_signal::disable
void disable() const
Configure the associated GPIO to its power-up (non-controlling) state.
Definition: gpio.hpp:662
nrfcxx::gpio::PIN_CNF_ACTIVE_LOW
constexpr uint32_t PIN_CNF_ACTIVE_LOW
GPIO pin configuration to detect active-low signals with pull to inactive.
Definition: gpio.hpp:76
nrfcxx::gpio::instr_psel::psel
constexpr static uint8_t psel
Index for the PSEL within its GPIO instance.
Definition: gpio.hpp:148
nrfcxx::gpio::instr_psel::assert
void assert() const
Set the corresponding GPIO to logic 1.
Definition: gpio.hpp:207
nrfcxx::gpio::instr_psel::global_psel
constexpr static int global_psel
Index for the PSEL within all GPIO peripherals on the device.
Definition: gpio.hpp:145
nrfcxx::gpio::pin_reference::toggle
void toggle() const
Toggle the pin drive state.
Definition: gpio.hpp:386
nrfcxx::gpio::active_signal::active_signal
active_signal(generic_pin &pin)
Construct the helper for an active-low signal.
Definition: gpio.hpp:621
impl.hpp
Primary header for nrfcxx implementation dependencies.
nrfcxx::gpio::generic_pin::set
virtual void set()
Set the pin to drive the output high.
Definition: gpio.hpp:456
nrfcxx::gpio::instr_psel::disable
void disable() const
Disable the instrumentation functionality.
Definition: gpio.hpp:199
nrfcxx::gpio::pin_reference::set
void set() const
Set the pin to drive the output high.
Definition: gpio.hpp:374
nrfcxx::gpio::pin_reference::local_bit
uint32_t const local_bit
A mask isolating the local_psel bit within the value space of peripheral.
Definition: gpio.hpp:355
nrfcxx::gpio::PIN_CNF_ACTIVE_HIGH_NOPULL
constexpr uint32_t PIN_CNF_ACTIVE_HIGH_NOPULL
GPIO pin configuration to detect active-high signals without pulling to inactive.
Definition: gpio.hpp:82
nrfcxx::gpio::generic_pin::toggle
virtual void toggle()
Toggle the pin drive state.
Definition: gpio.hpp:464
nrfcxx::gpio::PIN_CNF_PWRUP
constexpr uint32_t PIN_CNF_PWRUP
GPIO pin configuration at power-up.
Definition: gpio.hpp:54
nrfcxx::gpio::pin_reference::read
bool read() const
Return the input signal observed at the pin, or zero if the reference is invalid.
Definition: gpio.hpp:410
nrfcxx::gpio::instr_psel::psel_valid
constexpr static bool psel_valid
Valid GPIOs are non-negative values that are among the pins supported by the instance.
Definition: gpio.hpp:158
nrfcxx::gpio::instr_psel::toggle
void toggle() const
Invert the state of the corresponding GPIO.
Definition: gpio.hpp:237
nrfcxx::gpio::pin_reference::clear
void clear() const
Set the pin to drive the output low.
Definition: gpio.hpp:380
nrfcxx::gpio::gpio_pin::clear
void clear() override
Set the pin to drive the output low.
Definition: gpio.hpp:534
nrfcxx::gpio::instr_psel_scoped::set
void set(bool asserted) const
Forward to instr_psel::set().
Definition: gpio.hpp:296
nrfcxx::gpio::gpio_pin::toggle
void toggle() override
Toggle the pin drive state.
Definition: gpio.hpp:539
nrfcxx::gpio::make_scoped_instr
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.
Definition: gpio.hpp:331
nrfcxx::gpio::pin_reference
Generalized reference to a GPIO pin using a global psel ordinal.
Definition: gpio.hpp:344
nrfcxx::gpio::pin_config
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.
Definition: gpio.hpp:712
nrfcxx::gpio::pin_reference::create
static pin_reference create(int psel)
Construct the instance for the given global ordinal GPIO pin.
nrfcxx::gpio::pin_reference::peripheral
const nrf5::GPIO_Type & peripheral
Reference to a valid GPIO peripheral wrapper.
Definition: gpio.hpp:360
nrfcxx
Primary namespace for nrfcxx functionality.
Definition: clock.hpp:17
nrfcxx::gpio::pin_reference::configure
void configure(uint32_t pin_cnf) const
Set the PIN_CNF entry for the pin.
Definition: gpio.hpp:403
nrfcxx::gpio::generic_pin::configuration
virtual unsigned int configuration() const
Return implementation-specific information about the pin configuration.
Definition: gpio.hpp:486
nrfcxx::gpio::generic_pin::configure
virtual void configure(unsigned int pin_cnf)
Set the PIN_CNF entry for the pin if the reference is valid.
Definition: gpio.hpp:480