Skip to content

Commit a743cd5

Browse files
committed
fix: typo
Fixes #2356 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 3a00985 commit a743cd5

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

API.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ As each pin has not the same capabilities, it uses the best way:
8383
```C
8484
// Assuming Ax pins have PWM capabilities and use a different Timer.
8585
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
8787
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
8989
analogWrite(A3, 192); // Start PWM on A3, at 500 Hz with 75% duty cycle
9090
```
9191
@@ -327,7 +327,64 @@ This part describes the STM32 libraries provided with the core.
327327

328328
## SPI
329329

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.
381+
382+
##### Example:
383+
```C++
384+
SPI.setMISO(PC_4); // using pin name PY_n
385+
SPI.setMOSI(PC2); // using pin number PYn
386+
SPI.begin(2);
387+
```
331388

332389
## I2C
333390

0 commit comments

Comments
 (0)