Loading...
Searching...
No Matches
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include "kernel_defines.h"
#include "periph/gpio.h"
#include "periph/i2c.h"
#include "saul/periph.h"
#include "event.h"
+ Include dependency graph for pcf857x.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pcf857x_params_t
 PCF857X device initialization parameters. More...
 
struct  pcf857x_irq_event_t
 IRQ event type. More...
 
struct  pcf857x_t
 PCF857X device data structure type. More...
 
struct  pcf857x_saul_gpio_params_t
 PCF857X configuration structure for mapping expander pins to SAUL. More...
 

Macros

#define PCF857X_GPIO_PIN(x, y)   (y)
 conversion of (port x : pin y) to a pin number
 

Enumerations

enum  pcf857x_error_codes_t {
  PCF857X_OK = 0 , PCF857X_ERROR_I2C = ENXIO , PCF857X_ERROR_INV_EXP = ENOTSUP , PCF857X_ERROR_INV_MODE = EINVAL ,
  PCF857X_ERROR_INV_FLANK = EINVAL , PCF857X_ERROR_INT_PIN = ENOSYS
}
 Definition of PCF857X driver error codes. More...
 
enum  pcf857x_exp_t { PCF857X_EXP_PCF8574 , PCF857X_EXP_PCF8574A , PCF857X_EXP_PCF8575 , PCF857X_EXP_MAX }
 Definition of PCF857X expander variants. More...
 

Functions

int pcf857x_init (pcf857x_t *dev, const pcf857x_params_t *params)
 Initialize the PCF857X I/O expander.
 
int pcf857x_gpio_init (pcf857x_t *dev, uint8_t pin, gpio_mode_t mode)
 Initialize a PCF857X pin.
 
int pcf857x_gpio_init_int (pcf857x_t *dev, uint8_t pin, gpio_mode_t mode, gpio_flank_t flank, gpio_cb_t isr, void *arg)
 Initialize a PCF857X pin for external interrupt usage.
 
int pcf857x_gpio_read (pcf857x_t *dev, uint8_t pin)
 Get the value from PCF857X input pin.
 
void pcf857x_gpio_write (pcf857x_t *dev, uint8_t pin, int value)
 Write the value to PCF857X input pin.
 
void pcf857x_gpio_clear (pcf857x_t *dev, uint8_t pin)
 Clear the PCF857X output pin.
 
void pcf857x_gpio_set (pcf857x_t *dev, uint8_t pin)
 Set the PCF857X output pin.
 
void pcf857x_gpio_toggle (pcf857x_t *dev, uint8_t pin)
 Toggle the value of the PCF857X output pin.
 
void pcf857x_gpio_irq_enable (pcf857x_t *dev, uint8_t pin)
 Enable pin interrupt.
 
void pcf857x_gpio_irq_disable (pcf857x_t *dev, uint8_t pin)
 Disable pin interrupt.
 

PCF857X I2C slave addresses

PCF857X I2C slave addresses are defined as an offset to a base address, which depends on the expander used.

The address offset is in the range of 0 to 7.

#define PCF8575_BASE_ADDR   (0x20)
 PCF8575 I2C slave base address.
 
#define PCF8574_BASE_ADDR   (0x20)
 PCF8574 I2C slave base address.
 
#define PCF8574A_BASE_ADDR   (0x38)
 PCF8574A I2C slave base address.
 

PCF857X I/O expander pin number

#define PCF8575_GPIO_PIN_NUM   (16)
 PCF8575 has 16 I/O pins.
 
#define PCF8574_GPIO_PIN_NUM   (8)
 PCF8574 has 8 I/O pins.
 
#define PCF8574A_GPIO_PIN_NUM   (8)
 PCF8574A has 8 I/O pins.
 

Module dependent definitions and declarations

#define PCF857X_GPIO_PIN_NUM   (16)
 Maximum number of GPIO pins.
 
typedef uint16_t pcf857x_data_t
 Data type that can mask all expander pins.