template<uint8_t PIN>
class FastPin< PIN >
The simplest level of Pin class.
This relies on runtime functions during initialization to get the port/pin mask for the pin. Most of the accesses involve references to these static globals that get set up. This won't be the fastest set of pin operations, but it will provide pin level access on pretty much all Arduino environments. In addition, it includes some methods to help optimize access in various ways. Namely, the versions of hi(), lo(), and fastset() that take the port register as a passed in register variable (saving a global dereference), since these functions are aggressively inlined, that can help collapse out a lot of extraneous memory loads/dereferences.
In addition, if, while writing a bunch of data to a pin, you know no other pins will be getting written to, you can get/cache a value of the pin's port register and use that to do a full set to the register. This results in one being able to simply do a store to the register, vs. the load, and/or, and store that would be done normally.
There are platform specific instantiations of this class that provide direct i/o register access to pins for much higher speed pin twiddling.
Note that these classes are all static functions. So the proper usage is Pin<13>::hi(); or such. Instantiating objects is not recommended, as passing Pin objects around will likely -not- have the effect you're expecting.
- Examples
- Pintest.ino.
Definition at line 217 of file fastpin.h.
|
static void | setOutput () |
| Set the pin mode as OUTPUT
|
|
static void | setInput () |
| Set the pin mode as INPUT
|
|
static void | hi () |
| Set the pin state to HIGH
|
|
static void | lo () |
| Set the pin state to LOW
|
|
static void | strobe () |
| Toggle the pin twice to create a short pulse.
|
|
static void | toggle () |
| Toggle the pin.
|
|
static void | hi (FASTLED_REGISTER port_ptr_t port) |
| Set the same pin on another port to HIGH
|
|
static void | lo (FASTLED_REGISTER port_ptr_t port) |
| Set the same pin on another port to LOW
|
|
static void | set (FASTLED_REGISTER port_t val) |
| Set the state of the output register.
|
|
static void | fastset (FASTLED_REGISTER port_ptr_t port, FASTLED_REGISTER port_t val) |
| Set the state of a port.
|
|
static port_t | hival () |
| Gets the state of the port with this pin HIGH
|
|
static port_t | loval () |
| Gets the state of the port with this pin LOW
|
|
static port_ptr_t | port () |
| Get the output state of the port.
|
|
static port_t | mask () |
| Get the pin mask.
|
|