Skip to content

Commit 6c003ab

Browse files
committed
docs: align UART documentation with the current API
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent b181632 commit 6c003ab

9 files changed

Lines changed: 48 additions & 46 deletions

File tree

‎docs/API.md‎

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ An example that reads and converts the three internal channels and A0 is provide
132132
> [!WARNING]
133133
> This example is provided as-is and may require updates for device-specific datasheet values.
134134
135-
### HardwareSerial
135+
### Uart
136136
137137
STM32 MCUs have several _U(S)ART_ peripherals. For convenience, the _U(S)ART_**x** number is used to define the `Serialx` instance:
138138
@@ -150,10 +150,10 @@ For _LPUART_ peripherals:
150150
151151
**By default, only one `Serialx` instance is available mapped to the generic `Serial` name.**
152152
153-
To use a second serial port, a `HardwareSerial` object should be declared in the sketch before the `setup()` function:
153+
To use a second serial port, a `Uart` object should be declared in the sketch before the `setup()` function:
154154
```C++
155155
// RX TX
156-
HardwareSerial Serial1(PA10, PA9);
156+
Uart Serial1(PA10, PA9);
157157
158158
void setup() {
159159
Serial1.begin(115200);
@@ -196,8 +196,8 @@ Example for the `Serial3`:
196196
##### Change default `Serial` instance pins
197197
It is also possible to change the default pins used by the `Serial` instance using above API:
198198
199-
* `void setRx(uint32_t rx)`
200-
* `void setTx(uint32_t tx)`
199+
* `void setRx(pin_size_t rx)`
200+
* `void setTx(pin_size_t tx)`
201201
* `void setRx(PinName rx)`
202202
* `void setTx(PinName tx)`
203203
@@ -215,17 +215,17 @@ It is also possible to change the default pins used by the `Serial` instance usi
215215

216216
Available in core version greater than **1.7.0**
217217

218-
It is now possible to set a `HardwareSerial` in half-duplex mode.
218+
It is now possible to set a `Uart` in half-duplex mode.
219219

220220
The `U(S)ART` can be configured to follow a single-wire half-duplex protocol where the Tx and Rx lines are internally connected. In this communication mode, only the Tx pin is used for both transmission and reception.
221221

222-
* Extended `HardwareSerial` constructors:
223-
* `HardwareSerial(uint32_t _rxtx)`: U(S)ART Tx pin number (`PYn`) used for half-duplex
224-
* `HardwareSerial(PinName _rxtx)`: U(S)ART Tx pin name (`PY_n`) used for half-duplex
222+
* Extended `Uart` constructors:
223+
* `Uart(pin_size_t _rxtx)`: U(S)ART Tx pin number (`PYn`) used for half-duplex
224+
* `Uart(PinName _rxtx)`: U(S)ART Tx pin name (`PY_n`) used for half-duplex
225225
* if `Rx == Tx` then assume half-duplex mode:
226-
* `HardwareSerial(uint32_t _rx, uint32_t _tx)`: U(S)ART Tx pin number (`PYn`) used for half-duplex
227-
* `HardwareSerial(PinName _rx, PinName tx)`: U(S)ART Tx pin name (`PY_n`) used for half-duplex
228-
* `HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex = HALF_DUPLEX_DISABLED)`: if `HALF_DUPLEX_ENABLED` get the first Tx pin for requested peripheral in the` PeripheralPins.c` used for half-duplex
226+
* `Uart(pin_size_t _rx, pin_size_t _tx)`: U(S)ART Tx pin number (`PYn`) used for half-duplex
227+
* `Uart(PinName _rx, PinName tx)`: U(S)ART Tx pin name (`PY_n`) used for half-duplex
228+
* `Uart(void *peripheral, HalfDuplexMode_t halfDuplex = HALF_DUPLEX_DISABLED)`: if `HALF_DUPLEX_ENABLED` get the first Tx pin for requested peripheral in the` PeripheralPins.c` used for half-duplex
229229

230230
* Add `enableHalfDuplexRx()` to enable Serial in Rx mode. Doing a `read()` could be used but will avoid to perform a read. Useful before `available()` usage
231231
* `void setHalfDuplex()`: enable half-duplex mode of an instance when it not instantiate in half-duplex mode. Must be call before `begin()` in this case.
@@ -237,26 +237,26 @@ Require to connect `PA0` and` PB10`.
237237
_All possible constructor are listed._
238238

239239
```C++
240-
HardwareSerial Serial3(PA0);
241-
HardwareSerial Serial4(PB10);
240+
Uart Serial3(PA0);
241+
Uart Serial4(PB10);
242242

