|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
43 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
100 uint32_t maskInt = mask;
102 while (maskInt >>= 1)
117 return Mask::NULL_PIN;
119 return static_cast<Mask>(1 << pinNum);
129 static void flash_port (
const uint32_t pinMask,
unsigned int iterations = 10) {
132 const unsigned int delay = MILLISECOND << 7;
133 unsigned int timer = delay +
CNT;
135 for (uint32_t i = 0; i < iterations; ++i) {
145 Port (
const uint32_t portMask = Mask::NULL_PIN) {
146 this->m_mask = portMask;
154 this->m_mask = portMask;
182 this->m_mask |= mask;
192 DIRA = (
DIRA & ~(this->m_mask)) | (this->m_mask &
static_cast<uint32_t
>(direction));
201 if (
DIRA & this->m_mask)
211 __asm__
volatile (
"or dira, %0" : :
"r" (this->m_mask));
218 __asm__
volatile (
"andn dira, %0" : :
"r" (this->m_mask));
227 __asm__
volatile (
"or outa, %0" : :
"r" (this->m_mask));
250 __asm__
volatile (
"andn outa, %0" : :
"r" (this->m_mask));
273 __asm__
volatile (
"xor outa, %0" : :
"r" (this->m_mask));
283 OUTA = ((
OUTA & ~(this->m_mask)) | (value & this->m_mask));
292 return INA & this->m_mask;
void set_dir_out() const
Set the port for output.
static uint8_t from_mask(const Mask mask)
Determine which pin number based on a pin mask.
#define OUTA
Use to set output pin states when corresponding DIRA bits are 1.
uint32_t read_fast() const
Allow easy reading of only selected pins from a port.
#define INA
Use to read the pins when corresponding DIRA bits are 0.
void add_pins(const uint32_t mask)
Add pins to the current mask.
static void flash_port(const uint32_t pinMask, unsigned int iterations=10)
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given set o...
void set_dir_in() const
Set the port for input.
void set_dir(const PropWare::Port::Dir direction) const
Set port as either input or output.
#define waitcnt2(a, b)
Wait until system counter reaches a value.
Port(const uint32_t portMask, const PropWare::Port::Dir direction)
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...
Flexible port that can have any pin enabled or disabled. Pins are independent of each other.
void set() const
Set selected output port high (set all pins to 1)
Port(const uint32_t portMask=Mask::NULL_PIN)
void set_mask(const uint32_t mask)
Set the mask for this port.
#define CNT
The system clock count.
uint32_t get_mask() const
Return the full pin mask of all pins in the port.
void toggle() const
Toggle the output value of a port.
PropWare::Port::Dir get_dir() const
Determine the direction this port is currently set to.
#define DIRA
Use to set pins to input (0) or output (1).
static Mask to_mask(const uint8_t pinNum)
Return a Mask type based on a pin number.
Generic definitions and functions for the Parallax Propeller.
void clear() const
Clear selected output port (set it to 0)