Hi all,
I'm trying to build a small software that is using DMA for STM32.
When I'm trying to define HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) the complier is failing with:
..\libraries\SrcWrapper\stm32\uart.c.o: in function `HAL_UART_RxCpltCallback':
uart.c:(.text.HAL_UART_RxCpltCallback+0x0): multiple definition of `HAL_UART_RxCpltCallback'; .. IR_RC_Airwell.ino.cpp:(.text.HAL_UART_RxCpltCallback+0x0): first defined here
This function is defined stm32f4xx_hal_uart.c in stm32core libraries as:
/**
* @brief Rx Transfer completed callbacks.
* @param huart Pointer to a UART_HandleTypeDef structure that contains
* the configuration information for the specified UART module.
* @retval None
*/
__weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(huart);
/* NOTE: This function should not be modified, when the callback is needed,
the HAL_UART_RxCpltCallback could be implemented in the user file
*/
}
My function is written like this in my IR_RC_Airwell.ino:
..
void setup() {
// put your setup code here, to run once:
SerialUSB.begin(1152000);
SerialUSB.setTimeout(100);
memset(serUSB, '\0', BUFSIZE);
HAL_UART_Receive_DMA (&huart1, UART1_rxBuffer, 12);
}
void loop() {
}
void TestFunction(char *buf) {
/* Prevent unused argument(s) compilation warning */
//UNUSED(buf);
/* NOTE: This function should not be modified, when the callback is needed,
the TestFunction could be implemented in the user file
*/
SerialUSB.print(buf);
SerialUSB.print("\n");
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
SerialUSB.print("OK");
SerialUSB.print("\n");
//HAL_UART_Transmit(&huart1, UART1_rxBuffer, 12, 100);
//HAL_UART_Receive_DMA(&huart1, UART1_rxBuffer, 12);
}
I've repicate a test function in test.cpp and test.h:
#include "test.h"
__weak void TestFunction(char *buf) {
/* Prevent unused argument(s) compilation warning */
UNUSED(buf);
/* NOTE: This function should not be modified, when the callback is needed,
the TestFunction could be implemented in the user file
*/
}
and my test.h:
#if defined ( __GNUC__ )
#ifndef __weak
#define __weak __attribute__((weak))
#endif /* __weak */
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif /* __packed */
#endif /* __GNUC__ */
#define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
void TestFunction(char *);
And this function is working without any issues.
What I'm doing wrong?
Kind regards.