Skip to content

Commit

Permalink
[stm32] Document UART buffer config transition
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jun 30, 2024
1 parent 7a8c57d commit ad778f7
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/modm/platform/uart/stm32/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@

props = {}

descr_example = """
```cpp
using namespace modm::platform;
// Using only hardware buffers for Tx and Rx (both 1 symbol)
using UartN = BufferedUart<U(s)artHalN>;
// using only TX software buffer
using UartN = BufferedUart<U(s)artHalN, UartTxBuffer<512>>;
// using only RX software buffer
using UartN = BufferedUart<U(s)artHalN, UartRxBuffer<256>>;
// using both TX and RX software buffers
using UartN = BufferedUart<U(s)artHalN, UartTxBuffer<512>, UartRxBuffer<256>>;
```
"""

descr_buffer = """
The buffer configuration is now implemented in C++.
Please replace any `modm::platform::U(s)artN` type with:
""" + descr_example

class Instance(Module):
def __init__(self, driver, instance):
self.driver = driver
Expand All @@ -27,6 +46,8 @@ class Instance(Module):
module.description = "Instance {}".format(self.instance)

def prepare(self, module, options):
module.add_alias(Alias(name="buffer.tx", description=descr_buffer))
module.add_alias(Alias(name="buffer.rx", description=descr_buffer))
module.depends(":platform:uart")
return True

Expand Down Expand Up @@ -55,7 +76,22 @@ class Instance(Module):

def init(module):
module.name = ":platform:uart"
module.description = "Universal Asynchronous Receiver Transmitter (UART)"
module.description = """
# Universal Asynchronous Receiver Transmitter (UART)
The UART buffer configuration is implemented as C++ template arguments:
""" + descr_example + """
## Using FreeRTOS buffers
A special buffer implementation is available for FreeRTOS that uses the proper
queue implementation to sleep and wake up the calling thread:
```cpp
// using both TX and RX software buffers
using UartTxRxN = BufferedUart<U(s)artHalN, UartTxBufferFreeRtos<512>, UartRxBufferFreeRtos<256>>;
```
"""

def prepare(module, options):
device = options[":target"]
Expand Down

0 comments on commit ad778f7

Please sign in to comment.