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