AberLED shield library
Library for the bicolor LED (and TFT screen) shield used in CS12020
Public Types | Static Public Member Functions | List of all members
FastPin< PIN > Class Template Reference

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. More...

#include <TFT_FastPin.h>

Public Types

typedef volatile uint8_t * port_ptr_t
 
typedef uint8_t 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 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 139 of file TFT_FastPin.h.

Member Typedef Documentation

template<uint8_t PIN>
typedef volatile uint8_t* FastPin< PIN >::port_ptr_t

Definition at line 147 of file TFT_FastPin.h.

template<uint8_t PIN>
typedef uint8_t FastPin< PIN >::port_t

Definition at line 148 of file TFT_FastPin.h.

Member Function Documentation

template<uint8_t PIN>
static void FastPin< PIN >::fastset ( register port_ptr_t  port,
register port_t  val 
)
inlinestatic

Definition at line 162 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::hi ( )
inlinestatic

Definition at line 153 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::hi ( register port_ptr_t  port)
inlinestatic

Definition at line 158 of file TFT_FastPin.h.

template<uint8_t PIN>
static port_t FastPin< PIN >::hival ( )
inlinestatic

Definition at line 164 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::lo ( )
inlinestatic

Definition at line 154 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::lo ( register port_ptr_t  port)
inlinestatic

Definition at line 159 of file TFT_FastPin.h.

template<uint8_t PIN>
static port_t FastPin< PIN >::loval ( )
inlinestatic

Definition at line 165 of file TFT_FastPin.h.

template<uint8_t PIN>
static port_t FastPin< PIN >::mask ( )
inlinestatic

Definition at line 167 of file TFT_FastPin.h.

template<uint8_t PIN>
static port_ptr_t FastPin< PIN >::port ( )
inlinestatic

Definition at line 166 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::set ( register port_t  val)
inlinestatic

Definition at line 160 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::setInput ( )
inlinestatic

Definition at line 151 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::setOutput ( )
inlinestatic

Definition at line 150 of file TFT_FastPin.h.

template<uint8_t PIN>
static void FastPin< PIN >::strobe ( )
inlinestatic

Definition at line 156 of file TFT_FastPin.h.


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