FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
API that manipulates a whole digital IO port. More...
#include <fastarduino/gpio.h>
Public Member Functions | |
FastPort ()=default | |
Construct a FastPort without any physical setup on target MCU. More... | |
FastPort (uint8_t ddr, uint8_t port=0) INLINE | |
Construct a FastPort with the given direction byte and initial values byte. More... | |
template<uint8_t BIT> | |
FastPin< PORT, BIT > | get_pin (PinMode mode, bool value=false) |
Create a FastPin instance for a given pin of this port, and sets its direction mode and level value (if output). More... | |
template<uint8_t BIT> | |
FastPin< PORT, BIT > | get_pin () |
Create a FastPin instance for a given pin of this port. More... | |
void | set_PORT (uint8_t port) INLINE |
Set the 8-bits value for port PORT register. More... | |
uint8_t | get_PORT () INLINE |
Get the current 8-bit value of port PORT register. More... | |
void | set_DDR (uint8_t ddr) INLINE |
Set the 8-bits value for port DDR (direction) register. More... | |
uint8_t | get_DDR () INLINE |
Get the current 8-bit value of port DDR (direction) register. More... | |
void | set_PIN (uint8_t pin) INLINE |
Set the 8-bits value for port PIN register. More... | |
uint8_t | get_PIN () INLINE |
Get the 8-bits value of PIN register for this port, i.e. More... | |
Static Public Attributes | |
static constexpr const board::Port | PORT = PORT_ |
The actual port in target MCU. More... | |
API that manipulates a whole digital IO port.
Implementation is highly optimized for size and speed: instances use no SRAM at all, most common methods use only 2 AVR instructions.
Note that using this API means that every method manipulates ALL pins of a port at a time. If you need to handle several, but not all, pins of a port, consider using gpio::FastMaskedPort instead.
PORT_ | the target port |
|
default |
Construct a FastPort
without any physical setup on target MCU.
This is useful if default pins directions and values are OK for you and you want to avoid calling mode setup on target MCU.
|
inline |
Construct a FastPort
with the given direction byte and initial values byte.
The pins mode is forced on the target MCU.
ddr | the direction to set (in DDR register of this port) for each pin (1 bit is one pin, when 1 the pin is set as output, when 0 as input). |
port | the initial values for PORT register of this port; each bit is for one pin of the port, its meaning depends on the pin direction: if input, then it fixes if pullup resistor should be used, if output, then it fixes the output level of the pin. |
|
inline |
Create a FastPin
instance for a given pin of this port, and sets its direction mode and level value (if output).
Note that you would normally not need this method, as each pin should normally already set properly first through this port. You should rather use get_pin()
instead.
BIT | the bit position for which to return a FastPin instance; if there is no pin at this bit position, a compilation error will occur. |
FastPin
instance allowing direct manipulation of the given pin
|
inline |
Create a FastPin
instance for a given pin of this port.
No additional setup is performed on that pin: it just keeps its current direction and value.
BIT | the bit position for which to return a FastPin instance; if there is no pin at this bit position, a compilation error will occur. |
FastPin
instance allowing direct manipulation of the given pin
|
inline |
Set the 8-bits value for port PORT register.
If a pin is set currently set as output, then the matching bit in port
will set the output level of this pin. If a pin is set currently as input, then the matching bit in port
defines if a pullup resistor is used or not.
port | the initial values for PORT register of this port; each bit is for one pin of the port, its meaning depends on the pin direction: if input, then it fixes if pullup resistor should be used, if output, then it fixes the output level of the pin. |
|
inline |
Get the current 8-bit value of port PORT register.
Each bit maps to a pin configuration in this port. Depending on DDR configuration for a pin, the PORT value is interpreted differently: for an input pin, the matching PORT bit indicates if this pin has a pullup register on it.
|
inline |
Set the 8-bits value for port DDR (direction) register.
Each pin direction is decided by the matching bit.
ddr | the direction to set (in DDR register of this port) for each pin (1 bit is one pin, when 1 the pin is set as output, when 0 as input). |
|
inline |
|
inline |
|
inline |
|
staticconstexpr |