Skip to content

Commit

Permalink
added doxygen comments, removed unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Noroian committed Nov 28, 2024
1 parent 57ef881 commit d6679ec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
53 changes: 45 additions & 8 deletions general/include/pca9539.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ PCA 9539 16 bit GPIO expander. Datasheet: https://www.ti.com/lit/ds/symlink/pca
#define PCA_DIRECTION_0_REG 0x06
#define PCA_DIRECTION_1_REG 0x07

/**
* @brief Pointer to write function
*
*/
typedef int (*WritePtr)(uint16_t dev_addr, uint16_t mem_address,
uint16_t mem_add_size, uint8_t *data, uint16_t size,
int delay);

/**
* @brief Pointer to read function
*
*/
typedef int (*ReadPtr)(uint16_t dev_addr, uint16_t mem_address,
uint16_t mem_add_size, uint8_t *data, uint16_t size,
int delay);
Expand All @@ -49,32 +58,60 @@ typedef struct {
uint16_t dev_addr;
} pca9539_t;

void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
uint8_t dev_addr);
/**
* @brief Initialize the PCA9539 Driver
*
* @param pca
* @param writeFunc
* @param readFunc
* @param 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);
/**
* @brief Read the register of the PCA9539
*
* @param pca
* @param reg_type
* @param buf
* @return int
*/
int pca9539_read_reg(pca9539_t *pca, uint8_t reg_type, uint8_t *buf);

int pca9539_read_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t *buf);
/**
* @brief Read the pin state of the PCA9539
*
* @param pca
* @param reg_type
* @param pin
* @param buf
* @return int
*/
int pca9539_read_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t *buf);

int pca9539_write_reg(pca9539_t *pca, uint8_t reg_type, uint8_t buf);
/**
* @brief Write the register of the PCA9539
*
* @param pca
* @param reg_type
* @param buf
* @return int
*/
int pca9539_write_reg(pca9539_t *pca, uint8_t reg_type, uint8_t buf);

int pca9539_write_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t buf);
/**
* @brief Write the pin of the PCA9539
*
* @param pca
* @param reg_type
* @param pin
* @param buf
* @return int
*/
int pca9539_write_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t buf);

#endif
7 changes: 0 additions & 7 deletions general/src/pca9539.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#define REG_SIZE_BITS 8

//Write Register returns the Write Function Pointer
int pca_write_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
{
//Parameters in the HAL Function
Expand All @@ -16,7 +15,6 @@ int pca_write_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
delay);
}

//Read Register returns the Read Function Pointer
int pca_read_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
{
uint16_t mem_add_size = 8;
Expand All @@ -27,7 +25,6 @@ int pca_read_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
delay);
}

//Intializes the struct
void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
uint8_t dev_addr)
{
Expand All @@ -37,7 +34,6 @@ void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
pca->read = readFunc;
}

//Read PCA9539 Register
int pca9539_read_reg(pca9539_t *pca, uint8_t reg_type, uint8_t *buf)
{
int status = pca_read_reg(pca, reg_type, buf);
Expand All @@ -48,7 +44,6 @@ int pca9539_read_reg(pca9539_t *pca, uint8_t reg_type, uint8_t *buf)
return status;
}

//Read PCA9539 Pin
int pca9539_read_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t *buf)
{
Expand All @@ -63,13 +58,11 @@ int pca9539_read_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
return status;
}

//Write PCA9539 Register
int pca9539_write_reg(pca9539_t *pca, uint8_t reg_type, uint8_t buf)
{
return pca_write_reg(pca, reg_type, &buf);
}

//Write PCA9539 Pin
int pca9539_write_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t buf)
{
Expand Down

0 comments on commit d6679ec

Please sign in to comment.