• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _module-pw_sys_io_stm32cube:
2
3-------------------
4pw_sys_io_stm32cube
5-------------------
6
7``pw_sys_io_stm32cube`` implements the ``pw_sys_io`` facade over UART using
8the STM32Cube HAL to support an assortment of boards from STMicroelectronics.
9
10The UART baud rate is fixed at 115200 (8N1).
11
12Setup
13=====
14This module requires relatively minimal setup:
15
16  1. Write code against the ``pw_sys_io`` facade.
17  2. Specify the ``dir_pw_sys_io_backend`` GN global variable to point to this
18     backend.
19  3. Call ``pw_sys_io_Init()`` during init so the UART is properly initialized
20     and configured.
21
22For devices other than the STM32F429I-DISC1, this module will need to be
23configured to use the appropriate GPIO pins and USART peripheral.
24
25Module Configuration Options
26============================
27The following configurations can be adjusted via compile-time configuration of
28this module, see the
29:ref:`module documentation <module-structure-compile-time-configuration>` for
30more details.
31
32.. c:macro:: PW_SYS_IO_STM32CUBE_USART_NUM
33
34  The USART peripheral number to use. (1 for USART1, 2 for USART2, etc.)
35
36.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_PORT
37
38  The port that the USART peripheral TX/RX pins are on. (e.g. to use A9/A10
39  pins for TX and RX, respectively, set this to A)
40
41.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_TX_PORT
42
43  The port for the USART peripheral TX pin, if different from
44  PW_SYS_IO_STM32CUBE_GPIO_PORT.
45
46.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_RX_PORT
47
48  The port for the USART peripheral RX pin, if different from
49  PW_SYS_IO_STM32CUBE_GPIO_PORT.
50
51.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_TX_PIN
52
53  The pin index to use for USART transmission within the port set by
54  ``PW_SYS_IO_STM32CUBE_GPIO_PORT``.
55
56.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_RX_PIN
57
58  The pin index to use for USART reception within the port set by
59  ``PW_SYS_IO_STM32CUBE_GPIO_PORT``.
60
61.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_AF
62
63  The alternate function index to use for USART reception within the port set by
64  ``PW_SYS_IO_STM32CUBE_GPIO_PORT``.
65
66.. c:macro:: PW_SYS_IO_STM32CUBE_USART_PREFIX
67
68  The peripheral name prefix (either UART or USART) for the peripheral selected
69  by ``PW_SYS_IO_STM32CUBE_USART_NUM``. Defaults to USART.
70
71Module usage
72============
73After building an executable that utilizes this backend, flash the
74produced .elf binary to the development board. Then, using a serial
75communication terminal like minicom/screen (Linux/Mac) or TeraTerm (Windows),
76connect to the device at a baud rate of 115200 (8N1). If you're not using a
77STM32F429I-DISC1 development board, manually connect a USB-to-serial TTL adapter
78to pins ``PA9`` (MCU TX) and ``PA10`` (MCU RX), making sure to match logic
79levels (e.g. 3.3V versus 1.8V).
80
81Sample connection diagram
82-------------------------
83
84.. code-block:: text
85
86  --USB Serial--+    +-----STM32F429 MCU-----
87                |    |
88             TX o--->o PA10/USART1_RX
89                |    |
90             RX o<---o PA9/USART1_TX
91                |    |
92  --------------+    +-----------------------
93