GPIO_NXP_Arduino 0.1.1
GPIO device operation sample code for Arduino
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GPIO_base Class Reference

#include <GPIO_NXP.h>

Inheritance diagram for GPIO_base:
PCAL6xxx_base PCAL6408A PCAL6416A PCAL6524 PCAL6534

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
 

Detailed Description

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.

Member Enumeration Documentation

◆ board

Target board selection constants

Definition at line 49 of file GPIO_NXP.h.

Constructor & Destructor Documentation

◆ GPIO_base()

GPIO_base::GPIO_base ( uint8_t  i2c_address,
const int  nbits,
const uint8_t *  arp,
uint8_t  ai 
)

Constractor

Parameters
i2c_addressI2C target address
nbitsNumber of IO bits
arpPointer to register access reference table
aiAuto-increment flag

Definition at line 5 of file GPIO_NXP.cpp.

◆ ~GPIO_base()

GPIO_base::~GPIO_base ( )
virtual

Destractor

Definition at line 18 of file GPIO_NXP.cpp.

Member Function Documentation

◆ begin()

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.

Parameters
envboard type given. If the target is an Arduino shield board, use GPIO_base::ARDUINO_SHIELD

Definition at line 22 of file GPIO_NXP.cpp.

◆ config() [1/2]

void GPIO_base::config ( int  port,
uint8_t  config,
uint8_t  mask = 0 
)

Config, single

Basic GPIO port access function for single port configuration

Parameters
portPort number
valueValue to be written into configuration register
maskBit mask. Value will not be changed in bit positions '1' in mask

Definition at line 65 of file GPIO_NXP.cpp.

Referenced by config().

◆ config() [2/2]

void GPIO_base::config ( uint8_t *  vp)

Config, all

Basic GPIO port access function for all port configuration

Parameters
vpPointer to array of configuration values. The array should have 'n_ports' length

Definition at line 73 of file GPIO_NXP.cpp.

◆ input() [1/2]

uint8_t GPIO_base::input ( int  port)

Input, single

Basic GPIO port access function for single port input

Parameters
portPort number
Returns
Port read value

Definition at line 53 of file GPIO_NXP.cpp.

◆ input() [2/2]

uint8_t * GPIO_base::input ( uint8_t *  vp)

Input, all

Basic GPIO port access function for all ports input

Parameters
vpPointer to an array of values. The array should have 'n_ports' length
Returns
Pointer to vp

Definition at line 58 of file GPIO_NXP.cpp.

◆ output() [1/2]

void GPIO_base::output ( int  port,
uint8_t  value,
uint8_t  mask = 0 
)

Output, single

Basic GPIO port access function for single port output

Parameters
portPort number
valueValue to be output
maskBit mask. Value will not be changed in bit positions '1' in mask

Definition at line 40 of file GPIO_NXP.cpp.

◆ output() [2/2]

void GPIO_base::output ( uint8_t *  vp)

Output, all

Basic GPIO port access function for all ports output

Parameters
vpPointer to an array of values. The array should have 'n_ports' length

Definition at line 48 of file GPIO_NXP.cpp.

◆ print_bin()

void GPIO_base::print_bin ( uint8_t  v)
static

Definition at line 168 of file GPIO_NXP.cpp.

◆ read_port() [1/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
port_numOption, to specify port number
Returns
Register read value

Definition at line 158 of file GPIO_NXP.cpp.

◆ read_port() [2/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
vpPointer to an array of values. The array should have 'n_ports' length
Returns
Pointer to vp

Definition at line 110 of file GPIO_NXP.cpp.

Referenced by input().

◆ read_port16() [1/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
port_numOption, to specify port number
Returns
Register read value

Definition at line 163 of file GPIO_NXP.cpp.

◆ read_port16() [2/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
vpPointer to an array of values. The array should have 'n_ports' length
Returns
Pointer to vp

Definition at line 123 of file GPIO_NXP.cpp.

◆ write_port() [1/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
vpPointer to an array of values. The array should have 'n_ports' length

Definition at line 78 of file GPIO_NXP.cpp.

Referenced by config(), and output().

◆ write_port() [2/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
valueValue to be written into a register
port_numOption, to specify port number

Definition at line 148 of file GPIO_NXP.cpp.

◆ write_port16() [1/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
vpPointer to an array of values. The array should have 'n_ports' length

Definition at line 89 of file GPIO_NXP.cpp.

◆ write_port16() [2/2]

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'

Parameters
wAccsess word. This should be choosen from access_word'
valueValue to be written into a register
port_numOption, to specify port number

Definition at line 153 of file GPIO_NXP.cpp.

Member Data Documentation

◆ n_bits

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().

◆ n_ports

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().


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