3 Commits

Author SHA1 Message Date
eeeck 11e50b05e4 Make debug print safer by checking if ST-Link debugger is connected 2026-06-18 09:10:00 +02:00
eeeck e951eaef7c Fix debug prints 2026-06-18 09:07:09 +02:00
eeeck ce25cba61b Fix typo 2026-06-18 09:06:07 +02:00
2 changed files with 16 additions and 8 deletions
+6 -3
View File
@@ -111,9 +111,12 @@ void vUARTLogger(void *argument)
{
DEBUG_PRINT("CAN frame detected\r\n");
int len = format_can_message(tx_buffer, message.source, &message);
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len);
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
DEBUG_PRINT("CAN frame sent via UART\r\n");
if (HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tx_buffer, len) == HAL_OK)
{
osSemaphoreAcquire(xUARTDMASemaphore, osWaitForever);
DEBUG_PRINT("CAN frame sent via UART\r\n");
}
else DEBUG_PRINT("HAL error, CAN frame NOT sent!\r\n");
}
}
}
+10 -5
View File
@@ -77,11 +77,16 @@ static void MX_SDIO_SD_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
int _write(int file, char *ptr, int len) {
for (int i = 0; i < len; i++) {
ITM_SendChar((*ptr++));
}
return len;
int _write(int file, char *ptr, int len)
{
if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && (ITM->TCR & ITM_TCR_ITMENA_Msk))
{
for (int i = 0; i < len; i++)
{
ITM_SendChar((*ptr++));
}
}
return len;
}
/* USER CODE END PFP */