Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
GPIO< PIN > Class Template Reference

#include <GPIO.h>

Inheritance diagram for GPIO< PIN >:
Inheritance graph
Collaboration diagram for GPIO< PIN >:
Collaboration graph

Classes

struct  gpio_reg_t
 

Public Member Functions

GPIO< PIN > & input ()
 
void pullup ()
 
void output ()
 
void open_drain ()
 
bool read ()
 
 operator bool ()
 
void low ()
 
void high ()
 
void toggle ()
 
void write (int value)
 
void operator= (int value)
 
void pulse (uint16_t width)
 
int pulse ()
 
 GPIO ()
 
GPIO< PIN > & input ()
 
void pullup ()
 
void output ()
 
void open_drain ()
 
bool read ()
 
 operator bool ()
 
void low ()
 
void high ()
 
void toggle ()
 
void write (int value)
 
void operator= (int value)
 
void pulse (uint16_t width)
 
int pulse ()
 

Protected Member Functions

gpio_reg_tSFR ()
 
Pio * SFR ()
 
uint32_t ID_PIO ()
 

Static Protected Attributes

static const uint8_t MASK = GPIO_MASK(PIN)
 
static const uint32_t MASK = GPIO_MASK(PIN)
 

Detailed Description

template<BOARD::pin_t PIN>
class GPIO< PIN >

General Purpose Digital I/O pin template class. Highly optimized pin access. The PIN address is a bit pointer to the port control register. See Hardware/AVR/Board.h for details.

Parameters
[in]PINboard pin definition.

General Purpose Digital I/O pin template class. Highly optimized pin access. The PIN address is a port control register index and pin bit position. See Hardware/SAM/Board.h for details.

Parameters
[in]PINboard pin definition.

Definition at line 31 of file GPIO.h.

Constructor & Destructor Documentation

template<BOARD::pin_t PIN>
GPIO< PIN >::GPIO ( )
inline

Construct pin instance and initiate.

Definition at line 36 of file GPIO.h.

Member Function Documentation

template<BOARD::pin_t PIN>
void GPIO< PIN >::high ( )
inline

Set pin high(1). Shorthand for write(HIGH).

Definition at line 104 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::high ( )
inline

Set pin high(1). Shorthand for write(HIGH).

Definition at line 113 of file GPIO.h.

template<BOARD::pin_t PIN>
uint32_t GPIO< PIN >::ID_PIO ( )
inlineprotected

Return parallel input/output port identity.

Returns
identity.

Definition at line 200 of file GPIO.h.

template<BOARD::pin_t PIN>
GPIO<PIN>& GPIO< PIN >::input ( )
inline

Set pin to input mode.

Definition at line 36 of file GPIO.h.

template<BOARD::pin_t PIN>
GPIO<PIN>& GPIO< PIN >::input ( )
inline

Set pin to input mode.

Definition at line 45 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::low ( )
inline

Set pin low(0). Shorthand for write(LOW).

Definition at line 95 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::low ( )
inline

Set pin low(0). Shorthand for write(LOW).

Definition at line 104 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::open_drain ( )
inline

Open-drain pin. Use input() for high and output() for low.

Definition at line 65 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::open_drain ( )
inline

Open-drain pin. Use input() for high and output() for low.

Definition at line 74 of file GPIO.h.

template<BOARD::pin_t PIN>
GPIO< PIN >::operator bool ( )
inline

Return current pin state. Shorthand for read().

Returns
state.

Definition at line 86 of file GPIO.h.

template<BOARD::pin_t PIN>
GPIO< PIN >::operator bool ( )
inline

Return current pin state. Shorthand for read().

Returns
state.

Definition at line 95 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::operator= ( int  value)
inline

Set pin to given state. Non-zero value will set the pin HIGH(1), and zero value will set the pin LOW(0). Shorthand for write(value).

Parameters
[in]valueto set pin.

Definition at line 135 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::operator= ( int  value)
inline

Set pin to given state. Non-zero value will set the pin HIGH(1), and zero value will set the pin LOW(0). Shorthand for write(value).

Parameters
[in]valueto set pin.

Definition at line 144 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::output ( )
inline

Set pin to output mode.

Definition at line 56 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::output ( )
inline

Set pin to output mode.

Definition at line 65 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::pullup ( )
inline

Used with input() to activate internal pullup resistor on input pin.

Definition at line 47 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::pullup ( )
inline

Used with input() to activate internal pullup resistor on input pin.

Definition at line 56 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::pulse ( uint16_t  width)
inline

Generate pulse with given width in micro-seconds. Interrupts are disabled while generating the pulse.

Parameters
[in]widthin micro-seconds.

Definition at line 146 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::pulse ( uint16_t  width)
inline

Generate pulse with given width in micro-seconds. Interrupts are disabled while generating the pulse.

Parameters
[in]widthin micro-seconds.

Definition at line 155 of file GPIO.h.

template<BOARD::pin_t PIN>
int GPIO< PIN >::pulse ( )
inline

Detect pulse and return width in micro-seconds.

Returns
width in micro-seconds.

Definition at line 163 of file GPIO.h.

template<BOARD::pin_t PIN>
int GPIO< PIN >::pulse ( )
inline

Detect pulse and return width in micro-seconds.

Returns
width in micro-seconds.

Definition at line 167 of file GPIO.h.

template<BOARD::pin_t PIN>
bool GPIO< PIN >::read ( )
inline

Return current pin state.

Returns
state.

Definition at line 76 of file GPIO.h.

template<BOARD::pin_t PIN>
bool GPIO< PIN >::read ( )
inline

Return current pin state.

Returns
state.

Definition at line 85 of file GPIO.h.

template<BOARD::pin_t PIN>
Pio* GPIO< PIN >::SFR ( )
inlineprotected

Return pointer to control registers.

Returns
pointer.

Definition at line 184 of file GPIO.h.

template<BOARD::pin_t PIN>
gpio_reg_t* GPIO< PIN >::SFR ( )
inlineprotected

Return pointer to control registers.

Returns
pointer.

Definition at line 184 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::toggle ( )
inline

Toggle pin state. Shorthand for write(!read()).

Definition at line 113 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::toggle ( )
inline

Toggle pin state. Shorthand for write(!read()).

Definition at line 122 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::write ( int  value)
inline

Set pin to given state. Non-zero value will set the pin HIGH(1), and zero value will set the pin LOW(0).

Parameters
[in]valueto set pin.

Definition at line 124 of file GPIO.h.

template<BOARD::pin_t PIN>
void GPIO< PIN >::write ( int  value)
inline

Set pin to given state. Non-zero value will set the pin HIGH(1), and zero value will set the pin LOW(0).

Parameters
[in]valueto set pin.

Definition at line 133 of file GPIO.h.

Member Data Documentation

template<BOARD::pin_t PIN>
const uint32_t GPIO< PIN >::MASK = GPIO_MASK(PIN)
staticprotected

Pin bit position mask in control registers.

Definition at line 178 of file GPIO.h.

template<BOARD::pin_t PIN>
const uint8_t GPIO< PIN >::MASK = GPIO_MASK(PIN)
staticprotected

Pin bit position mask in control registers.

Definition at line 191 of file GPIO.h.


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