FastLED  3.1
FastPin< PIN > Class Template Reference

The simplest level of Pin class. More...

#include <fastpin.h>

+ Inheritance diagram for FastPin< PIN >:

Public Types

typedef volatile RwReg * port_ptr_t
 
typedef RwReg port_t
 
typedef volatile RwReg * port_ptr_t
 
typedef RwReg port_t
 

Static Public Member Functions

static void setOutput ()
 
static void setInput ()
 
static void hi () __attribute__((always_inline))
 
static void lo () __attribute__((always_inline))
 
static void strobe () __attribute__((always_inline))
 
static void toggle () __attribute__((always_inline))
 
static void hi (register port_ptr_t port) __attribute__((always_inline))
 
static void lo (register port_ptr_t port) __attribute__((always_inline))
 
static void set (register port_t val) __attribute__((always_inline))
 
static void fastset (register port_ptr_t port, register port_t val) __attribute__((always_inline))
 
static port_t hival () __attribute__((always_inline))
 
static port_t loval () __attribute__((always_inline))
 
static port_ptr_t port () __attribute__((always_inline))
 
static port_t mask () __attribute__((always_inline))
 
static void setOutput ()
 
static void setInput ()
 
static void hi () __attribute__((always_inline))
 
static void lo () __attribute__((always_inline))
 
static void strobe () __attribute__((always_inline))
 
static void toggle () __attribute__((always_inline))
 
static void hi (register port_ptr_t port) __attribute__((always_inline))
 
static void lo (register port_ptr_t port) __attribute__((always_inline))
 
static void set (register port_t val) __attribute__((always_inline))
 
static void fastset (register port_ptr_t port, register port_t val) __attribute__((always_inline))
 
static port_t hival () __attribute__((always_inline))
 
static port_t loval () __attribute__((always_inline))
 
static port_ptr_t port () __attribute__((always_inline))
 
static port_t mask () __attribute__((always_inline))
 

Detailed Description

template<uint8_t PIN>
class FastPin< PIN >

The simplest level of Pin class.

This relies on runtime functions durinig 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.

Definition at line 160 of file fastpin.h.


The documentation for this class was generated from the following file: