2022-02-24 02:11 PM
Here is my c++ code:
void print_console(std::string msg)
{
const char *p = msg.c_str();
HAL_UART_Transmit_DMA(CONSOLE, p, strlen(msg));
while (console_tx_flag == 0); // Wait until the uart transmit is complete
console_tx_flag = 0;
}
Does anyone know how to fix this? The error is pointing to the HAL_UART_Transmis_DMA()
Thank you!
Solved! Go to Solution.
2022-02-24 03:34 PM
I figured it out, thanks you: HAL_UART_Transmit_DMA(CONSOLE, (uint8_t *)p, strlen(p));
2022-02-24 02:30 PM
HAL_UART_Transmit_DMA(CONSOLE, p, strlen(p));
2022-02-24 02:41 PM
361 void print_console(std::string msg)
362 {
363 const char *p = msg.c_str();
364 HAL_UART_Transmit_DMA(CONSOLE, p, strlen(p));
365 while (console_tx_flag == 0); // Wait until the uart transmit is complete
366 console_tx_flag = 0;
367 }
yields the following errors:
Description Resource Path Location Type
invalid conversion from 'const char*' to 'const uint8_t*' {aka 'const unsigned char*'} [-fpermissive] main.cpp /STM32-SPI-Slave/Core/Src line 364 C/C++ Problem
make: *** [Core/Src/subdir.mk:58: Core/Src/main.o] Error 1 STM32-SPI-Slave C/C++ Problem
initializing argument 2 of 'HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef*, const uint8_t*, uint16_t)' stm32g4xx_hal_uart.h /STM32-SPI-Slave/Drivers/STM32G4xx_HAL_Driver/Inc line 1615 C/C++ Problem
2022-02-24 03:34 PM
I figured it out, thanks you: HAL_UART_Transmit_DMA(CONSOLE, (uint8_t *)p, strlen(p));