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