243-
//HardwareSerial Serial3(PA_0);
244-
//HardwareSerial Serial4(PB_10);
243+
//Uart Serial3(PA_0);
244+
//Uart Serial4(PB_10);
245245

246-
//HardwareSerial Serial3(UART4, HALF_DUPLEX_ENABLED);
247-
//HardwareSerial Serial4(USART3, HALF_DUPLEX_ENABLED);
246+
//Uart Serial3(UART4, HALF_DUPLEX_ENABLED);
247+
//Uart Serial4(USART3, HALF_DUPLEX_ENABLED);
248248

249-
//HardwareSerial Serial3(PA0, PA0);
250-
//HardwareSerial Serial4(PB10, PB10);
249+
//Uart Serial3(PA0, PA0);
250+
//Uart Serial4(PB10, PB10);
251251

252-
//HardwareSerial Serial3(PA_0, PA_0);
253-
//HardwareSerial Serial4(PB_10, PB_10);
252+
//Uart Serial3(PA_0, PA_0);
253+
//Uart Serial4(PB_10, PB_10);
254254

255-
//HardwareSerial Serial3(NC, PA_0);
256-
//HardwareSerial Serial4(NC, PB_10);
255+
//Uart Serial3(NC, PA_0);
256+
//Uart Serial4(NC, PB_10);
257257

258-
//HardwareSerial Serial3(NUM_DIGITAL_PINS, PA0);
259-
//HardwareSerial Serial4(NUM_DIGITAL_PINS, PB10);
258+
//Uart Serial3(NUM_DIGITAL_PINS, PA0);
259+
//Uart Serial4(NUM_DIGITAL_PINS, PB10);
260260

