PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
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. More...
#include <PropWare/gpio/simpleport.h>
Public Types | |
enum | Mask { 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 } |
enum | Dir { Dir::IN = 0, Dir::OUT = -1 } |
Public Member Functions | |
SimplePort () | |
SimplePort (const PropWare::Port::Mask firstPin, uint8_t portWidth) | |
Initialize a port and configures its bit-mask. More... | |
SimplePort (const PropWare::Port::Mask firstPin, uint8_t portWidth, const PropWare::Port::Dir direction) | |
Initialize a port and configures its bit-mask and direction. More... | |
void | set_mask (const PropWare::Port::Mask firstPin, uint8_t portWidth) |
Configure a port's bit-mask. More... | |
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 writing to align the LSB of the input parameter with the least significant pin in the data port. More... | |
uint32_t | read () const |
Allow easy reading of only selected pins from a port. More... | |
void | set_mask (const uint32_t mask) |
Set the mask for this port. More... | |
uint32_t | get_mask () const |
Return the full pin mask of all pins in the port. More... | |
void | add_pins (const uint32_t mask) |
Add pins to the current mask. More... | |
void | set_dir (const PropWare::Port::Dir direction) const |
Set port as either input or output. More... | |
PropWare::Port::Dir | get_dir () const |
Determine the direction this port is currently set to. More... | |
void | set_dir_out () const |
Set the port for output. | |
void | set_dir_in () const |
Set the port for input. | |
void | set () const |
Set selected output port high (set all pins to 1) More... | |
void | high () const |
void | on () const |
void | clear () const |
Clear selected output port (set it to 0) More... | |
void | low () const |
void | off () const |
void | toggle () const |
Toggle the output value of a port. More... | |
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 align data with the desired output pins. More... | |
uint32_t | read_fast () const |
Allow easy reading of only selected pins from a port. More... | |
Static Public Member Functions | |
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 of pins a specific number of times. More... | |
static uint8_t | from_mask (const Mask mask) |
Determine which pin number based on a pin mask. More... | |
static Mask | to_mask (const uint8_t pinNum) |
Return a Mask type based on a pin number. More... | |
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 of pins a specific number of times. More... | |
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.
Definition at line 36 of file simpleport.h.
|
stronginherited |
|
inherited |
Bit-mask of GPIO pins
PropWare::SimplePort::SimplePort | ( | ) |
Definition at line 55 of file simpleport.h.
PropWare::SimplePort::SimplePort | ( | const PropWare::Port::Mask | firstPin, |
uint8_t | portWidth | ||
) |
Initialize a port and configures its bit-mask.
[in] | firstPin | Least significant pin in the data port mask |
[in] | portWidth | The number of pins in the data port |
Definition at line 66 of file simpleport.h.
PropWare::SimplePort::SimplePort | ( | const PropWare::Port::Mask | firstPin, |
uint8_t | portWidth, | ||
const PropWare::Port::Dir | direction | ||
) |
Initialize a port and configures its bit-mask and direction.
[in] | firstPin | Least significant pin in the data port mask |
[in] | portWidth | The number of pins in the data port |
[in] | direction | Determine input or output for the port |
Definition at line 77 of file simpleport.h.
|
inherited |
|
inherited |
|
static |
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given set of pins a specific number of times.
[in] | firstPin | First pin in sequence |
[in] | portWidth | Number of pins that should be flashed |
[in] | iterations | Number of times that the pins should flicker on and back off again |
Definition at line 46 of file simpleport.h.
|
staticinherited |
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given set of pins a specific number of times.
[in] | pinMask | Pins that should be flashed |
[in] | iterations | Number of times that the pins should flicker on and back off again |
Definition at line 129 of file port.h.
|
staticinherited |
Determine which pin number based on a pin mask.
[in] | mask | Value with only a single bit set high representing Propeller pin (i.e.: 0x80 would be pin 7) |
Definition at line 98 of file port.h.
|
inherited |
|
inherited |
|
inherited |
Definition at line 233 of file port.h.
|
inherited |
Definition at line 256 of file port.h.
|
inherited |
Definition at line 263 of file port.h.
|
inherited |
Definition at line 240 of file port.h.
uint32_t PropWare::SimplePort::read | ( | ) | const |
Allow easy reading of only selected pins from a port.
Definition at line 116 of file simpleport.h.
|
inherited |
|
inherited |
|
inherited |
void PropWare::SimplePort::set_mask | ( | const PropWare::Port::Mask | firstPin, |
uint8_t | portWidth | ||
) |
Configure a port's bit-mask.
[in] | firstPin | Least significant pin in the data port mask |
[in] | portWidth | The number of pins in the data port |
Definition at line 88 of file simpleport.h.
|
inherited |
|
staticinherited |
|
inherited |
void PropWare::SimplePort::write | ( | uint32_t | value | ) | const |
Allow easy writing to a port w/o destroying data elsewhere in the port; A shift is performed before writing to align the LSB of the input parameter with the least significant pin in the data port.
[in] | value | value to be bit-masked and then written to the port |
Definition at line 105 of file simpleport.h.
|
inherited |