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

#include <GPIO_NXP.h>

Inheritance diagram for PCAL9722:
PCAL97xx_base GPIO_SPI GPIO_base

Public Types

enum  reg_num {
  Input_Port_0 , Input_Port_1 , Input_Port_2 , reserved0 ,
  Output_Port_0 , Output_Port_1 , Output_Port_2 , reserved1 ,
  Polarity_Inversion_port_0 , Polarity_Inversion_port_1 , Polarity_Inversion_port_2 , reserved2 ,
  Configuration_port_0 , Configuration_port_1 , Configuration_port_2 , Output_drive_strength_register_port_0A =0x40 ,
  Output_drive_strength_register_port_0B , Output_drive_strength_register_port_1A , Output_drive_strength_register_port_1B , Output_drive_strength_register_port_2A ,
  Output_drive_strength_register_port_2B , reserved3 , reserved4 , Input_latch_register_port_0 ,
  Input_latch_register_port_1 , Input_latch_register_port_2 , reserved5 , Pull_up_pull_down_enable_register_port_0 ,
  Pull_up_pull_down_enable_register_port_1 , Pull_up_pull_down_enable_register_port_2 , reserved6 , Pull_up_pull_down_selection_register_port_0 ,
  Pull_up_pull_down_selection_register_port_1 , Pull_up_pull_down_selection_register_port_2 , reserved7 , Interrupt_mask_register_port_0 ,
  Interrupt_mask_register_port_1 , Interrupt_mask_register_port_2 , reserved8 , Interrupt_status_register_port_0 ,
  Interrupt_status_register_port_1 , Interrupt_status_register_port_2 , reserved9 , Output_port_configuration_register ,
  reserved10 , reserved11 , reserved12 , Interrupt_edge_register_port_0A ,
  Interrupt_edge_register_port_0B , Interrupt_edge_register_port_1A , Interrupt_edge_register_port_1B , Interrupt_edge_register_port_2A ,
  Interrupt_edge_register_port_2B , reserved13 , reserved14 , Interrupt_clear_register_port_0 ,
  Interrupt_clear_register_port_1 , Interrupt_clear_register_port_2 , reserved15 , Input_status_port_0 ,
  Input_status_port_1 , Input_status_port_2 , reserved16 , Individual_pin_output_port_0_configuration_register ,
  Individual_pin_output_port_1_configuration_register , Individual_pin_output_port_2_configuration_register , reserved17 , Switch_debounce_enable_0 ,
  Switch_debounce_enable_1 , Switch_debounce_count
}
 
enum  board { NONE , ARDUINO_SHIELD }
 
- Public Types inherited from GPIO_base
enum  board { NONE , ARDUINO_SHIELD }
 

Public Member Functions

 PCAL9722 (uint8_t dev_address=(0x40 > > 1)+0)
 
virtual ~PCAL9722 ()
 
void begin (board env=NONE)
 
void output (int port, uint8_t value, uint8_t mask=0)
 
