Skip to content

Commit

Permalink
fixed structure
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Jan 13, 2025
1 parent d49130c commit f6e6798
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions general/include/pca9539.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ PCA 9539 16 bit GPIO expander. Datasheet: https://www.ti.com/lit/ds/symlink/pca
* @brief Pointer to write function
*
*/
typedef uint8_t (*WritePtr)(uint16_t dev_addr, uint8_t reg, uint8_t *data,
uint8_t size);
typedef uint8_t (*PCA_Write)(uint16_t dev_addr, uint8_t reg, uint8_t *data,
uint8_t size);

/**
* @brief Pointer to read function
*
*/
typedef uint8_t (*ReadPtr)(uint16_t dev_addr, uint8_t reg, uint8_t *data,
uint8_t size);
typedef uint8_t (*PCA_Read)(uint16_t dev_addr, uint8_t reg, uint8_t *data,
uint8_t size);

typedef struct {
WritePtr write;
ReadPtr read;
PCA_Write write;
PCA_Read read;

uint16_t dev_addr;
} pca9539_t;
Expand All @@ -64,7 +64,7 @@ typedef struct {
* @param readFunc function pointer to HAL specific read func
* @param dev_addr i2c device address
*/
void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
void pca9539_init(pca9539_t *pca, PCA_Write writeFunc, PCA_Read readFunc,
uint8_t dev_addr);

/**
Expand Down
6 changes: 3 additions & 3 deletions general/src/pca9539.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

#define REG_SIZE_BITS 8

int pca_write_reg(pca9539_t *pca, uint8_t address, uint8_t *data)
static int pca_write_reg(pca9539_t *pca, uint8_t address, uint8_t *data)
{
return pca->write(pca->dev_addr, address, data, 1);
}

int pca_read_reg(pca9539_t *pca, uint8_t address, uint8_t *data)
static int pca_read_reg(pca9539_t *pca, uint8_t address, uint8_t *data)
{
return pca->read(pca->dev_addr, address, data, 1);
}

void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
void pca9539_init(pca9539_t *pca, PCA_Write writeFunc, PCA_Read readFunc,
uint8_t dev_addr)
{
pca->dev_addr = dev_addr << 1u;
Expand Down

0 comments on commit f6e6798

Please sign in to comment.