GPIO_NXP_Arduino 0.1.1
GPIO device operation sample code for Arduino
|
#include <GPIO_NXP.h>
Public Types | |
enum | board { NONE , ARDUINO_SHIELD } |
Public Member Functions | |
GPIO_base (uint8_t i2c_address, const int nbits, const uint8_t *arp, uint8_t ai) | |
virtual | ~GPIO_base () |
void | begin (board env=NONE) |
void | output (int port, uint8_t value, uint8_t mask=0) |
void | output (uint8_t *vp) |
uint8_t | input (int port) |
uint8_t * | input (uint8_t *vp) |
void | config (int port, uint8_t config, uint8_t mask=0) |
void | config (uint8_t *vp) |
void | write_port (access_word w, uint8_t *vp) |
void | write_port16 (access_word w, uint16_t *vp) |
uint8_t * | read_port (access_word w, uint8_t *vp) |
uint16_t * | read_port16 (access_word w, uint16_t *vp) |
void | write_port (access_word w, uint8_t value, int port_num=0) |
void | write_port16 (access_word w, uint16_t value, int port_num=0) |
uint8_t | read_port (access_word w, int port_num=0) |
uint16_t | read_port16 (access_word w, int port_num=0) |
Static Public Member Functions | |
static void | print_bin (uint8_t v) |
Public Attributes | |
const int | n_bits |
const int | n_ports |
GPIO_base class
This class is a base class for all GPIO devices All actual device class will be derived from this
Definition at line 44 of file GPIO_NXP.h.
enum GPIO_base::board |
Target board selection constants
Definition at line 49 of file GPIO_NXP.h.
GPIO_base::GPIO_base | ( | uint8_t | i2c_address, |
const int | nbits, | ||
const uint8_t * | arp, | ||
uint8_t | ai | ||
) |
Constractor
i2c_address | I2C target address |
nbits | Number of IO bits |
arp | Pointer to register access reference table |
ai | Auto-increment flag |
Definition at line 5 of file GPIO_NXP.cpp.
|
virtual |
Destractor
Definition at line 18 of file GPIO_NXP.cpp.
void GPIO_base::begin | ( | board | env = NONE | ) |
Device initialization
Initialization method for Arduino shield board. Since the PCAL6xxx Arduino shield board have floating ADR (on D9) pin, the I2C target address could be another one. To avoid this behavior, call this method with 'GPIO_base::ARDUINO_SHIELD'. It will perform a hardware reset after the ADR pin set LOW.
env | board type given. If the target is an Arduino shield board, use GPIO_base::ARDUINO_SHIELD |
Definition at line 22 of file GPIO_NXP.cpp.
void GPIO_base::config | ( | int | port, |
uint8_t | config, | ||
uint8_t | mask = 0 |
||
) |
Config, single
Basic GPIO port access function for single port configuration
port | Port number |
value | Value to be written into configuration register |
mask | Bit mask. Value will not be changed in bit positions '1' in mask |
Definition at line 65 of file GPIO_NXP.cpp.
Referenced by config().
void GPIO_base::config | ( | uint8_t * | vp | ) |
Config, all
Basic GPIO port access function for all port configuration
vp | Pointer to array of configuration values. The array should have 'n_ports' length |
Definition at line 73 of file GPIO_NXP.cpp.
uint8_t GPIO_base::input | ( | int | port | ) |
Input, single
Basic GPIO port access function for single port input
port | Port number |
Definition at line 53 of file GPIO_NXP.cpp.
uint8_t * GPIO_base::input | ( | uint8_t * | vp | ) |
Input, all
Basic GPIO port access function for all ports input
vp | Pointer to an array of values. The array should have 'n_ports' length |
Definition at line 58 of file GPIO_NXP.cpp.
void GPIO_base::output | ( | int | port, |
uint8_t | value, | ||
uint8_t | mask = 0 |
||
) |
Output, single
Basic GPIO port access function for single port output
port | Port number |
value | Value to be output |
mask | Bit mask. Value will not be changed in bit positions '1' in mask |
Definition at line 40 of file GPIO_NXP.cpp.
void GPIO_base::output | ( | uint8_t * | vp | ) |
Output, all
Basic GPIO port access function for all ports output
vp | Pointer to an array of values. The array should have 'n_ports' length |
Definition at line 48 of file GPIO_NXP.cpp.
|
static |
Definition at line 168 of file GPIO_NXP.cpp.
uint8_t GPIO_base::read_port | ( | access_word | w, |
int | port_num = 0 |
||
) |
Read single port method
Single port register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
port_num | Option, to specify port number |
Definition at line 158 of file GPIO_NXP.cpp.
uint8_t * GPIO_base::read_port | ( | access_word | w, |
uint8_t * | vp | ||
) |
Read all port method
All port register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
vp | Pointer to an array of values. The array should have 'n_ports' length |
Definition at line 110 of file GPIO_NXP.cpp.
Referenced by input().
uint16_t GPIO_base::read_port16 | ( | access_word | w, |
int | port_num = 0 |
||
) |
Read single port method
Single port 16 bit register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
port_num | Option, to specify port number |
Definition at line 163 of file GPIO_NXP.cpp.
uint16_t * GPIO_base::read_port16 | ( | access_word | w, |
uint16_t * | vp | ||
) |
Read all port method
All port 16 bit register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
vp | Pointer to an array of values. The array should have 'n_ports' length |
Definition at line 123 of file GPIO_NXP.cpp.
void GPIO_base::write_port | ( | access_word | w, |
uint8_t * | vp | ||
) |
Write all port method
All port register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
vp | Pointer to an array of values. The array should have 'n_ports' length |
Definition at line 78 of file GPIO_NXP.cpp.
void GPIO_base::write_port | ( | access_word | w, |
uint8_t | value, | ||
int | port_num = 0 |
||
) |
Write single port method
Single port register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
value | Value to be written into a register |
port_num | Option, to specify port number |
Definition at line 148 of file GPIO_NXP.cpp.
void GPIO_base::write_port16 | ( | access_word | w, |
uint16_t * | vp | ||
) |
Write all port method
All port 16 bit register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
vp | Pointer to an array of values. The array should have 'n_ports' length |
Definition at line 89 of file GPIO_NXP.cpp.
void GPIO_base::write_port16 | ( | access_word | w, |
uint16_t | value, | ||
int | port_num = 0 |
||
) |
Write single port method
Single port 16 bit register access function using word of 'access_word'
w | Accsess word. This should be choosen from access_word' |
value | Value to be written into a register |
port_num | Option, to specify port number |
Definition at line 153 of file GPIO_NXP.cpp.
const int GPIO_base::n_bits |
Number of IO bits
Definition at line 55 of file GPIO_NXP.h.
Referenced by read_port16(), and write_port16().
const int GPIO_base::n_ports |
Number of IO ports
Definition at line 58 of file GPIO_NXP.h.
Referenced by read_port(), read_port16(), write_port(), and write_port16().