Hi, Peter Stuge wrote: > Peter Stuge wrote: > > I suggest: > > > > 1. Move forward with SAMD11 replacing FTDI > > 2. Add CTS+RTS to the UART interface > > I discovered that CTS+RTS are actually already connected to the USER FTDI > in the rev03 schematic, but not to the MGMT FTDI. So at least some of the > routing already exists! > > Paul, do you know if the STM32 USER UART init code enables nCTS+nRTS use?
I thought that the answer is yes, since: commit 3109973fe239e60f4ec223ce95ef1609ea329e7c Author: Fredrik Thulin <fred...@thulin.net> Date: Wed May 18 14:44:01 2016 +0200 A little more robust file transfer ... diff --git a/stm-init.c b/stm-init.c index ab1905b..4421b21 100644 @@ -122,7 +122,7 @@ static void MX_USART2_UART_Init(void) huart_user.Init.StopBits = UART_STOPBITS_1; huart_user.Init.Parity = UART_PARITY_NONE; huart_user.Init.Mode = UART_MODE_TX_RX; - huart_user.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart_user.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS; huart_user.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&huart_user) != HAL_OK) { ...but the answer is really no, hardware flow control has never worked on the Alpha. If anyone has experienced communication issues then this might well be why. A patch is attached. > In a couple of days I'll check if wiring them to my SAMD11 daughterboard2 > does anything. I've done this now. It turned out to be complicated, so it took a while. The daughterboard2 I use for SAMD11 firmware testing and development covered most of the FTDI chip so I soldered wires to the STM32 pins, which was fiddly, and then I had to desolder the FTDI chip, because it seems to drive RTS even when held in reset! >:( Then I observed that STM32 ignored CTS, guessed that initialization was incorrect, and learned the horrible HAL way to fix that. The good news is that a SAMD11 firmware using hardware flow control and interrupts, no DMA, sends RPC_GET_VERSION to STM32 and receives the response correctly every time, once the STM32 init code has been fixed. So the SAMD11 USB interface I propose has been tested, and is reliable. Kind regards //Peter
From e102894d7084e9a839ff8f2a889f8fe21d46f625 Mon Sep 17 00:00:00 2001 From: Peter Stuge <pe...@stuge.se> Date: Sat, 6 Jun 2020 04:00:31 +0200 Subject: [PATCH] stm-uart.c: Program CTS and RTS pins as alternate functions --- stm-uart.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/stm-uart.c b/stm-uart.c index f64c90c..9a5e53a 100644 --- a/stm-uart.c +++ b/stm-uart.c @@ -69,6 +69,20 @@ static void MX_DMA_Init(void) /* USART1 init function */ static void MX_USART1_UART_Init(void) { + GPIO_InitTypeDef g; + g.Mode = GPIO_MODE_AF_PP; + g.Pull = GPIO_NOPULL; + g.Speed = GPIO_SPEED_LOW; + g.Alternate = GPIO_AF7_USART1; + + /* USART1_CTS */ + g.Pin = GPIO_PIN_11; + HAL_GPIO_Init(GPIOA, &g); + + /* USART1_RTS */ + g.Pin = GPIO_PIN_12; + HAL_GPIO_Init(GPIOA, &g); + huart_mgmt.Instance = USART1; huart_mgmt.Init.BaudRate = USART_MGMT_BAUD_RATE; huart_mgmt.Init.WordLength = UART_WORDLENGTH_8B; @@ -90,6 +104,20 @@ static void MX_USART1_UART_Init(void) /* USART2 init function */ static void MX_USART2_UART_Init(void) { + GPIO_InitTypeDef g; + g.Mode = GPIO_MODE_AF_PP; + g.Pull = GPIO_NOPULL; + g.Speed = GPIO_SPEED_LOW; + g.Alternate = GPIO_AF7_USART2; + + /* USART2_CTS */ + g.Pin = GPIO_PIN_0; + HAL_GPIO_Init(GPIOA, &g); + + /* USART2_RTS */ + g.Pin = GPIO_PIN_1; + HAL_GPIO_Init(GPIOA, &g); + huart_user.Instance = USART2; huart_user.Init.BaudRate = USART_USER_BAUD_RATE; huart_user.Init.WordLength = UART_WORDLENGTH_8B; --
_______________________________________________ Tech mailing list Tech@cryptech.is https://lists.cryptech.is/listinfo/tech