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

#83 - ADS131M04 Driver #108

Merged
merged 10 commits into from
Jun 4, 2024
Merged

#83 - ADS131M04 Driver #108

merged 10 commits into from
Jun 4, 2024

Conversation

RChandler234
Copy link
Contributor

@RChandler234 RChandler234 commented Apr 3, 2024

Changes

The basic interface for the driver, setting up some basic SPI, and initializing the ADC into continuous-conversion mode using the RESET command. Mainly trying to figure out whether I need to configure anything to get good readings from the ADC and the best way to read out the values generated by the ADC

Notes

data-ready interrupt signal, DRDY
The end of tPOR is indicated by a transition of DRDY from low to high. The transition of DRDY from low to
high also indicates the SPI interface is ready to accept commands.
Connect the DRDY pin to a digital input on the host to trigger periodic data retrieval in conversion mode.
The conversion status of all channels is available as the DRDY[3:0] bits in the
STATUS register. The STATUS register content is automatically output as the response to the NULL command.
SPI: The device defaults to a 24-bit word size.

Either strobe the SYNC/RESET pin to re-synchronize conversions and clear the
FIFOs, or quickly read two data packets when data are read for the first time or after a gap in reading data.
This process ensures predictable DRDY pin behavior.

Notes for self from data sheet:
image
image
image
image

Might be important:
image
image
image

Todo

  • Make sure I'm writing the SPI commands in the right format
  • Make sure everything is configured correctly to get good readings
  • Implement functionality to read out of the ADC

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 #83

@RChandler234 RChandler234 self-assigned this Apr 3, 2024
Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

Looks solid but you should prob add the actual code that does stuff lol

general/include/ADS131M04.h Outdated Show resolved Hide resolved
general/include/ADS131M04.h Outdated Show resolved Hide resolved
general/include/ADS131M04.h Outdated Show resolved Hide resolved
general/src/ADS131M04.c Outdated Show resolved Hide resolved
general/include/ADS131M04.h Outdated Show resolved Hide resolved
general/src/ADS131M04.c Outdated Show resolved Hide resolved
Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

Ngl i'm a lil confused about how a dev might interact with this API. An ideal driver willmake it so that the user doesn't have to read the data sheet at all for how data is formatted in the registers and such. Also the SPI transactions are a bit off, check comment

void ads131m04_send_command(ads131_t *adc, uint16_t cmd)
{
HAL_GPIO_WritePin(adc->gpio, adc->cs_pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(adc->spi, cmd, 1, HAL_MAX_DELAY);
Copy link
Contributor

Choose a reason for hiding this comment

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

So usually you gotta write the register and value in 1 set of transactions (i.e. set pin low, write spi, write spi, ... set pin high)

@RChandler234
Copy link
Contributor Author

image

@nwdepatie nwdepatie self-requested a review June 4, 2024 21:16
Copy link
Contributor

@nwdepatie nwdepatie left a comment

Choose a reason for hiding this comment

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

Made some changes but looks god to me rn, we'll validate it when HV proteus board is assembled

@nwdepatie nwdepatie merged commit bd77e75 into main Jun 4, 2024
1 check passed
@nwdepatie nwdepatie deleted the #83-ADS131M04-driver branch June 4, 2024 21:20
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] - ADS131M04 Driver
2 participants