Skip to content

Commit 05fb284

Browse files
committed
chore(docs): enhance libraries structure
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 05e2e32 commit 05fb284

8 files changed

Lines changed: 270 additions & 324 deletions

File tree

‎docs/API.md‎

Lines changed: 0 additions & 262 deletions
Original file line numberDiff line numberDiff line change
@@ -369,268 +369,6 @@ parity bit is also inverted.
369369
See the [HardwareTimer library reference](HardwareTimer-library.md) for the timer API and STM32-specific timer features.
370370

371371

372-
## Built-in libraries
373-
374-
This part describes the STM32 libraries provided with the core.
375-
376-
### SPI
377-
378-
STM32 SPI library has been modified with the possibility to manage hardware CS pin linked to the SPI peripheral.
379-
This section documents STM32-specific additions to the [standard SPI API](https://docs.arduino.cc/language-reference/en/functions/communication/SPI/).
380-
381-
There are two ways to manage the CS pin:
382-
383-
- the CS pin is managed directly by the user code before to transfer the data (like the Arduino SPI library)
384-
- the user uses a hardware CS pin linked to the SPI peripheral
385-
386-
#### New SPISetting parameter
387-
388-
* `noReceive`: value can be `SPI_TRANSMITRECEIVE` or `SPI_TRANSMITONLY`. It allows to skip receive data after transmitting.
389-
390-
#### New API functions
391-
392-
* `SPIClass::SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)`: alternative class constructor
393-
_Params_ SPI `mosi` pin
394-
_Params_ SPI `miso` pin
395-
_Params_ SPI `sclk` pin
396-
_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.
397-
398-
###### Example
399-
400-
This is an example of the use of the hardware CS pin linked to the SPI peripheral:
401-
402-
```C++
403-
#include <SPI.h>
404-
// MOSI MISO SCLK SSEL
405-
SPIClass SPI_3(PC12, PC11, PC10, PC9);
406-
SPISettings settings(1000000, MSBFIRST, SPI_MODE0);
407-
408-
void setup() {
409-
SPI_3.begin(); // Enable the SPI_3 instance with default SPISsettings
410-
SPI_3.beginTransaction(settings); // Configure the SPI_3 instance
411-
SPI_3.transfer(0x52); // Transfers data to the first device
412-
SPI_3.end(); // SPI_3 instance is disabled
413-
}
414-
```
415-
416-
##### Change default `SPI` instance pins
417-
It is also possible to change the default pins used by the `SPI` instance using above API:
418-
419-
> [!WARNING]
420-
> Have to be called before `begin()`.
421-
422-
* `void setMISO(uint32_t miso)`
423-
* `void setMOSI(uint32_t mosi)`
424-
* `void setSCLK(uint32_t sclk)`
425-
* `void setSSEL(uint32_t ssel)`
426-
* `void setMISO(PinName miso)`
427-
* `void setMOSI(PinName mosi)`
428-
* `void setSCLK(PinName sclk)`
429-
* `void setSSEL(PinName ssel)`
430-
431-
> [!NOTE]
432-
> Using `setSSEL()` allows to enable hardware CS pin management linked to the SPI peripheral.
433-
434-
###### Example:
435-
```C++
436-
SPI.setMISO(PC_4); // using pin name PY_n
437-
SPI.setMOSI(PC2); // using pin number PYn
438-
SPI.begin(2);
439-
```
440-
441-
### I2C
442-
443-
By default, only one `Wire` instance is available and it uses the Arduino pins D14(SDA) and D15(SCL).
444-
To use a second I2C port, a `TwoWire` object should be declared in the sketch before the `setup()` function:
445-
```C++
446-
#include <Wire.h>
447-
// SDA SCL
448-
TwoWire Wire2(PB3, PB10);
449-
450-
void setup() {
451-
Wire2.begin();
452-
}
453-
454-
void loop() {
455-
Wire2.beginTransmission(0x71);
456-
Wire2.write('v');
457-
Wire2.endTransmission();
458-
delay(1000);
459-
}
460-
```
461-
462-
See [I2C Timing](customization/Custom-definitions.md#i2c-timing) to customize the I2C speed if needed.
463-
464-
#### Default I2C pins
465-
**The default I2C interface pins are configured inside the PeripheralPins.c file.**
466-
467-
##### Example (for Nucleo-L452RE in file PeripheralPins.c):
468-
```C++
469-
#ifdef HAL_I2C_MODULE_ENABLED
470-
WEAK const PinMap PinMap_I2C_SDA[] = {
471-
{PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
472-
{PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
473-
{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
474-
// {PB_7, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF5_I2C4)},
475-
{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
476-
{PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
477-
// {PB_11, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF3_I2C4)},
478-
{PB_14, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
479-
// {PC_1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
480-
{PC_1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF2_I2C4)},
481-
{NC, NP, 0}
482-
};
483-
#endif
484-
485-
#ifdef HAL_I2C_MODULE_ENABLED
486-
WEAK const PinMap PinMap_I2C_SCL[] = {
487-
{PA_7, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
488-
{PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
489-
// {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
490-
{PB_6, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF5_I2C4)},
491-
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
492-
{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
493-
// {PB_10, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF3_I2C4)},
494-
{PB_13, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
495-
// {PC_0, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
496-
{PC_0, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF2_I2C4)},
497-
{NC, NP, 0}
498-
};
499-
#endif
500-
```
501-
502-
#### Redefine I2C pins
503-
Because they are defined as WEAK, you can redefine them in your sketch file instead of changing values in the PeripheralPins.c file.
504-
You can also enable/disable the internal pull-ups with the second parameter of STM_PIN_DATA().
505-
###### Example (inside of sketch file):
506-
```C++
507-
const PinMap PinMap_I2C_SDA[] = {
508-
{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULLUP, GPIO_AF4_I2C1)},
509-
{PC_1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF2_I2C4)},
510-
{NC, NP, 0}
511-
};
512-
const PinMap PinMap_I2C_SCL[] = {
513-
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULLUP, GPIO_AF4_I2C1)},
514-
{PC_0, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF2_I2C4)},
515-
{NC, NP, 0}
516-
};
517-
```
518-
519-
520-
521-
#### New API functions
522-
523-
##### Change default `Wire` instance pins
524-
It is also possible to change the default pins used by the `Wire` instance using above API:
525-
526-
* `void setSCL(uint32_t scl)`
527-
* `void setSDA(uint32_t sda)`
528-
* `void setSCL(PinName scl)`
529-
* `void setSDA(PinName sda)`
530-
531-
> [!WARNING]
532-
> Have to be called before `begin()`.
533-
534-
###### Example:
535-
```C++
536-
Wire.setSDA(PC_4); // using pin name PY_n
537-
Wire.setSCL(PC2); // using pin number PYn
538-
Wire.begin();
539-
```
540-
541-
##### Enable general call mode
542-
Available in core version greater than **1.5.0**
543-
544-
Adding `true` as last parameters of the 3 `Wire::begin()` methods will enable the general call mode otherwise `false` per default:
545-
546-
* `void begin(bool generalCall = false)`
547-
* `void begin(uint8_t, bool generalCall = false)`
548-
* `void begin(int, bool generalCall = false)`
549-
550-
###### Example
551-
`Wire.begin(true);` or `Wire.begin(0x70,true);`
552-
553-
#### I2C buffer management
554-
By default, I2C buffers are aligned with the Arduino API at **32 bytes**. Transfers of up to **255 bytes** are also possible:
555-
556-
- In master mode: RX and TX buffers will automatically grow when needed, independently one from each other, and independently from other I2C instances. Nothing to do from application point of view. Warning: a bug in STM32 cube HAL (STM32 core v1.8.0) prevents to transfer exactly 255 bytes. (see [PR #853])
557-
558-
- In slave mode: RX and TX buffer size can be statically redefined using [hal_conf_extra.h](customization/HAL-configuration.md) or [`build_opt.h`][build_opt.h] (at compilation time) thanks to switch `I2C_TXRX_BUFFER_SIZE` (see [PR #853]). All I2C instances are impacted by change of this compilation switch.
559-
560-
### CMSIS-DSP
561-
562-
Available in core version greater than **1.7.0**
563-
564-
CMSIS-DSP is a suite of common signal-processing functions for Cortex-M devices.
565-
566-
The library is divided into a number of functions each covering a specific category:
567-
568-
- Basic math functions
569-
- Fast math functions
570-
- Complex math functions
571-
- Filters
572-
- Matrix functions
573-
- Transform functions
574-
- Motor control functions
575-
- Statistical functions
576-
- Support functions
577-
- Interpolation functions.
578-
579-
The library has separate functions for operating on 8-bit integers, 16-bit integers, 32-bit integer and 32-bit floating-point value.
580-
581-
More info:
582-
https://arm-software.github.io/CMSIS_5/DSP/html/index.html
583-
584-
To use it, include:
585-
```C++
586-
#include <CMSIS_DSP.h>
587-
```
588-
589-
`arm_math.h` is then included automatically.
590-
591-
592-
### EEPROM emulation
593-
594-
EEPROM emulation is based on Arduino API:
595-
https://docs.arduino.cc/learn/built-in-libraries/eeprom/
596-
597-
Emulation is made in Flash, with all constraints related to Flash operation:
598-
599-
- whole sector/page erased and written for each write operation. This can be very long depending on sector/page size.
600-
- limited Flash life cycle write operation
601-
602-
In addition to Arduino API, to mitigate Flash constraints, it is possible to use buffered API:
603-
Write operations are made in an intermediate RAM buffer, and only at the end (after writing several parameters for example) the buffer is copied in Flash. Thus only 1 write operation for a whole bunch of data.
604-
Example is available here: https://github.com/stm32duino/STM32Examples/tree/main/examples/NonReg/BufferedEEPROM
605-
```C
606-
void eeprom_buffer_fill(); // This function copies the data from flash into the buffer
607-
void eeprom_buffer_flush(); // This function writes the buffer content into the flash
608-
uint8_t eeprom_buffered_read_byte(const uint32_t pos); // Function reads a byte from the eeprom buffer
609-
void eeprom_buffered_write_byte(uint32_t pos, uint8_t value); // Function writes a byte to the eeprom buffer
610-
```
611-
By default, EEPROM emulation storage correspond to the last sector/page of Flash,
612-
and its size correspond to the size of the last sector/page.
613-
Nevertheless it is possible to customize address and size used for EEPROM.
614-
In this case, following switches should be defined (in variant.h or [`build_opt.h`][build_opt.h])
615-
616-
- `FLASH_BASE_ADDRESS`
617-
- `FLASH_DATA_SECTOR` or `FLASH_PAGE_NUMBER` (depending on STM32 family used)
618-
619-
see example of variant implementation: [PR #938](https://github.com/stm32duino/Arduino_Core_STM32/pull/938)
620-
621-
> [!WARNING]
622-
> Single/dual bank configuration:
623-
>
624-
> Default last sector used correspond to default board configuration.
625-
>
626-
> For example, NUCLEO_F767ZI is by default configured in single bank. Last sector correspond to this bank configuration.
627-
> If this configuration is changed, it is then mandatory to customize `FLASH_BASE_ADDRESS`/`FLASH_DATA_SECTOR`,
628-
> even to use last sector of Flash.
629-
630-
### Servo library
631-
632-
See the [Servo library reference](libraries/built-in/Servo-library.md) for the supported Servo API.
633-
634372
## Other
635373

636374
### Remembering variables across resets

‎docs/development/Contributing.md‎

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# CMSIS-DSP
2+
3+
Available in core version greater than **1.7.0**
4+
5+
CMSIS-DSP is a suite of common signal-processing functions for Cortex-M devices.
6+
7+
The library is divided into a number of functions each covering a specific category:
8+
9+
- Basic math functions
10+
- Fast math functions
11+
- Complex math functions
12+
- Filters
13+
- Matrix functions
14+
- Transform functions
15+
- Motor control functions
16+
- Statistical functions
17+
- Support functions
18+
- Interpolation functions.
19+
20+
The library has separate functions for operating on 8-bit integers, 16-bit integers, 32-bit integers and 32-bit floating-point values.
21+
22+
More info:
23+
24+
For cores based on CMSIS 6, CMSIS-DSP is provided as a separate package with its own version.
25+
See the [CMSIS-DSP documentation](https://arm-software.github.io/CMSIS-DSP/) and the
26+
[CMSIS-DSP repository](https://github.com/ARM-software/CMSIS-DSP) for package and source details.
27+
28+
For cores based on CMSIS 5, see the legacy documentation:
29+
https://arm-software.github.io/CMSIS_5/DSP/html/index.html
30+
31+
To use it, include:
32+
```C++
33+
#include <CMSIS_DSP.h>
34+
```
35+
36+
`arm_math.h` is then included automatically.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# EEPROM emulation
2+
3+
EEPROM emulation is based on Arduino API:
4+
https://docs.arduino.cc/learn/built-in-libraries/eeprom/
5+
6+
Emulation is made in Flash, with all constraints related to Flash operation:
7+
8+
- whole sector/page erased and written for each write operation. This can be very long depending on sector/page size.
9+
- limited Flash life cycle write operation
10+
11+
In addition to Arduino API, to mitigate Flash constraints, it is possible to use buffered API:
12+
Write operations are made in an intermediate RAM buffer, and only at the end (after writing several parameters for example) the buffer is copied in Flash. Thus only 1 write operation for a whole bunch of data.
13+
Example is available here: https://github.com/stm32duino/STM32Examples/tree/main/examples/NonReg/BufferedEEPROM
14+
```C
15+
void eeprom_buffer_fill(); // This function copies the data from flash into the buffer
16+
void eeprom_buffer_flush(); // This function writes the buffer content into the flash
17+
uint8_t eeprom_buffered_read_byte(const uint32_t pos); // Function reads a byte from the eeprom buffer
18+
void eeprom_buffered_write_byte(uint32_t pos, uint8_t value); // Function writes a byte to the eeprom buffer
19+
```
20+
By default, EEPROM emulation storage correspond to the last sector/page of Flash,
21+
and its size correspond to the size of the last sector/page.
22+
Nevertheless it is possible to customize address and size used for EEPROM.
23+
In this case, following switches should be defined (in variant.h or [`build_opt.h`][build_opt.h])
24+
25+
- `FLASH_BASE_ADDRESS`
26+
- `FLASH_DATA_SECTOR` or `FLASH_PAGE_NUMBER` (depending on STM32 family used)
27+
28+
see example of variant implementation: [PR #938](https://github.com/stm32duino/Arduino_Core_STM32/pull/938)
29+
30+
> [!WARNING]
31+
> Single/dual bank configuration:
32+
>
33+
> Default last sector used correspond to default board configuration.
34+
>
35+
> For example, NUCLEO_F767ZI is by default configured in single bank. Last sector correspond to this bank configuration.
36+
> If this configuration is changed, it is then mandatory to customize `FLASH_BASE_ADDRESS`/`FLASH_DATA_SECTOR`,
37+
> even to use last sector of Flash.
38+
39+
[build_opt.h]: ../../customization/Customize-build-options-using-build_opt.h.md

0 commit comments

Comments
 (0)