18#include <basictypes.h>
65 constexpr PinIO(uint32_t port, uint32_t pin) :
pio(*((volatile Pio*)
PIOA+port)),
mask(1 << pin) {}
78 uint8_t bits = ((uint8_t)fn)-2;
79 if (bits & 0x1) {
pio.PIO_ABCDSR[0] |=
mask; }
80 else {
pio.PIO_ABCDSR[0] &= ~mask; }
81 if (bits & 0x2) {
pio.PIO_ABCDSR[1] |=
mask; }
82 else {
pio.PIO_ABCDSR[1] &= ~mask; }
101 if(
mask == 0) {
return -1; }
112 uint32_t abcdsr0 = (
pio.PIO_ABCDSR[0] &
mask);
113 uint32_t abcdsr1 = (
pio.PIO_ABCDSR[1] &
mask);
153 inline bool tgl()
const {
bool val =
pio.PIO_ODSR &
mask;(&(
pio.PIO_SODR))[val] =
mask;
return val;}
185 (&(
pio.PIO_SODR))[!val] =
mask;
return *
this;
192 inline operator bool()
const {
return (
pio.PIO_PDSR &
mask); }
216 if (bHighDrive) {
pio.PIO_DRIVER |=
mask; }
217 else {
pio.PIO_DRIVER &= ~mask;}
268 pinCfg *
const pinArr;
275 PinIO *initpins, uint32_t pinCount);
310 operator uint32_t()
const;
324 _PinVector::pinCfg pinStore[n];
354#define TinyPinVector(n) \
355template<> class PinVector<n> : public _PinVector { \
357 inline PinVector(): _PinVector((n), nullptr) {} \
359 inline PinVector(PinIO *initpins, uint32_t pinCount) \
360 : _PinVector((n), nullptr, initpins, pinCount) \
362 inline uint32_t operator=(uint32_t val) {return (*(_PinVector*)this) = val; } \
363 inline uint32_t operator=(int val) {return (*(_PinVector*)this) = (uint32_t)val; } \
GPIO Pin Vector Base Class.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:259
void config(PinIO *pinCfgs, uint32_t count)
Configure the _PinVector based on an array of PinIOs. The index of the PinIO in the configuration arr...
uint32_t operator=(uint32_t val)
Assign a value to the _PinVector Bus.
PinIO operator[](int idx)
Access the PinIO for a specific bit position in the _PinVector.
void config(uint32_t idx, PinIO cfg)
Set the PinIO that will be used for a given bit position in the _PinVector.
GPIO Pin Class.
Definition coldfire/cpu/MCF5441X/include/cpu_pins.h:14
bool operator=(bool val)
Assign a driven value to the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:175
void setFn(pin_fn_t fn) const
Set the pin function for the managed pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:76
bool operator!() const
Return the opposite of the driven value of the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:198
void PullDown(bool enable) const
Configure the pad Pull Down resistor for the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:233
void set() const
Drive the pin(s) High.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:144
constexpr PinIO(uint32_t port, uint32_t pin)
Construct a PinIO for a specific cpu pin.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:65
bool toggle() const
Toggle the driven value for the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:158
void setHighStrength(bool bHighDrive)
Configure the drive strength of the output driver for the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:214
PinIO & operator=(const PinIO &rhs)
Assign a driven value to the pin(s) based on the line state of another pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:182
int8_t getFn()
Get the pin function for the managed pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:97
bool readBack() const
Read the state of the pin(s) line state without changing the pin function or direction.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:164
void drive() const
Configure the pin(s) to Output, without modifying the driven value.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:140
void PullUp(bool enable) const
Configure the pad Pull Up resistor for the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:226
uint16_t analogRead() const
Read an analog voltage on the given Pin. Only available for pins connected to the ADC.
bool read() const
Configure the pin as an input then return the line state.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:169
pin_fn_t
Definition coldfire/cpu/MCF5441X/include/cpu_pins.h:45
@ PIN_FN_D
Peripheral D.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:46
@ PIN_FN_A
Peripheral A.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:43
@ PIN_FN_OUT
Output.
Definition coldfire/cpu/MCF5441X/include/cpu_pins.h:51
@ PIN_FN_C
Peripheral C.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:45
@ PIN_FN_IN
Input.
Definition coldfire/cpu/MCF5441X/include/cpu_pins.h:50
@ PIN_FN_B
Peripheral B.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:44
void hiz() const
Configure the pin(s) to Input.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:136
void function(pin_fn_t fn) const
Set the pin function for the managed pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:132
bool tgl() const
Toggle the driven value for the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:153
PinIO()
Construct an empty PinIO. Exists for bootstrap compatibility; not intended for general use.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:53
constexpr PinIO(const PinIO &rhs)
Construct a copy of another PinIO.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:70
void clr() const
Drive the pin(s) Low.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:148
void multidrv(bool enable) const
Configure the multidrive/open-drain driver for the pin(s).
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:206
GPIO Pin Vector Class PinVector is a template instantiation of the _PinVector class,...
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:323
uint32_t operator=(uint32_t val)
Assign a value to the PinVector Bus.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:346
PinVector(PinIO *initpins, uint32_t pinCount)
PinVector Constructor, where pin configurations will be made at the time of construction.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:338
PinVector()
Bare constructor for a PinVector, where the bit configurations will be made later.
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:330
volatile Pio & pio
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:34
uint32_t mask
Definition cortex-m7/cpu/SAME70/include/cpu_pins.h:35
#define PIOA
(PIOA ) Base Address
Definition same70q21_sim.h:253