18 #include <basictypes.h> 66 constexpr
PinIO(uint32_t port, uint32_t pin) :
pio(*((volatile Pio*)PIOA+port)),
mask(1 << pin) {}
79 uint8_t bits = ((uint8_t)fn)-2;
80 if (bits & 0x1) {
pio.PIO_ABCDSR[0] |=
mask; }
81 else {
pio.PIO_ABCDSR[0] &= ~
mask; }
82 if (bits & 0x2) {
pio.PIO_ABCDSR[1] |=
mask; }
83 else {
pio.PIO_ABCDSR[1] &= ~
mask; }
109 inline void set()
const {
pio.PIO_SODR =
mask; }
118 inline bool tgl()
const {
bool val =
pio.PIO_ODSR &
mask;(&(
pio.PIO_SODR))[val] =
mask;
return val;}
150 (&(
pio.PIO_SODR))[!val] =
mask;
return *
this;
157 inline operator bool()
const {
return (
pio.PIO_PDSR &
mask); }
181 if (bHighDrive) {
pio.PIO_DRIVER |=
mask; }
182 else {
pio.PIO_DRIVER &= ~
mask;}
233 pinCfg *
const pinArr;
240 PinIO *initpins, uint32_t pinCount);
275 operator uint32_t()
const;
290 _PinVector::pinCfg pinStore[n];
319 #define TinyPinVector(n) \ 320 template<> class PinVector<n> : public _PinVector { \ 322 inline PinVector(): _PinVector((n), nullptr) {} \ 324 inline PinVector(PinIO *initpins, uint32_t pinCount) \ 325 : _PinVector((n), nullptr, initpins, pinCount) \ bool operator!() const
Return the oposite of the driven value of the pin(s).
Definition: cpu_pins.h:163
bool readBack() const
Read the state of the pin(s) line state without changing the pin function or direction.
Definition: cpu_pins.h:129
PinVector(PinIO *initpins, uint32_t pinCount)
PinVector Constructor, where pin configurations will be made at the time of construction.
Definition: cpu_pins.h:304
PinIO()
Construct an empty PinIO. Exists for bootstrap compatibility; not intended for general use...
Definition: cpu_pins.h:54
Output.
Definition: cpu_pins.h:43
void multidrv(bool enable) const
Configure the multidrive/open-drain driver for the pin(s).
Definition: cpu_pins.h:171
GPIO Pin Vector Base Class.
Definition: cpu_pins.h:224
constexpr PinIO(uint32_t port, uint32_t pin)
Construct a PinIO for a specific cpu pin.
Definition: cpu_pins.h:66
Peripheral A.
Definition: cpu_pins.h:44
bool operator=(bool val)
Assign a driven value to the pin(s).
Definition: cpu_pins.h:140
bool read() const
Configure the pin as an input then return the line state.
Definition: cpu_pins.h:134
PinIO & operator=(const PinIO &rhs)
Assign a driven value to the pin(s) based on the line state of another pin(s).
Definition: cpu_pins.h:147
PinIO operator[](int idx)
Access the PinIO for a specific bit position in the _PinVector.
uint32_t operator=(uint32_t val)
Assign a value to the _PinVector Bus.
void PullUp(bool enable) const
Configure the pad Pull Up resistor for the pin(s).
Definition: cpu_pins.h:191
void clr() const
Drive the pin(s) Low.
Definition: cpu_pins.h:113
void PullDown(bool enable) const
Configure the pad Pull Down resistor for the pin(s).
Definition: cpu_pins.h:198
Peripheral D.
Definition: cpu_pins.h:47
bool toggle() const
Toggle the driven value for the pin(s).
Definition: cpu_pins.h:123
uint32_t operator=(uint32_t val)
Assign a value to the PinVector Bus.
Definition: cpu_pins.h:312
volatile Pio & pio
Definition: cpu_pins.h:34
void setHighStrength(bool bHighDrive)
Configure the drive strength of the output driver for the pin(s).
Definition: cpu_pins.h:179
void hiz() const
Configure the pin(s) to Input.
Definition: cpu_pins.h:101
void setFn(pin_fn_t fn) const
Set the pin function for the managed pin(s).
Definition: cpu_pins.h:77
void drive() const
Configure the pin(s) to Output, without modifying the driven value.
Definition: cpu_pins.h:105
constexpr PinIO(const PinIO &rhs)
Construct a copy of another PinIO.
Definition: cpu_pins.h:71
Input.
Definition: cpu_pins.h:42
uint16_t analogRead() const
Read an analog voltage on the given Pin. Only available for pins connected to the ADC...
void config(uint32_t idx, PinIO cfg)
Set the PinIO that will be used for a given bit position in the _PinVector.
Peripheral B.
Definition: cpu_pins.h:45
GPIO Pin Class.
Definition: cpu_pins.h:32
Peripheral C.
Definition: cpu_pins.h:46
pin_fn_t
Definition: cpu_pins.h:41
GPIO Pin Vector Class PinVector is a template instantiation of the _PinVector class, allowing for minimal storage requirements for potentially large vectors, without heavy code duplication due to template copies.
Definition: cpu_pins.h:289
PinVector()
Bare constructor for a PinVector, where the bit configurations will be made later.
Definition: cpu_pins.h:296
bool tgl() const
Toggle the driven value for the pin(s).
Definition: cpu_pins.h:118
uint32_t mask
Definition: cpu_pins.h:35