adafruit / Adafruit_BusIO

Arduino library for I2C & SPI abstractions
MIT License
285 stars 259 forks source link

write method parameter const-ness #84

Closed yilungao closed 2 years ago

yilungao commented 2 years ago

fix https://github.com/adafruit/Adafruit_FRAM_SPI/issues/25

Scope: added const keyword to the following two methods in the Adafruit_SPIDevice class: bool write(const uint8_t *buffer, size_t len, const uint8_t *prefix_buffer = NULL, size_t prefix_len = 0); bool write_then_read(const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len, uint8_t sendvalue = 0xFF);

I was only able to test the modified code with ESP32 DevKitC (espressif) and the Adafruit SPI Non-Volatile FRAM Breakout - 64Kbit / 8KByte (MB85RS64V). This means the else part (i.e. non-esp32 arduino MCUs) of the following code is not tested.

https://github.com/adafruit/Adafruit_BusIO/blob/1741708a6ae80a9805f35f69ab7ed7787a252825/Adafruit_SPIDevice.cpp#L306-L323

Also, I wasn't able to run a test write_then_read on a mcu.

ladyada commented 2 years ago

hiya! thanks so much for submitting a PR! we can review & merge PRs once they have passed continuous integration (CI). that means that code compiles cleanly for all tested platforms, is clang formatted so we maintain the same text formatting for all new code, and is doxygen documented. if your code isnt passing, check the CI output (click on the red X next to the PR to scroll through the log and find where the error is

here is a tutorial on doxygen: https://learn.adafruit.com/the-well-automated-arduino-library/doxygen

and clang-format: https://learn.adafruit.com/the-well-automated-arduino-library/formatting-with-clang-format

and overall how to contribute PRs to libraries: https://learn.adafruit.com/contribute-to-arduino-with-git-and-github

once you get that green checkmark that indicates CI has passed, please comment reply to this post so we know its time for another review (we may not get notified on CI pass and miss that its time to look!)

yilungao commented 2 years ago

Thanks @ladyada for the info. My first commit failed at clang, which made sense as I didn't apply clang-format. My second commit failed at pre-install. Any thoughts how I can resolve the following? The only change I made was clang-formatting my change.

E: Unable to locate package libllvm8 Error: Process completed with exit code 100.

@hathach FYI in case I can get any help from you. Thanks!

hathach commented 2 years ago

it is probably github network issue, I just re-run the job.