[Cryptech-Commits] [sw/stm32] 01/08: Peter Stuge's fix for hardware flow control: Program CTS and RTS pins as alternate functions.

git at cryptech.is git at cryptech.is
Thu Oct 15 22:22:10 UTC 2020


This is an automated email from the git hooks/post-receive script.

paul at psgd.org pushed a commit to branch master
in repository sw/stm32.

commit 2accd94bac96255de19d734341b0b95ed07e4b38
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Thu Oct 15 13:12:49 2020 -0400

    Peter Stuge's fix for hardware flow control: Program CTS and RTS pins as alternate functions.
---
 stm-uart.c | 36 +++++++++++++++++++++++++++++++++---
 1 file 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;



More information about the Commits mailing list