diff --git a/Core/Src/pdu.c b/Core/Src/pdu.c index 33a0cf4..22f26f8 100644 --- a/Core/Src/pdu.c +++ b/Core/Src/pdu.c @@ -19,6 +19,30 @@ static osMutexAttr_t pdu_mutex_attributes; +//hi2c2 variable to pass to the function wrappers +extern I2C_HandleTypeDef hi2c2; + +//Function wrapper for the STM specific HAL write function +//Serves as function pointer for PCA PAL +static inline int pca_i2c_write(uint16_t dev_addr, uint16_t address, + uint16_t mem_add_size, uint8_t *data, + uint16_t size, int delay) + +{ + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, + size, delay); +} + +//Function wrapper for the STM specific HAL read function +//Serves as function pointer for PCA PAL +static inline int pca_i2c_read(uint16_t dev_addr, uint16_t address, + uint16_t mem_add_size, uint8_t *data, + uint16_t size, int delay) +{ + return HAL_I2C_Mem_Write(&hi2c2, dev_addr, address, mem_add_size, data, + size, delay); +} + static uint8_t sound_rtds(pdu_t *pdu) { if (!pdu) @@ -129,7 +153,10 @@ pdu_t *init_pdu(I2C_HandleTypeDef *hi2c) /* Initialize Control GPIO Expander */ pdu->ctrl_expander = malloc(sizeof(pca9539_t)); assert(pdu->ctrl_expander); - pca9539_init(pdu->ctrl_expander, pdu->hi2c, CTRL_ADDR); + + //NEED + pca9539_init(pdu->ctrl_expander, pca_i2c_write, pca_i2c_read, + CTRL_ADDR); // write everything OFF, FAULT 1 is off uint8_t buf = 0b00000010; diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 970cceb..3bb4e77 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 970cceb6d6589c23d21ff6e3d2c29696973902ff +Subproject commit 3bb4e772c7f8dabb728d40da849ac2d661df4ce8