Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newnewfeat/pca #198

Merged
merged 9 commits into from
Dec 5, 2024
Merged

Newnewfeat/pca #198

merged 9 commits into from
Dec 5, 2024

Conversation

rubennoro
Copy link
Contributor

Changes

Added write and read function pointers, and made i2c_handler of unspecified void* pointer so that it may point to enum that is used in HAL. Experiencing issues in the pdu.c that doesnt reflect these changes, but outside of that it works.

Notes

Any other notes go here

Test Cases

  • Case A
  • Edge case
  • ...

To Do

Any remaining things that need to get done

  • item 1
  • ...

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please reach out to your Project Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • All commits are tagged with the ticket number
  • No merge conflicts
  • All checks passing
  • Remove any non-applicable sections of this template
  • Assign the PR to yourself
  • Request reviewers & ping on Slack
  • PR is linked to the ticket (fill in the closes line below)

Closes #158 (issue #)

int pca9539_write_pin(pca9539_t *pca, uint8_t reg_type, uint8_t pin,
uint8_t buf);

/*IGNORE THIS CODE - SERVES AS A REFERENCE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this code if its unused

uint16_t dev_addr;
} pca9539_t;

/// Init PCA9539, a 16 bit I2C GPIO expander
void pca9539_init(pca9539_t *pca, I2C_HandleTypeDef *i2c_handle,
void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comments are missing. Use doxygen, javadoc style comments seen in other repos.

@@ -4,30 +4,112 @@

#define REG_SIZE_BITS 8

HAL_StatusTypeDef pca_write_reg(pca9539_t *pca, uint16_t address, uint8_t *data)
//RETURNS THE WRITE POINTER INSTEAD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is confusing

pca->dev_addr = dev_addr << 1u; shifted one to the left cuz STM says so
}
*/
//Read PCA9539 Register
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments aren't needed since they are already in the @brief section in the header file.

@@ -58,33 +51,30 @@ typedef struct {

void pca9539_init(pca9539_t *pca, WritePtr writeFunc, ReadPtr readFunc,
uint8_t dev_addr);
/**
* @brief Initialize the PCA9539 Driver
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These also need to include definitions for parameters and return types. If you use VScode, you should get the doxygen extension. It autofills all that stuff for you.

* @param pca
* @param writeFunc
* @param readFunc
* @param dev_addr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should write what each of these mean, even if its completely obvious. Follow how doxygen comments are done in other codebases, like Cerb.

@Sabramz Sabramz merged commit 6427e59 into main Dec 5, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Driver] - Make PCA95 driver platform agnostic
2 participants