void output (const 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 (const uint8_t *vp)
 
void write_port (access_word w, const uint8_t *vp)
 
void write_port16 (access_word w, const 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)
 
int reg_w (uint8_t reg_adr, const uint8_t *data, uint16_t size)
 
int reg_w (uint8_t reg_adr, uint8_t data)
 
int reg_r (uint8_t reg_adr, uint8_t *data, uint16_t size)
 
uint8_t reg_r (uint8_t reg_adr)
 
void write_r8 (uint8_t reg, uint8_t val)
 
void write_r16 (uint8_t reg, uint16_t val)
 
uint8_t read_r8 (uint8_t reg)
 
uint16_t read_r16 (uint8_t reg)
 
void bit_op8 (uint8_t reg, uint8_t mask, uint8_t value)
 
void bit_op16 (uint8_t reg, uint16_t mask, uint16_t value)
 
- Public Member Functions inherited from PCAL97xx_base
 PCAL97xx_base (uint8_t dev_address, const int nbits, const uint8_t arp[], uint8_t ai)
 
- Public Member Functions inherited from GPIO_SPI
 GPIO_SPI (uint8_t device_address, int nbits, const uint8_t *arp, uint8_t ai)
 
virtual ~GPIO_SPI ()
 
- Public Member Functions inherited from GPIO_base
 GPIO_base (uint8_t i2c_address, int nbits, const uint8_t *arp, uint8_t ai)
 
 GPIO_base (TwoWire &wire, uint8_t i2c_address, int nbits, const uint8_t *arp, uint8_t ai)
 
virtual ~GPIO_base ()
 
virtual void begin (board env=NONE)
 

Public Attributes

const int n_bits
 
const int n_ports
 
- Public Attributes inherited from GPIO_base
const int n_bits
 
const int n_ports
 

Static Public Attributes

static constexpr uint8_t access_ref [NUM_access_word]
 

Additional Inherited Members

- Static Public Member Functions inherited from GPIO_base
static void print_bin (uint8_t v)
 
- Protected Attributes inherited from GPIO_base
const uint8_t auto_increment
 

Detailed Description

PCAL9722 class

Definition at line 2095 of file GPIO_NXP.h.

Member Enumeration Documentation

◆ board

Constants for begin() method

Definition at line 2165 of file GPIO_NXP.h.

◆ reg_num

Name of the PCAL9722 registers

Definition at line 2099 of file GPIO_NXP.h.

Constructor & Destructor Documentation

◆ PCAL9722()

PCAL9722::PCAL9722 ( uint8_t dev_address = (0x40 >> 1) + 0)

Constractor

Parameters
interfaceI2C instance
i2c_addressI2C target address

Definition at line 406 of file GPIO_NXP.cpp.

◆ ~PCAL9722()

PCAL9722::~PCAL9722 ( )
virtual

Destractor

Definition at line 411 of file GPIO_NXP.cpp.

Member Function Documentation

◆ begin()

void PCAL9722::begin ( board env = NONE)

Device/board initialization

This method is needed to initialize Arduino-shield type evaluation boards from NXP. This method takes one argument of "PCAL6534::ARDUINO_SHIELD" to set RESET and ADDRESS pins.

If the devoce is used as it self, this method doesn't need to be called.

Parameters
envThis argument can be given as "PCAL6534::NONE" ot "PCAL6534::ARDUINO_SHIELD"

Definition at line 415 of file GPIO_NXP.cpp.

◆ bit_op8()

void PCAL9722::bit_op8 ( uint8_t reg,
uint8_t mask,
uint8_t value )

Register overwriting with bit-mask

Register can be updated by bit level

Parameters
regregister index/address/pointer
maskbit-mask to protect overwriting
valuevalue to overwrite

◆ config() [1/2]

void PCAL9722::config ( const uint8_t * vp)
virtual

Config, all ports

Basic GPIO port access function for all port configuration

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

Reimplemented from GPIO_base.

◆ config() [2/2]

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

Config, single port

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

Reimplemented from GPIO_base.

◆ input() [1/2]

uint8_t PCAL9722::input ( int port)
virtual

Input, single port

Basic GPIO port access function for single port input

Parameters
portPort number
Returns
Port read value

Reimplemented from GPIO_base.

◆ input() [2/2]

uint8_t * PCAL9722::input ( uint8_t * vp)
virtual

Input, all ports

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

Reimplemented from GPIO_base.

◆ output() [1/2]

void PCAL9722::output ( const uint8_t * vp)
virtual

Output, all ports

Basic GPIO port access function for all ports output

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

Reimplemented from GPIO_base.

◆ output() [2/2]

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

Output, single port

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

Reimplemented from GPIO_base.

◆ read_port() [1/2]

uint8_t PCAL9722::read_port ( access_word w,
int port_num = 0 )
virtual

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

Reimplemented from GPIO_base.

◆ read_port() [2/2]

uint8_t * PCAL9722::read_port ( access_word w,
uint8_t * vp )
virtual

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

Reimplemented from GPIO_base.

◆ read_port16() [1/2]

uint16_t PCAL9722::read_port16 ( access_word w,
int port_num = 0 )
virtual

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

Reimplemented from GPIO_base.

◆ read_port16() [2/2]

uint16_t * PCAL9722::read_port16 ( access_word w,
uint16_t * vp )
virtual

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

Reimplemented from GPIO_base.

◆ read_r16()

uint16_t PCAL9722::read_r16 ( uint8_t reg)

Register read, 16 bit

This 16 bit access may ot be common but it's useful for sensor devices

Parameters
regregister index/address/pointer
Returns
data value

◆ read_r8()

uint8_t PCAL9722::read_r8 ( uint8_t reg)

Register read, 8 bit

Parameters
regregister index/address/pointer
Returns
data value

◆ reg_r() [1/2]

uint8_t PCAL9722::reg_r ( uint8_t reg_adr)
virtual

Single register read

Parameters
regregister index/address/pointer
Returns
read data

Reimplemented from GPIO_SPI.

◆ reg_r() [2/2]

int PCAL9722::reg_r ( uint8_t reg_adr,
uint8_t * data,
uint16_t size )
virtual

Multiple register read

Parameters
regregister index/address/pointer
datapointer to data buffer
sizedata size
Returns
transferred data size

Reimplemented from GPIO_SPI.

◆ reg_w() [1/2]

int PCAL9722::reg_w ( uint8_t reg_adr,
const uint8_t * data,
uint16_t size )
virtual

Multiple register write

Parameters
regregister index/address/pointer
datapointer to data buffer
sizedata size
Returns
transferred data size

Reimplemented from GPIO_SPI.

◆ reg_w() [2/2]

int PCAL9722::reg_w ( uint8_t reg_adr,
uint8_t data )
virtual

Single register write

Parameters
regregister index/address/pointer
datapointer to data buffer
sizedata size
Returns
transferred data size

Reimplemented from GPIO_SPI.

◆ write_port() [1/2]

void PCAL9722::write_port ( access_word w,
const uint8_t * vp )
virtual

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

Reimplemented from GPIO_base.

◆ write_port() [2/2]

void PCAL9722::write_port ( access_word w,
uint8_t value,
int port_num = 0 )
virtual

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

Reimplemented from GPIO_base.

◆ write_port16() [1/2]

void PCAL9722::write_port16 ( access_word w,
const uint16_t * vp )
virtual

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

Reimplemented from GPIO_base.

◆ write_port16() [2/2]

void PCAL9722::write_port16 ( access_word w,
uint16_t value,
int port_num = 0 )
virtual

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

Reimplemented from GPIO_base.

◆ write_r16()

void PCAL9722::write_r16 ( uint8_t reg,
uint16_t val )

Register write, 16 bit

This 16 bit access may ot be common but it's useful for sensor devices

Parameters
regregister index/address/pointer
valdata value

◆ write_r8()

void PCAL9722::write_r8 ( uint8_t reg,
uint8_t val )

Register write, 8 bit

Parameters
regregister index/address/pointer
valdata value

Member Data Documentation

◆ access_ref

constexpr uint8_t PCAL9722::access_ref
staticconstexpr
Initial value:
= {
Input_Port_0,
Output_Port_0,
Polarity_Inversion_port_0,
Configuration_port_0,
Output_drive_strength_register_port_0A,
Input_latch_register_port_0,
Pull_up_pull_down_enable_register_port_0,
Pull_up_pull_down_selection_register_port_0,
Interrupt_mask_register_port_0,
Interrupt_status_register_port_0,
Output_port_configuration_register,
}

Definition at line 2145 of file GPIO_NXP.h.

◆ n_bits

const int PCAL9722::n_bits

Number of IO bits

Definition at line 2171 of file GPIO_NXP.h.

◆ n_ports

const int PCAL9722::n_ports

Number of IO ports

Definition at line 2174 of file GPIO_NXP.h.


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