convert usart.c to cpp class

This commit is contained in:
2024-12-16 11:36:03 +01:00
parent e27ae40884
commit 7b7e783d68
8 changed files with 55 additions and 153 deletions

View File

@@ -67,47 +67,27 @@ void SystemClock_Config(void);
*/
int main(void) {
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
driver::usart::Usart usart2(USART2, 115200, UART_WORDLENGTH_8B, UART_STOPBITS_1,
UART_PARITY_NONE, UART_MODE_TX_RX, UART_HWCONTROL_NONE,
UART_OVERSAMPLING_16);
usart2.init();
/* USER CODE BEGIN 2 */
usart2.println("\r\nWeight cell init.");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
usart2.println("This is a pretty long string, exceeding TX bufsize. Hello, world!11!");
HAL_Delay(500);
/* USER CODE END WHILE */
usart2.println("\r\n Hello, world! cell init.");
/* USER CODE BEGIN 3 */
HAL_Delay(500);
}
/* USER CODE END 3 */
}
/**
@@ -139,8 +119,7 @@ void SystemClock_Config(void) {
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
/** Initializes the CPU, AHB and APB buses clocks */
RCC_ClkInitStruct.ClockType =
RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;