- Notifications
You must be signed in to change notification settings - Fork1k
[breaking] SPI library rework#2171
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
5 commits Select commitHold shift + click to select a range
97bebdc
chore(SPI): remove deprecated WiFi library workaround
fpistm43ec3cb
chore(SPI): clean up internal CS pin managements
fpistm0ada13f
chore(SPI): remove non arduino transfer api with 2 buffer
fpistm392469a
chore(SPI): align with ArduinoCoreAPI
fpistm0a926cf
ci(example): update BareMinimun.ino
fpistmFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
36 changes: 17 additions & 19 deletionsCI/build/examples/BareMinimum/BareMinimum.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
93 changes: 43 additions & 50 deletionslibraries/SPI/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,63 @@ | ||
## SPI | ||
STM32 SPI library has been modified with the possibility to managehardware CSpin linked to the SPIperipheral. | ||
_We do not describe here the [SPI Arduino API](https://www.arduino.cc/en/Reference/SPI) but the functionalities added._ | ||
User have 2 possibilities 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) | ||
* the user uses a hardware CS pin linked to the SPI peripheral | ||
### NewSPISetting parameter | ||
* `noReceive`: value can be `SPI_TRANSMITRECEIVE` or `SPI_TRANSMITONLY`. It allows to skip receive data after transmitting. Default `SPI_TRANSMITRECEIVE`. | ||
### New API functions | ||
* `SPIClass::SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)`: alternative class constructor | ||
_Params_ SPI `mosi` pin | ||
_Params_ SPI `miso` pin | ||
_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. | ||
* `SPI_HandleTypeDef *getHandle(void)`: Could be used to mix Arduino API and STM32Cube HAL API (ex: DMA). **Use at your own risk.** | ||
##### Example | ||
This is an example of the use of the hardware CS pin linked to the SPI peripheral: | ||
```C++ | ||
#include <SPI.h> | ||
// MOSI MISO SCLK SSEL | ||
SPIClass SPI_3(PC12, PC11, PC10, PC9); | ||
void setup() { | ||
SPI_3.begin(); // Enable the SPI_3 instance with default SPISsettings | ||
SPI_3.beginTransaction(settings); // Configure the SPI_3 instance with other settings | ||
SPI_3.transfer(0x52); // Transfers data to the first device | ||
SPI_3.end() //SPI_3 instance is disabled | ||
} | ||
``` | ||
#### Change default `SPI` instance pins | ||
It is also possible to change the default pins used by the `SPI` instance using above API: | ||
[[/img/Warning-icon.png|alt="Warning"]] **Have to be called before `begin()`.** | ||
* `void setMISO(uint32_t miso)` | ||
* `void setMOSI(uint32_t mosi)` | ||
* `void setSCLK(uint32_t sclk)` | ||
* `void setSSEL(uint32_t ssel)` | ||
* `void setMISO(PinName miso)` | ||
* `void setMOSI(PinName mosi)` | ||
* `void setSCLK(PinName sclk)` | ||
* `void setSSEL(PinName ssel)` | ||
**_Note 1_** Using `setSSEL()` allows to enable hardwareCS pin management linked to the SPI peripheral. | ||
##### Example: | ||
```C++ | ||
SPI.setMISO(PC_4); // using pin name PY_n | ||
SPI.setMOSI(PC2); // using pin number PYn | ||
SPI.begin(2); | ||
``` |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.