I use UARTD1 (chibios 2.4.3) with RS485(soft RTS).
I have the problem: I don't receive rx callbacks.
TX callbacks work OK. stm32F100
Code: Select all
/*
* This callback is invoked when a transmission buffer has been completely
* read by the driver.
*/
static void txend1(UARTDriver *uartp)
{
(void)uartp;
palTogglePad(GPIOA, PA_RS485_LED);
}
/*
* This callback is invoked when a transmission has physically completed.
*/
static void txend2(UARTDriver *uartp)
{
(void)uartp;
palSetPad(GPIOA, PA_RS485_LED);
}
static void rxerr(UARTDriver *uartp, uartflags_t e) {
(void)uartp;
(void)e;
}
static void rxchar(UARTDriver *uartp, uint16_t c)
{
(void)uartp;
(void)c;
/* Flashing the LED each time a character is received.*/
palTogglePad(GPIOA, PA_RS485_LED);
}
static void rxend(UARTDriver *uartp)
{
(void)uartp;
}
UARTConfig uart_cfg_1 = {
txend1, /* End of Transmission buffer callback */
txend2, /* Physical end of transmission callback */
rxend, /* Receive buffer filled callback */
rxchar, /* Char received while out of the UART_RECEIVE state */
rxerr, /* Receive error callback */
19200, /* Baudrate */
USART_CR1_RXNEIE, /* cr1 register values */
0, /* cr2 register values */
0 /* cr3 register values */
};
int main(void)
{
halInit();
chSysInit();
/*
* Activates the uart driver 1
*/
uartStart(&UARTD1, &uart_cfg_1);
while (TRUE)
{
palSetPad(GPIOA, PA_RS485_RTS);
chThdSleepMilliseconds(20);
uartStartSend(&UARTD1, 14, "Hello world!\n\r"); // output works fine <<<<<<<<<<<<<<<<<<<<<<<-
chThdSleepMilliseconds(20);
palClearPad(GPIOA, PA_RS485_RTS);
chThdSleepMilliseconds(20);
uartStartReceive(&UARTD1, BUF_SZ, uart1_data.buffer); // nothing happens, callbacks dont work, when pressing smth in terminal
}
}