AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This file contains the primary macros for naming and manipulating GPIO pin names. More...
#include <avr/io.h>
Go to the source code of this file.
Classes | |
class | GpioPinVariable |
This class defines a type that can encode a GPIO pin as a variable. Read the section on GPIO Pin Variables to understand how to use this class. More... | |
Macros | |
#define | GpioPin(portLtr, pinNbr) |
Primary macro-function for defining a GPIO pin name. More... | |
#define | GpioPinAnalog(portLtr, pinNbr, adcNbr) |
Secondary macro-function for defining a GPIO pin name for GPIO pins that support analog conversion. More... | |
#define | GpioPinPwm(portLtr, pinNbr, timer, chan) |
Secondary macro-function for defining a GPIO pin name for GPIO pins that support PWM output. More... | |
#define | isGpioPinModeOutput(pinName) |
Test if the mode of the GPIO pin is output (i.e., the corresponding DDRn bit is set). More... | |
#define | isGpioPinModeInput(pinName) |
Test if the mode of the GPIO pin is input (i.e., the corresponding DDRn is clear). More... | |
#define | setGpioPinModeOutput(pinName) |
Set the mode of the GPIO pin to output (i.e., set the corresponding DDRn bit). More... | |
#define | setGpioPinModeInput(pinName) |
Set the mode of the GPIO pin to input (i.e., clear the corresponding DDRn and PORTn bits). More... | |
#define | setGpioPinModeInputPullup(pinName) |
Set the mode of the GPIO pin to input with pullup (i.e., clear the corresponding DDRn bit and set the PORTn bit). More... | |
#define | readGpioPinDigital(pinName) |
Read the value of the GPIO pin (i.e., return the value of correspoinding the PINn bit). More... | |
#define | writeGpioPinDigital(pinName, val) |
Write a value the GPIO pin (i.e., set or clear the correspoinding the PORTn bit). More... | |
#define | setGpioPinHigh(pinName) |
Write a 1 to the GPIO pin (i.e., set the correspoinding the PORTn bit). More... | |
#define | setGpioPinLow(pinName) |
Write a 0 the GPIO pin (i.e., clear the correspoinding the PORTn bit). More... | |
#define | getGpioDDR(pinName) |
Get the DDRn corresponding to this GPIO pin. More... | |
#define | getGpioPORT(pinName) |
Get the PORTn corresponding to this GPIO pin. More... | |
#define | getGpioPIN(pinName) |
Get the bit number corresponding to this GPIO pin. More... | |
#define | getGpioMASK(pinName) |
Get the bit mask corresponding to this GPIO pin. More... | |
#define | getGpioADC(pinName) |
Get the ADC channel corresponding to this GPIO pin, assuming it is an ADC capable GPIO pin. More... | |
#define | getGpioOCR(pinName) |
Get the OCR register corresponding to this GPIO pin, assuming it is a PWM capable GPIO pin. More... | |
#define | getGpioCOM(pinName) |
Get the COM bit name corresponding to this GPIO pin, assuming it is a PWM capable GPIO pin. More... | |
#define | getGpioTCCR(pinName) |
Get the TCCR register corresponding to this GPIO pin, assuming it is a PWM capable GPIO pin. More... | |
#define | makeGpioVarFromGpioPin(pinName) |
Create a GPIO pin variable of type GpioPinVariable from a GPIO pin macro. More... | |
#define | makeGpioVarFromGpioPinAnalog(pinName) |
Create a GPIO pin variable of type GpioPinVariable that can be used for analog-to-digital reading from a GPIO pin macro. More... | |
#define | makeGpioVarFromGpioPinPwm(pinName) |
Create a GPIO pin variable of type GpioPinVariable that can be used for PWM from a GPIO pin macro. More... | |
Enumerations | |
enum | { kDigitalLow = 0, kDigitalHigh = 1 } |
Constants for digital values representing LOW and HIGH. More... | |
Functions | |
bool | isGpioPinModeOutputV (const GpioPinVariable &pinVar) |
Test if the mode of the GPIO pin is output (i.e., the corresponding DDRn bit is set). More... | |
bool | isGpioPinModeInputV (const GpioPinVariable &pinVar) |
Test if the mode of the GPIO pin is input (i.e., the corresponding DDRn is clear). More... | |
void | setGpioPinModeOutputV (const GpioPinVariable &pinVar) |
Set the mode of the GPIO pin to output (i.e., set the corresponding DDRn bit). More... | |
void | setGpioPinModeInputV (const GpioPinVariable &pinVar) |
Set the mode of the GPIO pin to input (i.e., clear the corresponding DDRn and PORTn bits). More... | |
void | setGpioPinModeInputPullupV (const GpioPinVariable &pinVar) |
Set the mode of the GPIO pin to input with pullup (i.e., clear the corresponding DDRn bit and set the PORTn bit). More... | |
bool | readGpioPinDigitalV (const GpioPinVariable &pinVar) |
Read the value of the GPIO pin (i.e., return the value of correspoinding the PINn bit). More... | |
void | writeGpioPinDigitalV (const GpioPinVariable &pinVar, bool value) |
Write a value the GPIO pin (i.e., set or clear the correspoinding the PORTn bit). More... | |
void | setGpioPinHighV (const GpioPinVariable &pinVar) |
Write a 1 to the GPIO pin (i.e., set the correspoinding the PORTn bit). More... | |
void | setGpioPinLowV (const GpioPinVariable &pinVar) |
Write a 0 to the GPIO pin (i.e., clear the correspoinding the PORTn bit). More... | |
This file contains the primary macros for naming and manipulating GPIO pin names.
Normally you do not include this file directly. Instead include either ArduinoPins.h, which will automatically include this file.
#define getGpioADC | ( | pinName | ) |
Get the ADC channel corresponding to this GPIO pin, assuming it is an ADC capable GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioCOM | ( | pinName | ) |
Get the COM bit name corresponding to this GPIO pin, assuming it is a PWM capable GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioDDR | ( | pinName | ) |
Get the DDRn corresponding to this GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioMASK | ( | pinName | ) |
Get the bit mask corresponding to this GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioOCR | ( | pinName | ) |
Get the OCR register corresponding to this GPIO pin, assuming it is a PWM capable GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioPIN | ( | pinName | ) |
Get the bit number corresponding to this GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioPORT | ( | pinName | ) |
Get the PORTn corresponding to this GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define getGpioTCCR | ( | pinName | ) |
Get the TCCR register corresponding to this GPIO pin, assuming it is a PWM capable GPIO pin.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define GpioPin | ( | portLtr, | |
pinNbr | |||
) |
Primary macro-function for defining a GPIO pin name.
portLtr
an uppercase letter identifying the port (e.g., A, B, C, ...) the GPIO pin belongs to. pinNbr
a number between 0 and 7 identifying the bit on that port that corresponds to the GPIO pin. #define GpioPinAnalog | ( | portLtr, | |
pinNbr, | |||
adcNbr | |||
) |
Secondary macro-function for defining a GPIO pin name for GPIO pins that support analog conversion.
portLtr
an uppercase letter identifying the port (e.g., A, B, C, ...) the GPIO pin belongs to. pinNbr
a number between 0 and 7 identifying the bit on that port that corresponds to the GPIO pin. adcNbr
a number representing the ADC converter channel corresponding to this GPIO pin (0-7 for ArduinoUno; 0-15 for ArduinoMega) #define GpioPinPwm | ( | portLtr, | |
pinNbr, | |||
timer, | |||
chan | |||
) |
Secondary macro-function for defining a GPIO pin name for GPIO pins that support PWM output.
portLtr
an uppercase letter identifying the port (e.g., A, B, C, ...) the GPIO pin belongs to. pinNbr
a number between 0 and 7 identifying the bit on that port that corresponds to the GPIO pin. timer
a number representing the timer number associated with the PWM function on this GPIO pin. chan
a letter (A, B, or C) representing the channel on the timer associated with the PWM function on this GPIO pin. #define isGpioPinModeInput | ( | pinName | ) |
Test if the mode of the GPIO pin is input (i.e., the corresponding DDRn is clear).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define isGpioPinModeOutput | ( | pinName | ) |
Test if the mode of the GPIO pin is output (i.e., the corresponding DDRn bit is set).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define makeGpioVarFromGpioPin | ( | pinName | ) |
Create a GPIO pin variable of type GpioPinVariable from a GPIO pin macro.
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define makeGpioVarFromGpioPinAnalog | ( | pinName | ) |
Create a GPIO pin variable of type GpioPinVariable that can be used for analog-to-digital reading from a GPIO pin macro.
pinName
a GPIO pin name macro generated by GpioPinAnalog().#define makeGpioVarFromGpioPinPwm | ( | pinName | ) |
Create a GPIO pin variable of type GpioPinVariable that can be used for PWM from a GPIO pin macro.
pinName
a GPIO pin name macro generated by GpioPinPwm().#define readGpioPinDigital | ( | pinName | ) |
Read the value of the GPIO pin (i.e., return the value of correspoinding the PINn bit).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm().#define setGpioPinHigh | ( | pinName | ) |
Write a 1 to the GPIO pin (i.e., set the correspoinding the PORTn bit).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define setGpioPinLow | ( | pinName | ) |
Write a 0 the GPIO pin (i.e., clear the correspoinding the PORTn bit).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define setGpioPinModeInput | ( | pinName | ) |
Set the mode of the GPIO pin to input (i.e., clear the corresponding DDRn and PORTn bits).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define setGpioPinModeInputPullup | ( | pinName | ) |
Set the mode of the GPIO pin to input with pullup (i.e., clear the corresponding DDRn bit and set the PORTn bit).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define setGpioPinModeOutput | ( | pinName | ) |
Set the mode of the GPIO pin to output (i.e., set the corresponding DDRn bit).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). #define writeGpioPinDigital | ( | pinName, | |
val | |||
) |
Write a value the GPIO pin (i.e., set or clear the correspoinding the PORTn bit).
pinName
a GPIO pin name macro generated by either GpioPin(), GpioPinAnalog(), or GpioPinPwm(). val
the value to be written: 0 means to clear the GPIO pin; any other value means to set it. anonymous enum |
|
inline |
Test if the mode of the GPIO pin is input (i.e., the corresponding DDRn is clear).
pinVar
a GPIO pin variable of type GpioPinVariable.
|
inline |
Test if the mode of the GPIO pin is output (i.e., the corresponding DDRn bit is set).
pinVar
a GPIO pin variable of type GpioPinVariable.
|
inline |
Read the value of the GPIO pin (i.e., return the value of correspoinding the PINn bit).
pinVar
a GPIO pin variable of type GpioPinVariable.
|
inline |
Write a 1 to the GPIO pin (i.e., set the correspoinding the PORTn bit).
pinVar
a GPIO pin variable of type GpioPinVariable.
|
inline |
Write a 0 to the GPIO pin (i.e., clear the correspoinding the PORTn bit).
pinVar
aa GPIO pin variable of type GpioPinVariable.
|
inline |
Set the mode of the GPIO pin to input with pullup (i.e., clear the corresponding DDRn bit and set the PORTn bit).
pinVar
a GPIO pin variable of type GpioPinVariable.
|
inline |
Set the mode of the GPIO pin to input (i.e., clear the corresponding DDRn and PORTn bits).
pinVar
a GPIO pin name variable of type GpioPinVariable.
|
inline |
Set the mode of the GPIO pin to output (i.e., set the corresponding DDRn bit).
pinVar
a GPIO pin variable of type GpioPinVariable.
|
inline |
Write a value the GPIO pin (i.e., set or clear the correspoinding the PORTn bit).
pinVar
a GPIO pin variable of type GpioPinVariable. val
the value to be written: 0 means to clear the GPIO pin; any other value means to set it.