blob: cd0fdbeb8af8d43fad36e1b97a89ade315c50b76 [file] [log] [blame]
Armando Montaneza398cd12021-12-13 10:57:41 -08001.. _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 This defaults to 64 Bytes.
42
43.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_TX_PIN
44
45 The pin index to use for USART transmission within the port set by
46 ``PW_SYS_IO_STM32CUBE_GPIO_PORT``.
47
48.. c:macro:: PW_SYS_IO_STM32CUBE_GPIO_RX_PIN
49
50 The pin index to use for USART reception within the port set by
51 ``PW_SYS_IO_STM32CUBE_GPIO_PORT``.
52
53Module usage
54============
55After building an executable that utilizes this backend, flash the
56produced .elf binary to the development board. Then, using a serial
57communication terminal like minicom/screen (Linux/Mac) or TeraTerm (Windows),
58connect to the device at a baud rate of 115200 (8N1). If you're not using a
59STM32F429I-DISC1 development board, manually connect a USB-to-serial TTL adapter
60to pins ``PA9`` (MCU TX) and ``PA10`` (MCU RX), making sure to match logic
61levels (e.g. 3.3V versus 1.8V).
62
63Sample connection diagram
64-------------------------
65
66.. code-block:: text
67
68 --USB Serial--+ +-----STM32F429 MCU-----
69 | |
70 TX o--->o PA10/USART1_RX
71 | |
72 RX o<---o PA9/USART1_TX
73 | |
74 --------------+ +-----------------------