USART tx length fix, some experiments with cpp string manip

This commit is contained in:
2024-12-16 12:29:13 +01:00
parent 7b7e783d68
commit 17099b0047
4 changed files with 39 additions and 96 deletions

View File

@@ -1,70 +1,13 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include <cstdlib>
#include "gpio.h"
#include "stm32f4xx_hal.h"
#include "usart.hpp"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void) {
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
@@ -81,19 +24,19 @@ int main(void) {
UART_OVERSAMPLING_16);
usart2.init();
usart2.println("");
usart2.println("\r\nWeight cell init.");
while (1) {
usart2.println("\r\n Hello, world! cell init.");
int i{0};
HAL_Delay(500);
while (1) {
std::string buf{"Iteration #"};
usart2.println(buf + std::to_string(i++));
HAL_Delay(1000);
}
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
@@ -132,10 +75,6 @@ void SystemClock_Config(void) {
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None