Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
pca95xx.h File Reference

Driver for the 8-bit I/O expander based on i2c. More...

#include "std.h"
#include "mcu_periph/i2c.h"
+ Include dependency graph for pca95xx.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pca95xx
 PCA95XX structure. More...
 

Macros

#define PCA95XX_DEFAULT_ADDRESS   0x40
 
#define PCA95XX_INPUT_REG   (0x00)
 
#define PCA95XX_OUTPUT_REG   (0x01)
 
#define PCA95XX_POL_REG   (0x02)
 
#define PCA95XX_CONFIG_REG   (0x03)
 
#define PCA95XX_P0   (1 << 0)
 
#define PCA95XX_P1   (1 << 1)
 
#define PCA95XX_P2   (1 << 2)
 
#define PCA95XX_P3   (1 << 3)
 
#define PCA95XX_P4   (1 << 4)
 
#define PCA95XX_P5   (1 << 5)
 
#define PCA95XX_P6   (1 << 6)
 
#define PCA95XX_P7   (1 << 7)
 
#define PCA95XX_CLEAR_ALL   0x00
 

Functions

void pca95xx_init (struct pca95xx *dev, struct i2c_periph *i2c_p, uint8_t addr)
 Init PCA95XX. More...
 
bool pca95xx_configure (struct pca95xx *dev, uint8_t val, bool blocking)
 Configure PCA95XX. More...
 
bool pca95xx_set_output (struct pca95xx *dev, uint8_t mask, bool blocking)
 Set output value. More...
 
bool pca95xx_get_input (struct pca95xx *dev, uint8_t mask, uint8_t *result)
 Get input value. More...
 

Detailed Description

Driver for the 8-bit I/O expander based on i2c.

Definition in file pca95xx.h.


Data Structure Documentation

◆ pca95xx

struct pca95xx

PCA95XX structure.

Definition at line 53 of file pca95xx.h.

+ Collaboration diagram for pca95xx:
Data Fields
struct i2c_periph * i2c_p
struct i2c_transaction i2c_trans

Macro Definition Documentation

◆ PCA95XX_CLEAR_ALL

#define PCA95XX_CLEAR_ALL   0x00

Definition at line 49 of file pca95xx.h.

◆ PCA95XX_CONFIG_REG

#define PCA95XX_CONFIG_REG   (0x03)

Definition at line 38 of file pca95xx.h.

◆ PCA95XX_DEFAULT_ADDRESS

#define PCA95XX_DEFAULT_ADDRESS   0x40

Definition at line 33 of file pca95xx.h.

◆ PCA95XX_INPUT_REG

#define PCA95XX_INPUT_REG   (0x00)

Definition at line 35 of file pca95xx.h.

◆ PCA95XX_OUTPUT_REG

#define PCA95XX_OUTPUT_REG   (0x01)

Definition at line 36 of file pca95xx.h.

◆ PCA95XX_P0

#define PCA95XX_P0   (1 << 0)

Definition at line 40 of file pca95xx.h.

◆ PCA95XX_P1

#define PCA95XX_P1   (1 << 1)

Definition at line 41 of file pca95xx.h.

◆ PCA95XX_P2

#define PCA95XX_P2   (1 << 2)

Definition at line 42 of file pca95xx.h.

◆ PCA95XX_P3

#define PCA95XX_P3   (1 << 3)

Definition at line 43 of file pca95xx.h.

◆ PCA95XX_P4

#define PCA95XX_P4   (1 << 4)

Definition at line 44 of file pca95xx.h.

◆ PCA95XX_P5

#define PCA95XX_P5   (1 << 5)

Definition at line 45 of file pca95xx.h.

◆ PCA95XX_P6

#define PCA95XX_P6   (1 << 6)

Definition at line 46 of file pca95xx.h.

◆ PCA95XX_P7

#define PCA95XX_P7   (1 << 7)

Definition at line 47 of file pca95xx.h.

◆ PCA95XX_POL_REG

#define PCA95XX_POL_REG   (0x02)

Definition at line 37 of file pca95xx.h.

Function Documentation

◆ pca95xx_configure()

bool pca95xx_configure ( struct pca95xx dev,
uint8_t  val,
bool  blocking 
)

Configure PCA95XX.

Parameters
[in]devaddress to pca95xx device
[in]valvalue to write to confi register
[in]blockingtrue for blocking i2c transaction
Returns
false if i2c was not ready or transaction submit fails or timeout (blocking)

Definition at line 42 of file pca95xx.c.

References blocking, dev, i2c_blocking_transmit(), i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, PCA95XX_CONFIG_REG, and val.

Referenced by gpio_ext_pca95xx_lazy_init(), gpio_ext_pca95xx_setup_input(), gpio_ext_pca95xx_setup_output(), multi_ranger_init(), and multi_ranger_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pca95xx_get_input()

bool pca95xx_get_input ( struct pca95xx dev,
uint8_t  mask,
uint8_t result 
)

Get input value.

Parameters
[in]devaddress to pca95xx device
[in]maskinput pins
[out]inputregister with mask applied Note: always blocking
Returns
false if i2c was not ready or transaction submit fails or timeout (blocking)

Definition at line 78 of file pca95xx.c.

References dev, i2c_blocking_transceive(), I2CTransDone, I2CTransFailed, I2CTransSuccess, and PCA95XX_INPUT_REG.

Referenced by gpio_ext_pca95xx_get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pca95xx_init()

void pca95xx_init ( struct pca95xx dev,
struct i2c_periph i2c_p,
uint8_t  addr 
)

Init PCA95XX.

Parameters
[in]devaddress to pca95xx device
[in]i2c_paddres of i2c bus
[in]addri2c address

Definition at line 30 of file pca95xx.c.

References dev, and I2CTransDone.

Referenced by gpio_ext_pca95xx_lazy_init(), and multi_ranger_init().

+ Here is the caller graph for this function:

◆ pca95xx_set_output()

bool pca95xx_set_output ( struct pca95xx dev,
uint8_t  mask,
bool  blocking 
)

Set output value.

Parameters
[in]devaddress to pca95xx device
[in]maskoutput pins to set
[in]blockingtrue for blocking i2c transaction
Returns
false if i2c was not ready or transaction submit fails or timeout (blocking)

Definition at line 60 of file pca95xx.c.

References blocking, dev, i2c_blocking_transmit(), i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, and PCA95XX_OUTPUT_REG.

Referenced by gpio_ext_pca95xx_clear(), gpio_ext_pca95xx_set(), multi_ranger_init(), and multi_ranger_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: