Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63e3e81986 | |||
| 84ea393dd6 |
@@ -24,7 +24,19 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
static inline void ITM_Print(const char *str) {
|
||||
while (*str) {
|
||||
uint32_t timeout = 1000;
|
||||
while ((ITM->PORT[0].u32 == 0) && (timeout-- > 0));
|
||||
|
||||
if (timeout > 0) {
|
||||
ITM->PORT[0].u8 = (uint8_t)(*str);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
#define DEBUG_PRINT(x) ITM_Print(x)
|
||||
#else
|
||||
#define DEBUG_PRINT(x)
|
||||
|
||||
+16
-16
@@ -95,7 +95,7 @@ int main(void)
|
||||
ITM->LAR = 0xC5ACCE55;
|
||||
ITM->TER = 1 << 0;
|
||||
ITM->TCR = ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_SWOENA_Msk;
|
||||
ITM_Print("Booting system\r\n");
|
||||
DEBUG_PRINT("Booting system\r\n");
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
@@ -104,7 +104,7 @@ int main(void)
|
||||
HAL_Init();
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
ITM_Print("Configuring system clock\r\n");
|
||||
DEBUG_PRINT("Configuring system clock\r\n");
|
||||
|
||||
/* USER CODE END Init */
|
||||
|
||||
@@ -112,7 +112,7 @@ int main(void)
|
||||
SystemClock_Config();
|
||||
|
||||
/* USER CODE BEGIN SysInit */
|
||||
ITM_Print("Initializing configured peripherals...\r\n");
|
||||
DEBUG_PRINT("Initializing configured peripherals...\r\n");
|
||||
/* USER CODE END SysInit */
|
||||
|
||||
/* Initialize all configured peripherals */
|
||||
@@ -123,14 +123,14 @@ int main(void)
|
||||
MX_SDIO_SD_Init();
|
||||
MX_USART1_UART_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
ITM_Print("Initializing CAN bus logger\r\n");
|
||||
DEBUG_PRINT("Initializing CAN bus logger\r\n");
|
||||
CAN_Logger_Init(&hcan1, &hcan2);
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Init scheduler */
|
||||
osKernelInitialize();
|
||||
|
||||
ITM_Print("Creating RTOS entities\r\n");
|
||||
DEBUG_PRINT("Creating RTOS entities\r\n");
|
||||
|
||||
/* USER CODE BEGIN RTOS_TASKS */
|
||||
const osThreadAttr_t CAN1rxAttributes = {
|
||||
@@ -191,7 +191,7 @@ int main(void)
|
||||
/* USER CODE END RTOS_EVENTS */
|
||||
|
||||
/* Start scheduler */
|
||||
ITM_Print("Starting RTOS init scheduler\r\n");
|
||||
DEBUG_PRINT("Starting RTOS init scheduler\r\n");
|
||||
osKernelStart();
|
||||
|
||||
/* We should never get here as control is now taken by the scheduler */
|
||||
@@ -203,7 +203,7 @@ int main(void)
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
ITM_Print("Error: RTOS scheduler crashed!\r\n");
|
||||
DEBUG_PRINT("ERROR: RTOS scheduler crashed!\r\n");
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ static void MX_CAN1_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN CAN1_Init 2 */
|
||||
ITM_Print("CAN1 initialized!\r\n");
|
||||
DEBUG_PRINT("CAN1 initialized!\r\n");
|
||||
/* USER CODE END CAN1_Init 2 */
|
||||
|
||||
}
|
||||
@@ -323,7 +323,7 @@ static void MX_CAN2_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN CAN2_Init 2 */
|
||||
ITM_Print("CAN2 initialized!\r\n");
|
||||
DEBUG_PRINT("CAN2 initialized!\r\n");
|
||||
/* USER CODE END CAN2_Init 2 */
|
||||
|
||||
}
|
||||
@@ -359,7 +359,7 @@ static void MX_SDIO_SD_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SDIO_Init 2 */
|
||||
ITM_Print("SDIO initialized!\r\n");
|
||||
DEBUG_PRINT("SDIO initialized!\r\n");
|
||||
/* USER CODE END SDIO_Init 2 */
|
||||
|
||||
}
|
||||
@@ -392,7 +392,7 @@ static void MX_USART1_UART_Init(void)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART1_Init 2 */
|
||||
ITM_Print("USART1 initialized!\r\n");
|
||||
DEBUG_PRINT("USART1 initialized!\r\n");
|
||||
/* USER CODE END USART1_Init 2 */
|
||||
|
||||
}
|
||||
@@ -415,7 +415,7 @@ static void MX_DMA_Init(void)
|
||||
HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
|
||||
|
||||
/* USER CODE BEGIN MX_DMA_Init 1 */
|
||||
ITM_Print("DMA initialized!\r\n");
|
||||
DEBUG_PRINT("DMA initialized!\r\n");
|
||||
/* USER CODE END MX_DMA_Init 1 */
|
||||
}
|
||||
|
||||
@@ -479,15 +479,15 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PB3 PB4 PB5 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
|
||||
/*Configure GPIO pins : PB4 PB5 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||
ITM_Print("GPIO initialized!\r\n");
|
||||
DEBUG_PRINT("GPIO initialized!\r\n");
|
||||
/* USER CODE END MX_GPIO_Init_2 */
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
*/
|
||||
void Error_Handler(void)
|
||||
{
|
||||
ITM_Print("ERROR: entering error handler\r\n");
|
||||
DEBUG_PRINT("ERROR: entering error handler\r\n");
|
||||
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
|
||||
Reference in New Issue
Block a user