From 1bdf8d241ce064db58d64e4400d09290bfd805e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 12 Mar 2023 00:50:49 +0100 Subject: [PATCH] add some logging --- Core/Inc/FreeRTOSConfig.h | 3 ++- Core/Src/app_main.c | 4 +++- Core/Src/freertos.c | 2 ++ Core/Src/main.c | 6 +++++- Core/Src/stm32f1xx_it.c | 3 +++ Core/Src/usart.c | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index 98d95a1..ea38632 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -133,7 +133,8 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ /* USER CODE BEGIN 1 */ -#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +#include +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); printf("configASSERT "__FILE__":%d\r\n",__LINE__); for( ;; );} /* USER CODE END 1 */ /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS diff --git a/Core/Src/app_main.c b/Core/Src/app_main.c index 8884f65..d825a32 100644 --- a/Core/Src/app_main.c +++ b/Core/Src/app_main.c @@ -83,6 +83,7 @@ static void redraw_display() { void app_task_main(void *argument) { + printf("Main task\r\n"); app_analog_init(); app_buzzer_init(); app_knob_init(); @@ -97,6 +98,7 @@ void app_task_main(void *argument) bool any_change = true; uint32_t last_redraw = osKernelGetTickCount(); + printf("Loop\r\n"); for (;;) { // sampling is done in the heater loop @@ -144,7 +146,7 @@ void app_task_main(void *argument) any_change = false; // Blink - HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); + LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); } vTaskDelay(pdMS_TO_TICKS(10)); diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index dfbacd0..aa4f7a8 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -135,6 +135,7 @@ void vApplicationMallocFailedHook(void); /* USER CODE BEGIN 4 */ void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) { + printf("vApplicationStackOverflowHook\r\n"); /* Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called if a stack overflow is detected. */ @@ -144,6 +145,7 @@ void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) /* USER CODE BEGIN 5 */ void vApplicationMallocFailedHook(void) { + printf("vApplicationMallocFailedHook\r\n"); /* vApplicationMallocFailedHook() will only be called if configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook function that will get called if a call to pvPortMalloc() fails. diff --git a/Core/Src/main.c b/Core/Src/main.c index 1ca3e38..123994c 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -100,7 +100,7 @@ int main(void) MX_IWDG_Init(); MX_USART1_UART_Init(); MX_ADC1_Init(); - MX_DMA_Init(); +// MX_DMA_Init(); MX_TIM4_Init(); MX_TIM2_Init(); MX_TIM3_Init(); @@ -110,6 +110,7 @@ int main(void) // this ensures SysTick runs at 1000Hz - used for LL delays LL_Init1msTick(SystemCoreClock); + printf("Start.\r\n"); /* USER CODE END 2 */ /* Init scheduler */ @@ -117,6 +118,7 @@ int main(void) MX_FREERTOS_Init(); /* Start scheduler */ + printf("a\r\n"); osKernelStart(); /* We should never get here as control is now taken by the scheduler */ @@ -218,6 +220,7 @@ void Error_Handler(void) /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); + printf("Error_Handler\r\n"); while (1) { } @@ -234,6 +237,7 @@ void Error_Handler(void) */ void assert_failed(uint8_t *file, uint32_t line) { + printf("assert_failed\r\n"); /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c index 00ae483..78a4a35 100644 --- a/Core/Src/stm32f1xx_it.c +++ b/Core/Src/stm32f1xx_it.c @@ -103,6 +103,7 @@ void HardFault_Handler(void) void MemManage_Handler(void) { /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + printf("MemManage_Handler\r\n"); /* USER CODE END MemoryManagement_IRQn 0 */ while (1) @@ -118,6 +119,7 @@ void MemManage_Handler(void) void BusFault_Handler(void) { /* USER CODE BEGIN BusFault_IRQn 0 */ + printf("BusFault_Handler\r\n"); /* USER CODE END BusFault_IRQn 0 */ while (1) @@ -133,6 +135,7 @@ void BusFault_Handler(void) void UsageFault_Handler(void) { /* USER CODE BEGIN UsageFault_IRQn 0 */ + printf("UsageFault_Handler\r\n"); /* USER CODE END UsageFault_IRQn 0 */ while (1) diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 9166098..547bdba 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -83,8 +83,8 @@ void MX_USART1_UART_Init(void) int _write(int fd, const char *pcBuffer, const int iLength) { int cnt = iLength; while (cnt-- > 0) { - LL_USART_TransmitData8(USART_DEBUG, *pcBuffer++); while (!LL_USART_IsActiveFlag_TXE(USART_DEBUG)) {} + LL_USART_TransmitData8(USART_DEBUG, *pcBuffer++); } return iLength; }