734820c137
* Targets: add F6 * F6: Update linker script for use with internal storage * F6: synchronize with F5, add all changes arriving in V9 board, update cube project. Github workflow: add multi-target build, add F6 to build targets. * CI: fix full assembly * CI: better artifact naming scheme * CI: fix artifacts wildcard * F6: Swap C10 - A15, vibro and sdcard detect pins
56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
#include "usart.h"
|
|
|
|
UART_HandleTypeDef huart1;
|
|
|
|
void MX_USART1_UART_Init(void) {
|
|
huart1.Instance = USART1;
|
|
huart1.Init.BaudRate = 115200;
|
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
|
huart1.Init.Parity = UART_PARITY_NONE;
|
|
huart1.Init.Mode = UART_MODE_TX_RX;
|
|
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
|
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
|
huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
|
|
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
|
|
|
if (HAL_UART_Init(&huart1) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
|
|
if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
|
|
if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
|
|
if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
}
|
|
|
|
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) {
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
if(uartHandle->Instance==USART1) {
|
|
|
|
__HAL_RCC_USART1_CLK_ENABLE();
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
GPIO_InitStruct.Pin = USART1_TX_Pin|USART1_RX_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
}
|
|
}
|
|
|
|
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) {
|
|
if(uartHandle->Instance==USART1) {
|
|
__HAL_RCC_USART1_CLK_DISABLE();
|
|
HAL_GPIO_DeInit(GPIOB, USART1_TX_Pin|USART1_RX_Pin);
|
|
}
|
|
}
|