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: docs/design-documents/drivers/serial/serial.md
+17-39Lines changed: 17 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,6 @@ The below diagram shows the inheritance hierarchy for the serial classes.
73
73
74
74

75
75
76
-
`MinimalSerial` is an abstract class that extracts basics I/O functionality from `SerialBase` so it can be re-used for a minimal serial console in the retarget code.
77
-
78
76
# Detailed design
79
77
80
78
### Detailed design : BufferedSerial
@@ -183,42 +181,6 @@ protected:
183
181
};
184
182
```
185
183
186
-
### Detailed design : MinimalSerial
187
-
188
-
The `MinimalSerial` class is a minimal abstract base class that provides basics I/O functionality. It is not part of the public interface. All other serial classes derive from it.
189
-
190
-
**API description**
191
-
192
-
This is the proposed API for the `MinimalSerial` class. Only two methods are provided to output `_base_putc()` and receive `_base_getc()` characters on the UART.
193
-
194
-
```C
195
-
class MinimalSerial : private NonCopyable<MinimalSerial> {
196
-
protected:
197
-
MinimalSerial(PinName tx, PinName rx, int baud);
198
-
virtual ~MinimalSerial();
199
-
int _base_getc();
200
-
int _base_putc(int c);
201
-
};
202
-
```
203
-
204
-
### Detailed design : MinimalConsole
205
-
206
-
`MinimalConsole` is an internal concrete class that derives from `MinimalSerial` and provides basic console functionality that can be used by the retarget code for resources constrained targets, see [Simplication of retarget code](#simplification-of-retarget-code).
207
-
208
-
**API description**
209
-
210
-
```C
211
-
class MinimalConsole : public MinimalSerial, private NonCopyable<MinimalConsole> {
212
-
public:
213
-
MinimalConsole(PinName tx, PinName rx, int baud);
214
-
virtual ~MinimalConsole();
215
-
int getc();
216
-
int putc(int c);
217
-
};
218
-
```
219
-
220
-
The constructor provides arguments to create a serial port connected to the specified transmit and receive pins and set to the specified baud rate. If a target has serial support, by default a serial port is used for the console and the pins and settings for the port selection come from target header files and JSON settings.
@@ -279,7 +247,17 @@ There are two approaches to achieve a minimal retarget layer. You can:
279
247
280
248
A minimal console only needs to write a single character at a time. So redefining the default fputc() to directly write to the serial port if the output stream is stdout and bypassing the system I/O functions should achieve higher memory savings. If we take this approach, we will have to rework some error handlers that rely on the POSIX form of `write(STDOUT_FILENO, buf, len)` to do emergency printing.
281
249
282
-
The second solution keeps the POSIX layer with the main saving coming from dropping the use of `FileHandle` and the file handle table itself. In this case, `write()` would call `MinimalConsole::putc` in a loop.
250
+
The second solution keeps the POSIX layer with the main saving coming from dropping the use of `FileHandle` and the file handle table itself. In this case, a `MinimalConsole` class will be implemented as an internal class in the retarget code and `write()` will call `MinimalConsole::putc` in a loop.
0 commit comments