aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2020-10-15 13:12:49 -0400
committerPaul Selkirk <paul@psgd.org>2020-10-15 13:39:19 -0400
commit2accd94bac96255de19d734341b0b95ed07e4b38 (patch)
tree7e9361c70c7794edb3e0bb542b15c253ae4539d4
parent314ba09b1447ec20c7ffad587691c83b965e7400 (diff)
Peter Stuge's fix for hardware flow control: Program CTS and RTS pins as alternate functions.
-rw-r--r--stm-uart.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/stm-uart.c b/stm-uart.c
index f64c90c..d07eec2 100644
--- a/stm-uart.c
+++ b/stm-uart.c
@@ -4,6 +4,8 @@
* Functions for sending strings and numbers over the uart.
*
* Copyright (c) 2015, NORDUnet A/S All rights reserved.
+ * Copyright: 2020, The Commons Conservancy Cryptech Project
+ * SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -15,9 +17,9 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * - Neither the name of the NORDUnet nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * - Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -69,6 +71,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 +106,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;