Skip to content

Commit

Permalink
removing the i2c_handler, preping for cerb changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Noroian committed Nov 10, 2024
1 parent dbf5358 commit c526b7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions general/include/pca9539.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ PCA 9539 16 bit GPIO expander. Datasheet: https://www.ti.com/lit/ds/symlink/pca
//return HAL_I2C_Mem_Write(pca->i2c_handle, pca->dev_addr, address,
//I2C_MEMADD_SIZE_8BIT, data, 1, HAL_MAX_DELAY);

typedef int (*WritePtr)(void *handler, uint16_t dev_addr, uint16_t mem_address,
typedef int (*WritePtr)(uint16_t dev_addr, uint16_t mem_address,
uint16_t mem_add_size, uint8_t *data, uint16_t size,
int delay);
typedef int (*ReadPtr)(void *handler, uint16_t dev_addr, uint16_t mem_address,
typedef int (*ReadPtr)(uint16_t dev_addr, uint16_t mem_address,
uint16_t mem_add_size, uint8_t *data, uint16_t size,
int delay);

typedef struct {
//int i2c_handler;
void *i2c_handler;
//void *i2c_handler;
//I2C_HandleTypeDef *i2c_handle;

WritePtr write;
Expand All @@ -56,8 +56,8 @@ typedef struct {
uint16_t dev_addr;
} pca9539_t;

void pca9539_init(pca9539_t *pca, void *i2c_handler, WritePtr writeFunc,
ReadPtr readFunc, uint8_t dev_addr);
void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
uint8_t dev_addr);

int pca9539_read_reg(pca9539_t *pca, uint8_t reg_type, uint8_t *buf);

Expand Down
14 changes: 7 additions & 7 deletions general/src/pca9539.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ int pca_write_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
uint16_t data_size = 1;
int delay = 0xFFFFFFFFU;

return pca->write(pca->i2c_handler, pca->dev_addr, address,
mem_add_size, data, data_size, delay);
return pca->write(pca->dev_addr, address, mem_add_size, data, data_size,
delay);
}

/*IGNORE THIS CODE - LEFT AS A REFERENCE
Expand All @@ -30,8 +30,8 @@ int pca_read_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
uint16_t data_size = 1;
int delay = 0xFFFFFFFFU;

return pca->read(pca->i2c_handler, pca->dev_addr, address, mem_add_size,
data, data_size, delay);
return pca->read(pca->dev_addr, address, mem_add_size, data, data_size,
delay);
}

/* IGNORE THIS CODE - LEFT AS A REFERENCE
Expand All @@ -43,10 +43,10 @@ HAL_StatusTypeDef pca_read_reg(pca9539_t* pca, uint16_t address, uint8_t* data)
}*/

//Intializes the struct
void pca9539_init(pca9539_t *pca, void *i2c_handler, WritePtr writeFunc,
ReadPtr readFunc, uint8_t dev_addr)
void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
uint8_t dev_addr)
{
pca->i2c_handler = i2c_handler;
//pca->i2c_handler = i2c_handler;
pca->dev_addr = dev_addr << 1u;

pca->write = writeFunc;
Expand Down

0 comments on commit c526b7c

Please sign in to comment.