PropWare
C++ objects and CMake build system for Parallax Propeller
|
Utility class to handle general purpose I/O pins. More...
#include <pin.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 { IN = 0, OUT = -1 } |
Public Member Functions | |
Pin () | |
Initialize to a NULL pin mask. | |
Pin (const PropWare::Port::Mask mask) | |
Create a Pin variable. More... | |
Pin (const PropWare::Port::Mask mask, const PropWare::Port::Dir direction) | |
void | set_mask (const PropWare::Port::Mask mask) |
void | set_pin_num (const uint8_t pinNum) |
Set a Pin's mask based on the pin number (an integer, 0 through 31) More... | |
PropWare::Port::Mask | get_mask () const |
void | write (const bool value) const |
Set or clear the pin programmatically. More... | |
bool | read () const |
Read the value from a single pin and return its state. More... | |
void | wait_until_high () const |
Hold cog execution until an input pin goes high. More... | |
void | wait_until_low () const |
Hold cog execution until an input pin goes low. More... | |
void | wait_until_toggle () const |
Hold cog execution until an input pin toggles. More... | |
bool | is_switch_low (const uint16_t debounceDelayInMillis=3) const |
Allow easy switch-press detection of any pin; Includes de-bounce protection. More... | |
PropWare::Pin * | operator= (const PropWare::Pin &rhs) |
Copy one pin object into another; Only copies pin mask, not I/O direction. | |
bool | operator== (const PropWare::Pin &rhs) |
Compare the pin mask of two pin objects. Does not compare I/O direction. | |
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... | |
Static Public Member Functions | |
static void | flash_pin (const Pin::Mask pinMask, const uint32_t iterations=10) |
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given pin a specific number of times. More... | |
static uint8_t | convert (Port::Mask mask) |
Determine which pin number based on a pin mask. More... | |
static Port::Mask | convert (const uint8_t pinNum) |
Return a PropWare::Pin::Mask type based on a pin number. More... | |
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 of pins a specific number of times. More... | |
Utility class to handle general purpose I/O pins.
|
inherited |
|
inherited |
Bit-mask of GPIO pins
PropWare::Pin::Pin | ( | const PropWare::Port::Mask | mask | ) |
Create a Pin variable.
[in] | mask | Bit-mask of pin; One of PropWare::Pin::Mask |
PropWare::Pin::Pin | ( | const PropWare::Port::Mask | mask, |
const PropWare::Port::Dir | direction | ||
) |
[in] | mask | Bit-mask of pin; One of PropWare::Pin::Mask |
[in] | direction | Direction to initialize pin; One of PropWare::Pin::Dir |
|
inherited |
Clear selected output port (set it to 0)
Definition at line 256 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 95 of file port.h.
|
staticinherited |
Return a PropWare::Pin::Mask type based on a pin number.
[in] | pinNum | PinNum number |
|
static |
Great for quick debugging to ensure a line of code is executed, this will quickly flash a given pin a specific number of times.
[in] | pinMask | Pin that should be flashed |
[in] | iterations | Number of times that the pin should flicker on and back off again |
Definition at line 45 of file pin.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.
|
inherited |
Determine the direction this port is currently set to.
|
inherited |
bool PropWare::Pin::is_switch_low | ( | const uint16_t | debounceDelayInMillis = 3 | ) | const |
Allow easy switch-press detection of any pin; Includes de-bounce protection.
[in] | debounceDelayInMillis | Set the de-bounce delay in units of milliseconds |
Definition at line 155 of file pin.h.
|
inherited |
Definition at line 263 of file port.h.
|
inherited |
Definition at line 270 of file port.h.
|
inherited |
bool PropWare::Pin::read | ( | ) | const |
|
inherited |
Set selected output port high (set all pins to 1)
Definition at line 233 of file port.h.
|
inherited |
Set port as either input or output.
[in] | direction | I/O direction to set selected pins; must be one of PropWare::Port::IN or PropWare::Port::OUT |
Definition at line 198 of file port.h.
void PropWare::Pin::set_mask | ( | const PropWare::Port::Mask | mask | ) |
Definition at line 77 of file pin.h.
void PropWare::Pin::set_pin_num | ( | const uint8_t | pinNum | ) |
|
inherited |
Toggle the output value of a port.
Definition at line 279 of file port.h.
void PropWare::Pin::wait_until_high | ( | ) | const |
void PropWare::Pin::wait_until_low | ( | ) | const |
void PropWare::Pin::wait_until_toggle | ( | ) | const |
void PropWare::Pin::write | ( | const bool | value | ) | const |
|
inherited |