Armando Montanez | a398cd1 | 2021-12-13 10:57:41 -0800 | [diff] [blame] | 1 | .. _module-pw_sys_io_stm32cube: |
| 2 | |
| 3 | ------------------- |
| 4 | pw_sys_io_stm32cube |
| 5 | ------------------- |
| 6 | |
| 7 | ``pw_sys_io_stm32cube`` implements the ``pw_sys_io`` facade over UART using |
| 8 | the STM32Cube HAL to support an assortment of boards from STMicroelectronics. |
| 9 | |
| 10 | The UART baud rate is fixed at 115200 (8N1). |
| 11 | |
| 12 | Setup |
| 13 | ===== |
| 14 | This 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 | |
| 22 | For devices other than the STM32F429I-DISC1, this module will need to be |
| 23 | configured to use the appropriate GPIO pins and USART peripheral. |
| 24 | |
| 25 | Module Configuration Options |
| 26 | ============================ |
| 27 | The following configurations can be adjusted via compile-time configuration of |
| 28 | this module, see the |
| 29 | :ref:`module documentation <module-structure-compile-time-configuration>` for |
| 30 | more 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 | |
| 53 | Module usage |
| 54 | ============ |
| 55 | After building an executable that utilizes this backend, flash the |
| 56 | produced .elf binary to the development board. Then, using a serial |
| 57 | communication terminal like minicom/screen (Linux/Mac) or TeraTerm (Windows), |
| 58 | connect to the device at a baud rate of 115200 (8N1). If you're not using a |
| 59 | STM32F429I-DISC1 development board, manually connect a USB-to-serial TTL adapter |
| 60 | to pins ``PA9`` (MCU TX) and ``PA10`` (MCU RX), making sure to match logic |
| 61 | levels (e.g. 3.3V versus 1.8V). |
| 62 | |
| 63 | Sample 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 | --------------+ +----------------------- |