Paparazzi UAS  v5.15_devel-229-g3fb4ee4
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pca95x4.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 pca95x4.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pca95x4
 PCA95X4 structure. More...
 

Macros

#define PCA95X4_DEFAULT_ADDRESS   0x40
 
#define PCA95X4_INPUT_REG   (0x00)
 
#define PCA95X4_OUTPUT_REG   (0x01)
 
#define PCA95X4_POL_REG   (0x02)
 
#define PCA95X4_CONFIG_REG   (0x03)
 
#define PCA95X4_P0   (1 << 0)
 
#define PCA95X4_P1   (1 << 1)
 
#define PCA95X4_P2   (1 << 2)
 
#define PCA95X4_P3   (1 << 3)
 
#define PCA95X4_P4   (1 << 4)
 
#define PCA95X4_P5   (1 << 5)
 
#define PCA95X4_P6   (1 << 6)
 
#define PCA95X4_P7   (1 << 7)
 
#define PCA95X4_CLEAR_ALL   0x00
 

Functions

void pca95x4_init (struct pca95x4 *dev, struct i2c_periph *i2c_p, uint8_t addr)
 Init PCA95X4. More...
 
bool pca95x4_configure (struct pca95x4 *dev, uint8_t val, bool blocking)
 Configure PCA95X4. More...
 
bool pca95x4_set_output (struct pca95x4 *dev, uint8_t mask, bool blocking)
 Set output value. More...
 

Detailed Description

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

Definition in file pca95x4.h.


Data Structure Documentation

struct pca95x4

PCA95X4 structure.

Definition at line 53 of file pca95x4.h.

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

Macro Definition Documentation

#define PCA95X4_CLEAR_ALL   0x00

Definition at line 49 of file pca95x4.h.

#define PCA95X4_CONFIG_REG   (0x03)

Definition at line 38 of file pca95x4.h.

Referenced by pca95x4_configure().

#define PCA95X4_DEFAULT_ADDRESS   0x40

Definition at line 33 of file pca95x4.h.

Referenced by multi_ranger_init().

#define PCA95X4_INPUT_REG   (0x00)

Definition at line 35 of file pca95x4.h.

#define PCA95X4_OUTPUT_REG   (0x01)

Definition at line 36 of file pca95x4.h.

Referenced by pca95x4_set_output().

#define PCA95X4_P0   (1 << 0)

Definition at line 40 of file pca95x4.h.

#define PCA95X4_P1   (1 << 1)

Definition at line 41 of file pca95x4.h.

#define PCA95X4_P2   (1 << 2)

Definition at line 42 of file pca95x4.h.

#define PCA95X4_P3   (1 << 3)

Definition at line 43 of file pca95x4.h.

#define PCA95X4_P4   (1 << 4)

Definition at line 44 of file pca95x4.h.

#define PCA95X4_P5   (1 << 5)

Definition at line 45 of file pca95x4.h.

#define PCA95X4_P6   (1 << 6)

Definition at line 46 of file pca95x4.h.

#define PCA95X4_P7   (1 << 7)

Definition at line 47 of file pca95x4.h.

#define PCA95X4_POL_REG   (0x02)

Definition at line 37 of file pca95x4.h.

Function Documentation

bool pca95x4_configure ( struct pca95x4 dev,
uint8_t  val,
bool  blocking 
)

Configure PCA95X4.

Parameters
[in]devaddress to pca95x4 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 pca95x4.c.

References i2c_transaction::buf, i2c_blocking_transmit(), pca95x4::i2c_p, pca95x4::i2c_trans, i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, PCA95X4_CONFIG_REG, i2c_transaction::slave_addr, i2c_transaction::status, and val.

Referenced by multi_ranger_init(), and multi_ranger_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void pca95x4_init ( struct pca95x4 dev,
struct i2c_periph i2c_p,
uint8_t  addr 
)

Init PCA95X4.

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

Definition at line 30 of file pca95x4.c.

References pca95x4::i2c_p, pca95x4::i2c_trans, I2CTransDone, i2c_transaction::slave_addr, and i2c_transaction::status.

Referenced by multi_ranger_init().

+ Here is the caller graph for this function:

bool pca95x4_set_output ( struct pca95x4 dev,
uint8_t  mask,
bool  blocking 
)

Set output value.

Parameters
[in]devaddress to pca95x4 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 pca95x4.c.

References i2c_transaction::buf, i2c_blocking_transmit(), pca95x4::i2c_p, pca95x4::i2c_trans, i2c_transmit(), I2CTransDone, I2CTransFailed, I2CTransSuccess, PCA95X4_OUTPUT_REG, i2c_transaction::slave_addr, and i2c_transaction::status.

Referenced by multi_ranger_init(), and multi_ranger_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: