From c4678339908e413cbc6751cf863267807acafc85 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Sun, 28 Jun 2015 16:30:08 +0200 Subject: Enable dual USART output functionality. In other words, enable the USART connected to the serial port on the Raspberry Pi GPIO header. Sending a newline to either USART directs the generated entropy to that USART. --- src/entropy/stm32f4xx_hal_msp.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/entropy/stm32f4xx_hal_msp.c') diff --git a/src/entropy/stm32f4xx_hal_msp.c b/src/entropy/stm32f4xx_hal_msp.c index fc27e04..536a78c 100644 --- a/src/entropy/stm32f4xx_hal_msp.c +++ b/src/entropy/stm32f4xx_hal_msp.c @@ -58,7 +58,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) */ GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; GPIO_InitStruct.Alternate = GPIO_AF7_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -66,6 +66,19 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) /* NVIC for interrupt mode */ HAL_NVIC_SetPriority(USART1_IRQn, 0, 1); HAL_NVIC_EnableIRQ(USART1_IRQn); + } else if (huart->Instance == USART2) { + /* Peripheral clock enable */ + __USART2_CLK_ENABLE(); + GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + GPIO_InitStruct.Alternate = GPIO_AF7_USART2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* NVIC for interrupt mode */ + HAL_NVIC_SetPriority(USART2_IRQn, 0, 1); + HAL_NVIC_EnableIRQ(USART2_IRQn); } } @@ -80,6 +93,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) PA10 ------> USART1_RX */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10); + } else if (huart->Instance == USART2) { + __USART2_CLK_DISABLE(); + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2 | GPIO_PIN_3); } } -- cgit v1.2.3