261261
static uint32_t nbTestOK = 0;
262262
static uint32_t nbTestKO = 0;
@@ -331,13 +331,13 @@ void loop() {
331331
332332
Available in core version **2.3.0** or later
333333
334-
* `HardwareSerial` constructors accept optional RTS/CTS pins:
335-
* `HardwareSerial(uint32_t _rx, uint32_t _tx, uint32_t _rts = NUM_DIGITAL_PINS, uint32_t _cts = NUM_DIGITAL_PINS)`
336-
* `HardwareSerial(PinName _rx, PinName _tx, PinName _rts = NC, PinName _cts = NC)`
337-
* You can also enable RTS/CTS pins on `HardwareSerial` instances:
338-
* `void setRts(uint32_t _rts)`
339-
* `void setCts(uint32_t _cts)`
340-
* `void setRtsCts(uint32_t _rts, uint32_t _cts)`
334+
* `Uart` constructors accept optional RTS/CTS pins:
335+
* `Uart(pin_size_t _rx, pin_size_t _tx, pin_size_t _rts = NUM_DIGITAL_PINS, pin_size_t _cts = NUM_DIGITAL_PINS)`
336+
* `Uart(PinName _rx, PinName _tx, PinName _rts = NC, PinName _cts = NC)`
337+
* You can also enable RTS/CTS pins on `Uart` instances:
338+
* `void setRts(pin_size_t _rts)`
339+
* `void setCts(pin_size_t _cts)`
340+
* `void setRtsCts(pin_size_t _rts, pin_size_t _cts)`
341341
* `void setRts(PinName _rts)`
342342
* `void setCts(PinName _cts)`
343343
* `void setRtsCts(PinName _rts, PinName _cts)`
@@ -346,10 +346,10 @@ Available in core version **2.3.0** or later
346346
347347
```C++
348348
// Enable hardware flow control on construction.
349-
HardwareSerial serial(PA10, PA9, PA12, PA11);
349+
Uart serial(PA10, PA9, PA12, PA11);
350350
351351
// Or, enable later (but before calling begin()).
352-
HardwareSerial serial(PA10, PA9);
352+
Uart serial(PA10, PA9);
353353
serial.setRtsCts(PA12, PA11);
354354
serial.begin(460800);
355355
```
@@ -361,10 +361,10 @@ Available in core version greater than **2.10.1**
361361
The U(S)ART Tx and Rx pin signal values can be inverted (VDD = 0/mark, Gnd = 1/idle), and the U(S)ART can send and receive data in negative/inverse logic (1 = L, 0 = H); the
362362
parity bit is also inverted.
363363

364-
* Enable Tx and Rx active level inversion on `HardwareSerial` instances, respectively:
364+
* Enable Tx and Rx active level inversion on `Uart` instances, respectively:
365365
* `void setTxInvert(void)`
366366
* `void setRxInvert(void)`
367-
* Enable data inversion on `HardwareSerial` instances:
367+
* Enable data inversion on `Uart` instances:
368368
* `void setDataInvert(void)`
369369

370370
### HardwareTimer library

‎docs/Pin-naming.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Serial.begin(9600);
1717

1818
Arduino functions such as `pinMode()` and `digitalWrite()` normally use the digital pin numbering defined by the selected board variant. The variant may also define aliases such as `PA0`, `PB7`, `A0`, or `LED_BUILTIN`. These aliases are board-specific and can map to Arduino digital numbers; they are not interchangeable with the `PinName` constant `PA_0`.
1919

20+
`digitalRead()` returns a `PinStatus` value (`HIGH` or `LOW`).
21+
2022
For example, a variant may map `PA0` to `PIN_A0`, while another maps a port-pin alias to a different digital pin number. Use the aliases and labels documented for the selected board:
2123

2224
```cpp
@@ -126,7 +128,7 @@ Internal ADC channels are different from external analog inputs. When supported
126128
Use the underscore form when a constructor or function expects a `PinName`. For example, these peripheral instances use the physical STM32 pins directly:
127129

128130
```cpp
129-
HardwareSerial Serial3(PA_10, PA_9); // RX, TX
131+
Uart Serial3(PA_10, PA_9); // RX, TX
130132
TwoWire Wire2(PB_9, PB_8); // SDA, SCL
131133
```
132134
@@ -139,7 +141,7 @@ Some board variants define names such as `PA2_ALT1` in addition to the default r
139141
For example, an alternate pin can be passed to a peripheral constructor when the variant provides that route:
140142
141143
```cpp
142-
HardwareSerial Serial2(PA2_ALT1, PA3_ALT1); // Only if defined by the variant
144+
Uart Serial2(PA2_ALT1, PA3_ALT1); // Only if defined by the variant
143145
```
144146

145147
Check `PeripheralPins.c` before using an `_ALT1` or similar name; the name alone does not guarantee that the requested peripheral supports that route. An unsupported route can prevent the peripheral from being configured correctly.

‎docs/Tools-menu.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Menu: "**Tools > U(S)ART support**"
1010
| Option | Description |
1111
|--------|-------------|
1212
| Enabled (generic 'Serial') | U(S)ART support is enabled and the generic `Serial` object is available. It is mapped to the board's default serial interface (e.g. the ST-LINK virtual COM port on Nucleo boards). |
13-
| Enabled (no generic 'Serial') | U(S)ART support is enabled (`-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE`) but the generic `Serial` is not defined. Instances have to be created by the user (e.g. `HardwareSerial Serial2(PA3, PA2);`). |
13+
| Enabled (no generic 'Serial') | U(S)ART support is enabled (`-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE`) but the generic `Serial` is not defined. Instances have to be created by the user (e.g. `Uart Serial2(PA3, PA2);`). |
1414
| Disabled (No Serial support) | U(S)ART support is disabled. Reduces the code size when serial is not used. |
1515

1616
## USB support

‎doxygen/mainpage.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sidebar to switch between the development (`dev`) and the released versions.
1111

1212
## Where to start
1313

14-
- [Classes](annotated.html): classes and structures such as `HardwareTimer`, `HardwareSerial` or `TwoWire`.
14+
- [Classes](annotated.html): classes and structures such as `HardwareTimer`, `Uart` or `TwoWire`.
1515
- [Files](files.html): browse the documented source files.
1616
- [Functions](globals_func.html): documented C functions.
1717

‎keywords.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ PIN_WIRE_SDA LITERAL1
266266
PIN_WIRE_SCL LITERAL1
267267

268268
# Serial
269-
HardwareSerial KEYWORD2
269+
Uart KEYWORD2
270270
setRx KEYWORD2
271271
setTx KEYWORD2
272272
HALF_DUPLEX_DISABLED LITERAL1

‎variants/STM32L0xx/L072R(B-Z)T_L073R(B-Z)T_L083R(B-Z)T/variant_PX_HER0.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196

197197
// Optional PIN_SERIALn_RX and PIN_SERIALn_TX where 'n' is the U(S)ART number
198198
// Used when user instantiate a hardware Serial using its peripheral name.
199-
// Example: HardwareSerial mySerial(USART3);
199+
// Example: Uart mySerial(USART3);
200200
// will use PIN_SERIAL3_RX and PIN_SERIAL3_TX if defined.
201201
#define ENABLE_HWSERIAL1
202202
#ifndef PIN_SERIAL1_RX

‎variants/STM32L4xx/L433C(B-C)(T-U)_L443CC(T-U)/variant_CYGNET.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212

213213
// Virtual COM Port for Cygnet with a 14-pin STLink Connector mounted.
214214
// To use the STLINK's Virtual COM port, add the following line to an Arduino project:
215-
// HardwareSerial SerialVCP(PIN_VCP_RX, PIN_VCP_TX);
215+
// Uart SerialVCP(PIN_VCP_RX, PIN_VCP_TX);
216216
#ifndef PIN_VCP_RX
217217
#define PIN_VCP_RX PIN_SERIAL_LP1_RX
218218
#endif

‎variants/STM32L4xx/L4R5Z(G-I)Y_L4R9Z(G-I)Y_L4S5ZIY_L4S9ZIY/variant_SWAN_R5.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261

262262
// Virtual COM Port for Swans with a 14-pin STLink Connector mounted.
263263
// To use the STLINK's Virtual COM port, this would be added to an Arduino project:
264-
// HardwareSerial SerialVCP(PIN_VCP_RX, PIN_VCP_TX);
264+
// Uart SerialVCP(PIN_VCP_RX, PIN_VCP_TX);
265265
#ifndef PIN_VCP_RX
266266
#define PIN_VCP_RX PIN_SERIAL_LP1_RX
267267
#endif

‎variants/STM32U5xx/U575O(G-I)YxQ_U585OIYxQ/variant_HERON.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275

276276
// Virtual COM Port for Heron with a 14-pin STLink Connector mounted.
277277
// To use the STLINK's Virtual COM port, add the following line to an Arduino project:
278-
// HardwareSerial SerialVCP(PIN_VCP_RX, PIN_VCP_TX);
278+
// Uart SerialVCP(PIN_VCP_RX, PIN_VCP_TX);
279279
#ifndef PIN_VCP_RX
280280
#define PIN_VCP_RX PIN_SERIAL3_RX
281281
#endif

0 commit comments

Comments
 (0)