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
{{ message }}
Repository navigation
Commit 6c003ab
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/API.md
+37-37Lines changed: 37 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,7 +132,7 @@ An example that reads and converts the three internal channels and A0 is provide
132
132
> [!WARNING]
133
133
> This example is provided as-is and may require updates for device-specific datasheet values.
134
134
135
-
### HardwareSerial
135
+
### Uart
136
136
137
137
STM32 MCUs have several _U(S)ART_ peripherals. For convenience, the _U(S)ART_**x** number is used to define the `Serialx` instance:
138
138
@@ -150,10 +150,10 @@ For _LPUART_ peripherals:
150
150
151
151
**By default, only one `Serialx` instance is available mapped to the generic `Serial` name.**
152
152
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:
154
154
```C++
155
155
// RX TX
156
-
HardwareSerial Serial1(PA10, PA9);
156
+
Uart Serial1(PA10, PA9);
157
157
158
158
void setup() {
159
159
Serial1.begin(115200);
@@ -196,8 +196,8 @@ Example for the `Serial3`:
196
196
##### Change default `Serial` instance pins
197
197
It is also possible to change the default pins used by the `Serial` instance using above API:
198
198
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)`
201
201
* `void setRx(PinName rx)`
202
202
* `void setTx(PinName tx)`
203
203
@@ -215,17 +215,17 @@ It is also possible to change the default pins used by the `Serial` instance usi
215
215
216
216
Available in core version greater than **1.7.0**
217
217
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.
219
219
220
220
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.
221
221
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
225
225
* 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
229
229
230
230
* 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
231
231
*`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`.
@@ -346,10 +346,10 @@ Available in core version **2.3.0** or later
346
346
347
347
```C++
348
348
// Enable hardware flow control on construction.
349
-
HardwareSerial serial(PA10, PA9, PA12, PA11);
349
+
Uart serial(PA10, PA9, PA12, PA11);
350
350
351
351
// Or, enable later (but before calling begin()).
352
-
HardwareSerial serial(PA10, PA9);
352
+
Uart serial(PA10, PA9);
353
353
serial.setRtsCts(PA12, PA11);
354
354
serial.begin(460800);
355
355
```
@@ -361,10 +361,10 @@ Available in core version greater than **2.10.1**
361
361
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
362
362
parity bit is also inverted.
363
363
364
-
* Enable Tx and Rx active level inversion on `HardwareSerial` instances, respectively:
364
+
* Enable Tx and Rx active level inversion on `Uart` instances, respectively:
365
365
*`void setTxInvert(void)`
366
366
*`void setRxInvert(void)`
367
-
* Enable data inversion on `HardwareSerial` instances:
Copy file name to clipboardExpand all lines: docs/Pin-naming.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ Serial.begin(9600);
17
17
18
18
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`.
19
19
20
+
`digitalRead()` returns a `PinStatus` value (`HIGH` or `LOW`).
21
+
20
22
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:
21
23
22
24
```cpp
@@ -126,7 +128,7 @@ Internal ADC channels are different from external analog inputs. When supported
126
128
Use the underscore form when a constructor or function expects a `PinName`. For example, these peripheral instances use the physical STM32 pins directly:
127
129
128
130
```cpp
129
-
HardwareSerialSerial3(PA_10, PA_9); // RX, TX
131
+
UartSerial3(PA_10, PA_9); // RX, TX
130
132
TwoWire Wire2(PB_9, PB_8); // SDA, SCL
131
133
```
132
134
@@ -139,7 +141,7 @@ Some board variants define names such as `PA2_ALT1` in addition to the default r
139
141
For example, an alternate pin can be passed to a peripheral constructor when the variant provides that route:
140
142
141
143
```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
143
145
```
144
146
145
147
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.
| 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);`). |
14
14
| Disabled (No Serial support) | U(S)ART support is disabled. Reduces the code size when serial is not used. |
0 commit comments