SdFat
Classes | Macros | Functions
Fast Pin I/O

Classes

class  DigitalPin< PinNumber >
 Fast digital port I/O. More...
 
struct  GpioPinMap_t
 

Macros

#define GPIO_PIN(reg, bit)   {&PIN##reg, &DDR##reg, &PORT##reg, 1 << bit}
 

Functions

static void badPinCheck (uint8_t pin)
 
void badPinNumber (void)
 
static volatile uint8_t * ddrReg (uint8_t pin)
 
static void fastBitWriteSafe (volatile uint8_t *address, uint8_t mask, bool level)
 
static void fastDdrWrite (uint8_t pin, bool level)
 
static bool fastDigitalRead (uint8_t pin)
 
static void fastDigitalToggle (uint8_t pin)
 
static void fastDigitalWrite (uint8_t pin, bool level)
 
static void fastPinConfig (uint8_t pin, uint8_t mode, bool level)
 
static void fastPinMode (uint8_t pin, uint8_t mode)
 
static uint8_t pinMask (uint8_t pin)
 
static volatile uint8_t * pinReg (uint8_t pin)
 
static volatile uint8_t * portReg (uint8_t pin)
 

Detailed Description

Fast Digital I/O functions and template class.

Macro Definition Documentation

#define GPIO_PIN (   reg,
  bit 
)    {&PIN##reg, &DDR##reg, &PORT##reg, 1 << bit}

Initializer macro.

Function Documentation

static void badPinCheck ( uint8_t  pin)
inlinestatic

Check for valid pin number

Parameters
[in]pinNumber of pin to be checked.
void badPinNumber ( void  )

generate bad pin number error

static volatile uint8_t* ddrReg ( uint8_t  pin)
inlinestatic

DDR register address

Parameters
[in]pinArduino pin number
Returns
register address
static void fastBitWriteSafe ( volatile uint8_t *  address,
uint8_t  mask,
bool  level 
)
inlinestatic

Fast write helper.

Parameters
[in]addressI/O register address
[in]maskbit mask for pin
[in]levelvalue for bit
static void fastDdrWrite ( uint8_t  pin,
bool  level 
)
inlinestatic

Write the DDR register.

Parameters
[in]pinArduino pin number
[in]levelvalue to write
static bool fastDigitalRead ( uint8_t  pin)
inlinestatic

Read pin value.

Parameters
[in]pinArduino pin number
Returns
value read
static void fastDigitalToggle ( uint8_t  pin)
inlinestatic

Toggle a pin.

Parameters
[in]pinArduino pin number

If the pin is in output mode toggle the pin level. If the pin is in input mode toggle the state of the 20K pullup.

static void fastDigitalWrite ( uint8_t  pin,
bool  level 
)
inlinestatic

Set pin value.

Parameters
[in]pinArduino pin number
[in]levelvalue to write
static void fastPinConfig ( uint8_t  pin,
uint8_t  mode,
bool  level 
)
inlinestatic

set pin configuration

Parameters
[in]pinArduino pin number
[in]modemode INPUT or OUTPUT.
[in]levelIf mode is output, set level high/low. If mode is input, enable or disable the pin's 20K pullup.
static void fastPinMode ( uint8_t  pin,
uint8_t  mode 
)
inlinestatic

Set pin mode.

Parameters
[in]pinArduino pin number
[in]modeINPUT, OUTPUT, or INPUT_PULLUP.

The internal pullup resistors will be enabled if mode is INPUT_PULLUP and disabled if the mode is INPUT.

static uint8_t pinMask ( uint8_t  pin)
inlinestatic

Bit mask for pin

Parameters
[in]pinArduino pin number
Returns
mask
static volatile uint8_t* pinReg ( uint8_t  pin)
inlinestatic

PIN register address

Parameters
[in]pinArduino pin number
Returns
register address
static volatile uint8_t* portReg ( uint8_t  pin)
inlinestatic

PORT register address

Parameters
[in]pinArduino pin number
Returns
register address