Move to PFP block in main.c and use more standard logic
This commit is contained in:
+74
-84
@@ -1,84 +1,74 @@
|
|||||||
/* USER CODE BEGIN Header */
|
/* USER CODE BEGIN Header */
|
||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @file : main.h
|
* @file : main.h
|
||||||
* @brief : Header for main.c file.
|
* @brief : Header for main.c file.
|
||||||
* This file contains the common defines of the application.
|
* This file contains the common defines of the application.
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* Copyright (c) 2026 STMicroelectronics.
|
* Copyright (c) 2026 STMicroelectronics.
|
||||||
* Copyright (c) 2026 Erick Ahmed.
|
* Copyright (c) 2026 Erick Ahmed.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
#ifndef __MAIN_H
|
#ifndef __MAIN_H
|
||||||
#define __MAIN_H
|
#define __MAIN_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f4xx_hal.h"
|
#include "stm32f4xx_hal.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "canlog.h"
|
#include "canlog.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN ET */
|
/* USER CODE BEGIN ET */
|
||||||
|
|
||||||
/* USER CODE END ET */
|
/* USER CODE END ET */
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
/* Exported constants --------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EC */
|
/* USER CODE BEGIN EC */
|
||||||
|
|
||||||
/* USER CODE END EC */
|
/* USER CODE END EC */
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EM */
|
/* USER CODE BEGIN EM */
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static inline void ITM_Print(const char *str) {
|
#include <stdio.h>
|
||||||
while (*str) {
|
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
|
||||||
uint32_t timeout = 1000;
|
#else
|
||||||
while ((ITM->PORT[0].u32 == 0) && (timeout-- > 0));
|
#define DEBUG_PRINT(...)
|
||||||
|
#endif
|
||||||
if (timeout > 0) {
|
/* USER CODE END EM */
|
||||||
ITM->PORT[0].u8 = (uint8_t)(*str);
|
|
||||||
}
|
/* Exported functions prototypes ---------------------------------------------*/
|
||||||
str++;
|
void Error_Handler(void);
|
||||||
}
|
|
||||||
}
|
/* USER CODE BEGIN EFP */
|
||||||
#define DEBUG_PRINT(x) ITM_Print(x)
|
|
||||||
#else
|
/* USER CODE END EFP */
|
||||||
#define DEBUG_PRINT(x)
|
|
||||||
#endif
|
/* Private defines -----------------------------------------------------------*/
|
||||||
/* USER CODE END EM */
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
/* Exported functions prototypes ---------------------------------------------*/
|
|
||||||
void Error_Handler(void);
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
/* USER CODE BEGIN EFP */
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
/* USER CODE END EFP */
|
#endif
|
||||||
|
|
||||||
/* Private defines -----------------------------------------------------------*/
|
#endif /* __MAIN_H */
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
|
||||||
|
|
||||||
/* USER CODE END Private defines */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __MAIN_H */
|
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ static void MX_SDIO_SD_Init(void);
|
|||||||
static void MX_USART1_UART_Init(void);
|
static void MX_USART1_UART_Init(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
int _write(int file, char *ptr, int len) {
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
ITM_SendChar((*ptr++));
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user