aboutsummaryrefslogtreecommitdiff
path: root/src/entropy/stm_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/entropy/stm_init.c')
-rw-r--r--src/entropy/stm_init.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/entropy/stm_init.c b/src/entropy/stm_init.c
index 4bf35b5..5f69760 100644
--- a/src/entropy/stm_init.c
+++ b/src/entropy/stm_init.c
@@ -38,9 +38,6 @@
/* Includes ------------------------------------------------------------------*/
#include "stm_init.h"
-//#include "stm32f4xx_hal.h"
-//#include "stm32f4xx_hal_rcc.h"
-
/** @addtogroup STM32F4xx_HAL_Examples
* @{
@@ -54,6 +51,7 @@
/* Private define ------------------------------------------------------------*/
#define UART1_BAUD_RATE 460800
+#define UART2_BAUD_RATE 115200
/* Private macro -------------------------------------------------------------*/
@@ -62,6 +60,7 @@
static GPIO_InitTypeDef GPIO_InitStruct;
TIM_HandleTypeDef htim2;
UART_HandleTypeDef huart1;
+UART_HandleTypeDef huart2;
DMA_HandleTypeDef hdma_tim;
/* Private function prototypes -----------------------------------------------*/
@@ -70,6 +69,7 @@ static void Error_Handler(void);
static void MX_GPIO_Init(void);
static void MX_TIM2_Init(uint32_t *counters_buf, uint16_t counters);
static void MX_USART1_UART_Init(void);
+static void MX_USART2_UART_Init(void);
/* Private functions ---------------------------------------------------------*/
/**
@@ -103,6 +103,7 @@ void stm_init(uint32_t *buf0, uint16_t counters)
MX_GPIO_Init();
MX_TIM2_Init(buf0, counters);
MX_USART1_UART_Init();
+ MX_USART2_UART_Init();
}
@@ -153,7 +154,7 @@ static void SystemClock_Config(void)
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV8;
RCC_OscInitStruct.PLL.PLLQ = 7;
- if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
+ if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
@@ -163,7 +164,7 @@ static void SystemClock_Config(void)
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* AHB prescaler */
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; /* APB1 prescaler /1 gives 42 MHz APB1 */
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; /* APB2 prescaler /1 gives 42 MHz APB2 */
- if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
+ if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
Error_Handler();
}
@@ -251,13 +252,12 @@ void MX_TIM2_Init(uint32_t *counters_buf, uint16_t counters)
*/
void MX_USART1_UART_Init(void)
{
-
huart1.Instance = USART1;
huart1.Init.BaudRate = UART1_BAUD_RATE;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
- huart1.Init.Mode = UART_MODE_TX; /* Only Transmit */
+ huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
@@ -267,6 +267,24 @@ void MX_USART1_UART_Init(void)
}
}
+/* USART2 init function */
+void MX_USART2_UART_Init(void)
+{
+ huart2.Instance = USART2;
+ huart2.Init.BaudRate = UART2_BAUD_RATE;
+ huart2.Init.WordLength = UART_WORDLENGTH_8B;
+ huart2.Init.StopBits = UART_STOPBITS_1;
+ huart2.Init.Parity = UART_PARITY_NONE;
+ huart2.Init.Mode = UART_MODE_TX_RX;
+ huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ huart2.Init.OverSampling = UART_OVERSAMPLING_16;
+
+ if (HAL_UART_Init(&huart2) != HAL_OK) {
+ /* Initialization Error */
+ Error_Handler();
+ }
+}
+
/**
* @brief This function is executed in case of error occurrence.
@@ -276,7 +294,7 @@ void MX_USART1_UART_Init(void)
static void Error_Handler(void)
{
HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET);
- while(1) { ; }
+ while(1) { ; }
}
#ifdef USE_FULL_ASSERT