From ed36495f584d944091406d042305868ff86a6140 Mon Sep 17 00:00:00 2001 From: Christian Lind Madsen Date: Mon, 29 Jan 2024 16:46:25 +0100 Subject: [PATCH] files added --- cm_pcf8574_driver.c | 21 +++++++++++++++++++++ cm_pcf8574_driver.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 cm_pcf8574_driver.c create mode 100644 cm_pcf8574_driver.h diff --git a/cm_pcf8574_driver.c b/cm_pcf8574_driver.c new file mode 100644 index 0000000..6fef72a --- /dev/null +++ b/cm_pcf8574_driver.c @@ -0,0 +1,21 @@ +/* + * cm_pcf8574_driver.c + * + * Created on: 29. jan. 2024 + * Author: Chris + */ +#include "cm_pcf8574_driver.h" + +int cm_pcf8574_RegTransEvt(cm_pcf8574_t inst, void i2c_inst, setGet_I2C_Event_fpt i2c_transfer_evt){ + + if(inst == NULL) return CM_PCF8574_NOK; + + inst->i2c_inst = i2c_inst; + inst->i2c_transfer_evt = i2c_transfer_evt; + + + + return CM_PCF8574_OK; + + +} diff --git a/cm_pcf8574_driver.h b/cm_pcf8574_driver.h new file mode 100644 index 0000000..161e015 --- /dev/null +++ b/cm_pcf8574_driver.h @@ -0,0 +1,44 @@ +/* + * cm_pcf8574_driver.h + * + * Created on: 29. jan. 2024 + * Author: Chris + */ + +#ifndef PCF8574_IO_EXPANDER_CM_PCF8574_DRIVER_H_ +#define PCF8574_IO_EXPANDER_CM_PCF8574_DRIVER_H_ + +enum{ + CM_PCF8574_OK = 0, + CM_PCF8574_NOK +}; + +typedef int (*setGet_I2C_Event_fpt)(void *inst, uint8_t *data, uint32_t len, uint8_t set_get); + + +typedef struct{ + + uint8_t B0 : 1; + uint8_t B1 : 1; + uint8_t B2 : 1; + uint8_t B3 : 1; + uint8_t B4 : 1; + uint8_t B5 : 1; + uint8_t B6 : 1; + uint8_t B7 : 1; + +}cm_io_port_t; + +typedef struct{ + void *i2c_inst; + setGet_I2C_Event_fpt i2c_transfer_evt; + + cm_io_port_t Port_1; + + +}cm_pcf8574_t; + +int cm_pcf8574_RegTransEvt(cm_pcf8574_t inst, void i2c_inst, setGet_I2C_Event_fpt i2c_transfer_evt); +int cm_pcf8574_init(cm_pcf8574_t *inst); + +#endif /* PCF8574_IO_EXPANDER_CM_PCF8574_DRIVER_H_ */