Paparazzi UAS  v6.0_unstable-94-gda5b527-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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

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

#define PCA95XX_CLEAR_ALL   0x00

Definition at line 49 of file pca95xx.h.

#define PCA95XX_CONFIG_REG   (0x03)

Definition at line 38 of file pca95xx.h.

Referenced by pca95xx_configure().

#define PCA95XX_DEFAULT_ADDRESS   0x40

Definition at line 33 of file pca95xx.h.

Referenced by multi_ranger_init().

#define PCA95XX_INPUT_REG   (0x00)

Definition at line 35 of file pca95xx.h.

Referenced by pca95xx_get_input().

#define PCA95XX_OUTPUT_REG   (0x01)

Definition at line 36 of file pca95xx.h.

Referenced by pca95xx_set_output().

#define PCA95XX_P0   (1 << 0)

Definition at line 40 of file pca95xx.h.

#define PCA95XX_P1   (1 << 1)

Definition at line 41 of file pca95xx.h.

#define PCA95XX_P2   (1 << 2)

Definition at line 42 of file pca95xx.h.

#define PCA95XX_P3   (1 << 3)

Definition at line 43 of file pca95xx.h.

#define PCA95XX_P4   (1 << 4)

Definition at line 44 of file pca95xx.h.

#define PCA95XX_P5   (1 << 5)

Definition at line 45 of file pca95xx.h.

#define PCA95XX_P6   (1 << 6)

Definition at line 46 of file pca95xx.h.

#define PCA95XX_P7   (1 << 7)

Definition at line 47 of file pca95xx.h.

#define PCA95XX_POL_REG   (0x02)

Definition at line 37 of file pca95xx.h.

Function Documentation

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 i2c_transaction::buf, i2c_blocking_transmit(), pca95xx::i2c_p, pca95xx::i2c_trans, i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, PCA95XX_CONFIG_REG, i2c_transaction::slave_addr, i2c_transaction::status, 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:

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 i2c_transaction::buf, i2c_blocking_transceive(), pca95xx::i2c_p, pca95xx::i2c_trans, I2CTransDone, I2CTransFailed, I2CTransSuccess, PCA95XX_INPUT_REG, i2c_transaction::slave_addr, and i2c_transaction::status.

Referenced by gpio_ext_pca95xx_get().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 pca95xx::i2c_p, pca95xx::i2c_trans, I2CTransDone, i2c_transaction::slave_addr, and i2c_transaction::status.

Referenced by gpio_ext_pca95xx_lazy_init(), and multi_ranger_init().

+ Here is the caller graph for this function:

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 i2c_transaction::buf, i2c_blocking_transmit(), pca95xx::i2c_p, pca95xx::i2c_trans, i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, PCA95XX_OUTPUT_REG, i2c_transaction::slave_addr, and i2c_transaction::status.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: