40 typedef enum {
P0 = BIT_0,
P1 = BIT_1,
P2 = BIT_2,
P3 = BIT_3,
P4 = BIT_4,
P5 = BIT_5,
P6 = BIT_6,
P7 = BIT_7,
P8 = BIT_8,
P9 = BIT_9,
P10 = BIT_10,
P11 = BIT_11,
P12 = BIT_12,
P13 = BIT_13,
P14 = BIT_14,
P15 = BIT_15,
P16 = BIT_16,
P17 = BIT_17,
P18 = BIT_18,
P19 = BIT_19,
P20 = BIT_20,
P21 = BIT_21,
P22 = BIT_22,
P23 = BIT_23,
P24 = BIT_24,
P25 = BIT_25,
P26 = BIT_26,
P27 = BIT_27,
P28 = BIT_28,
P29 = BIT_29,
P30 = BIT_30,
P31 = BIT_31,
NULL_PIN = 0
97 uint32_t maskInt = mask;
129 static void flash_port (
const uint32_t pinMask, uint32_t iterations = 10) {
132 const unsigned int delay = MILLISECOND << 7;
133 unsigned int timer = delay + CNT;
135 for (uint32_t i = 0; i < iterations; ++i) {
137 timer = waitcnt2(timer, delay);
152 Port (
const uint32_t portMask) {
153 this->m_mask = portMask;
161 this->m_mask = portMask;
189 this->m_mask |= mask;
199 DIRA = (DIRA & ~(this->m_mask)) | (this->m_mask & direction);
208 if (DIRA & this->m_mask)
218 DIRA |= this->m_mask;
225 __asm__
volatile (
"andn dira, %0" : :
"r" (this->m_mask));
234 OUTA |= this->m_mask;
257 OUTA &= ~(this->m_mask);
280 OUTA ^= this->m_mask;
290 OUTA = ((OUTA & ~(this->m_mask)) | (value & this->m_mask));
299 return INA & this->m_mask;
332 this->m_firstPinNum = 0;
342 this->
set_mask(firstPin, portWidth);
353 this->
set_mask(firstPin, portWidth);
364 this->m_mask = firstPin;
370 this->m_mask |= this->m_mask << 1;
396 uint8_t m_firstPinNum;
SimplePort(const PropWare::Port::Mask firstPin, uint8_t portWidth, const PropWare::Port::Dir direction)
Initialize a port and configures its bit-mask and direction.
void set_dir(const PropWare::Port::Dir direction) const
Set port as either input or output.
The PropWare::SimplePort is the recommended way to use data ports on the Propeller. All pins are consecutive, which allows for some simple shortcuts in reading, writing, and initialization.
void write_fast(const uint32_t value) const
Allow easy writing to a port w/o destroying data elsewhere in the port; No shift is performed to alig...
void set_dir_in() const
Set the port for input.
uint32_t get_mask() const
Return the full pin mask of all pins in the port.
void clear() const
Clear selected output port (set it to 0)
Generic definitions and functions for the Parallax Propeller.
SimplePort(const PropWare::Port::Mask firstPin, uint8_t portWidth)
Initialize a port and configures its bit-mask.
static void flash_port(const Port::Mask firstPin, const uint8_t portWidth, const uint16_t iterations=10)
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given set o...
Port()
Instantiate a NULL instance.
void set_dir_out() const
Set the port for output.
Port(const uint32_t portMask)
PropWare::Port::Dir get_dir() const
Determine the direction this port is currently set to.
void write(uint32_t value) const
Allow easy writing to a port w/o destroying data elsewhere in the port; A shift is performed before w...
void toggle() const
Toggle the output value of a port.
Port(const uint32_t portMask, const PropWare::Port::Dir direction)
static uint8_t convert(Port::Mask mask)
Determine which pin number based on a pin mask.
static Port::Mask convert(const uint8_t pinNum)
Return a PropWare::Pin::Mask type based on a pin number.
void set_mask(const uint32_t mask)
Set the mask for this port.
uint32_t read_fast() const
Allow easy reading of only selected pins from a port.
Flexible port that can have any pin enabled or disabled. Pins are independent of each other...
uint32_t read() const
Allow easy reading of only selected pins from a port.
static void flash_port(const uint32_t pinMask, uint32_t iterations=10)
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given set o...
void set_mask(const PropWare::Port::Mask firstPin, uint8_t portWidth)
Configure a port's bit-mask.
void add_pins(const uint32_t mask)
Add pins to the current mask.