You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: API.md
+60-3Lines changed: 60 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -83,9 +83,9 @@ As each pin has not the same capabilities, it uses the best way:
83
83
```C
84
84
// Assuming Ax pins have PWM capabilities and use a different Timer.
85
85
analogWrite(A1, 127); // Start PWM on A1, at 1000 Hz with 50% duty cycle
86
-
analogWriteFrequency(2000); // Set PMW period to 2000 Hz instead of 1000
86
+
analogWriteFrequency(2000); // Set PWM period to 2000 Hz instead of 1000
87
87
analogWrite(A2, 64); // Start PWM on A2, at 2000 Hz with 25% duty cycle
88
-
analogWriteFrequency(500); // Set PMW period to 500 Hz
88
+
analogWriteFrequency(500); // Set PWM period to 500 Hz
89
89
analogWrite(A3, 192); // Start PWM on A3, at 500 Hz with 75% duty cycle
90
90
```
91
91
@@ -327,7 +327,64 @@ This part describes the STM32 libraries provided with the core.
327
327
328
328
## SPI
329
329
330
-
See [`SPI README.md`](../blob/main/libraries/SPI/README.md)
330
+
STM32 SPI library has been modified with the possibility to manage hardware CS pin linked to the SPI peripheral.
331
+
_We do not describe here the [SPI Arduino API](https://www.arduino.cc/en/Reference/SPI) but the functionalities added._
332
+
333
+
User have 2 possibilities about the management of the CS pin:
334
+
* the CS pin is managed directly by the user code before to transfer the data (like the Arduino SPI library)
335
+
* the user uses a hardware CS pin linked to the SPI peripheral
336
+
337
+
### New SPISetting parameter
338
+
339
+
*`noReceive`: value can be `SPI_TRANSMITRECEIVE` or `SPI_TRANSMITONLY`. It allows to skip receive data after transmitting.
340
+
341
+
### New API functions
342
+
343
+
*`SPIClass::SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)`: alternative class constructor
344
+
_Params_ SPI `mosi` pin
345
+
_Params_ SPI `miso` pin
346
+
_Params_ SPI `sclk` pin
347
+
_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.
348
+
349
+
##### Example
350
+
351
+
This is an example of the use of the hardware CS pin linked to the SPI peripheral:
352
+
353
+
```C++
354
+
#include<SPI.h>
355
+
// MOSI MISO SCLK SSEL
356
+
SPIClass SPI_3(PC12, PC11, PC10, PC9);
357
+
358
+
void setup() {
359
+
SPI_3.begin(); // Enable the SPI_3 instance with default SPISsettings
360
+
SPI_3.beginTransaction(settings); // Configure the SPI_3 instance with other settings
361
+
SPI_3.transfer(0x52); // Transfers data to the first device
362
+
SPI_3.end() //SPI_3 instance is disabled
363
+
}
364
+
```
365
+
366
+
#### Change default `SPI` instance pins
367
+
It is also possible to change the default pins used by the `SPI` instance using above API:
368
+
369
+
[[/img/Warning-icon.png|alt="Warning"]] **Have to be called before `begin()`.**
370
+
371
+
* `void setMISO(uint32_t miso)`
372
+
* `void setMOSI(uint32_t mosi)`
373
+
* `void setSCLK(uint32_t sclk)`
374
+
* `void setSSEL(uint32_t ssel)`
375
+
* `void setMISO(PinName miso)`
376
+
* `void setMOSI(PinName mosi)`
377
+
* `void setSCLK(PinName sclk)`
378
+
* `void setSSEL(PinName ssel)`
379
+
380
+
**_Note 1_** Using `setSSEL()` allows to enable hardware CS pin management linked to the SPI peripheral.
0 commit comments