I would like to use serial driver on an stm32f4 discovery board.
I use SD1 in PB6 and PB7 bits. SerialDriver config is:
Code: Select all
static const SerialConfig serial_config ={
921600,
0,
USART_CR2_STOP1_BITS | USART_CR2_LINEN,
0
};
Init code is:
Code: Select all
palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOB, 7, PAL_MODE_INPUT_PULLUP);
I would like to use event driven option with:
Code: Select all
sdStart(&SD1, &serial_config);
event_listener_t serial_listener;
chEvtRegisterMaskWithFlags(chnGetEventSource(&SD_DRIVER),
&serial_listener,
EVENT_MASK(1),
CHN_INPUT_AVAILABLE);
while(TRUE) {
palSetPad(GPIOD, GPIOD_LED5);
eventmask_t evt = chEvtWaitAny(ALL_EVENTS);
if (evt & EVENT_MASK(1)) {
palTogglePad(GPIOD, GPIOD_LED5);
eventflags_t flags = chEvtGetAndClearFlags(&serial_listener);
if (flags&CHN_INPUT_AVAILABLE)
handle_serial_data(motorola);
}
chThdSleepMicroseconds(SERIAL_SLEEP_TIME_US);
}
I can send data to the serial port (I checked it with an oscilloscope), but I cannot get events on receive.
It enters chEvtWaitAny(ALL_EVENTS); and it cannot returns from it. I see the input in PB7.
Documentation said there is no need to init SerialDriver. Maybe I forgot to init anything?
Is there an example for event driven serial driver usage?
thx
Zamek