-
Notifications
You must be signed in to change notification settings - Fork 1k
Improve SPI library code understanding #161
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
Conversation
Thanks @fprwi6labs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this update.
Some typo to fix before merge. Else ok for me.
libraries/SPI/README.md
Outdated
_We do not describe here the [SPI Arduino API](https://www.arduino.cc/en/Reference/SPI) but the functionalities added._ | ||
|
||
We give to the user 3 possiblities about the management of the CS pin: | ||
* the CS pin is managed directly by the user code before to transfer the data (like the Arduino SPI library) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numbering:
1.
2.
3.
Remove the 'or'.
libraries/SPI/README.md
Outdated
|
||
### New API functions | ||
|
||
* **SPIClass::SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)**: alternative class constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use code formatter
SPIClass::SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)
: alternative class constructor
libraries/SPI/README.md
Outdated
_Params_ SPI sclk pin | ||
_Params_ (optional) SPI ssel pin. This pin must be an hardware CS pin. If you configure this pin, the chip select will be managed by the SPI peripheral. Do not use API functions with CS pin in parameter. | ||
|
||
* **void SPIClass::begin(uint8_t _pin)**: initialize the SPI interface and add a CS pin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
libraries/SPI/README.md
Outdated
* **void SPIClass::begin(uint8_t _pin)**: initialize the SPI interface and add a CS pin | ||
_Params_ spi CS pin to be managed by the SPI library | ||
|
||
* **void beginTransaction(uint8_t pin, SPISettings settings)**: allows to configure the SPI with other parameter. These new parameter are saved this an associated CS pin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
libraries/SPI/README.md
Outdated
_Params_ SPI CS pin to be managed by the SPI library | ||
_Params_ SPI settings | ||
|
||
* **void endTransaction(uint8_t pin)**: removes a CS pin and the SPI settings associated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
libraries/SPI/src/SPI.cpp
Outdated
* @param _count: number of bytes to send/receive. | ||
* @param _mode: (optional) can be SPI_CONTINUE in case of multiple successive | ||
* send or SPI_LAST to indicate the end of send. | ||
* If the _mode is set to SPI_CONTINUE, keep the spi instance alive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spi -> SPI
libraries/SPI/src/SPI.cpp
Outdated
* @param _count: number of bytes to send/receive. | ||
* @param _mode: (optional) can be SPI_CONTINUE in case of multiple successive | ||
* send or SPI_LAST to indicate the end of send. | ||
* If the _mode is set to SPI_CONTINUE, keep the spi instance alive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spi -> SPI
libraries/SPI/src/SPI.cpp
Outdated
* another one will contains the data received. begin() or | ||
* beginTransaction() must be called at least once before. | ||
* @param _pin: CS pin to select a device (optional). If the previous transfer | ||
* used another CS pin then the spi instance will be reconfigured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spi -> SPI
libraries/SPI/src/SPI.cpp
Outdated
* @brief Transfer several bytes. Only one buffer used to send and receive data. | ||
* begin() or beginTransaction() must be called at least once before. | ||
* @param _pin: CS pin to select a device (optional). If the previous transfer | ||
* used another CS pin then the spi instance will be reconfigured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spi -> SPI
libraries/SPI/src/SPI.h
Outdated
void setClockDivider(uint8_t _div) { | ||
setClockDivider(CS_PIN_CONTROLLED_BY_USER, _div); | ||
} | ||
// Not implemented functions. Keep for compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backward compatibility
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry missed one typo.
libraries/SPI/src/SPI.h
Outdated
void setClockDivider(uint8_t _div) { | ||
setClockDivider(CS_PIN_CONTROLLED_BY_USER, _div); | ||
} | ||
// Not implemented functions. Keep for backward compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: fpr <[email protected]>
Improve SPI library code understanding
Try to improve the clarity of the SPI library code after the feedback #157