Class pn532::gpio_status

Class Documentation

class gpio_status

Bitmap of the PN532’s GPIO. This class holds the values of all the GPIOs on the ports P3, P7 and I0/I1 of the PN532. You can set and read the whole mask (gpio_status::mask, gpio_status::set_mask) or individual bits with gpio_status::operator[]:

gpio_status gpio{};
gpio[{gpio_port::p3, 2}] = true;

Note

Setting a bit in this class does not automatically set it on the PN532, this just holds the value. You need to call e.g. controller::write_gpio

Public Functions

gpio_status() = default

Zero-initializes the data structure (all GPIO low).

inline gpio_status(std::uint8_t p3_mask, std::uint8_t p7_mask, std::uint8_t i0i1_mask)

Initialized the value of the GPIO for a bitmask for each port.

inline std::uint8_t mask(gpio_port loc) const

Read the bitmask of a single GPIO port.

inline void set_mask(gpio_port loc, std::uint8_t mask)

Set the bitmask of a single GPIO port.

inline bool operator[](std::pair<gpio_port, std::uint8_t> const &gpio_idx) const

Reads the status of a single GPIO.

Parameters:

gpio_idx – A port, index pair, e.g. {gpio_port::p3, 2}.

Returns:

True if the GPIO is high.

inline mlab::bit_ref operator[](std::pair<gpio_port, std::uint8_t> const &gpio_idx)

Returns a writable reference to a single bit, representing the status of a single GPIO.

Parameters:

gpio_idx – A port, index pair, e.g. {gpio_port::p3, 2}.

Returns:

A mlab::bit_ref instance (which should not outlive this object).