Here is a simplified snippet of my code as it stands now. The function "ProcessSerial" will transfer data back and forth between 2x SPI channels and an USART channel. The USB printf is just for debugging purposes. My program functions as expected as long as a terminal is connected via the USB.
Code: Select all
// Make printf more normal.
#define printf(...) chprintf((BaseSequentialStream *)&SDU1, __VA_ARGS__)
...
int main(void) {
halInit();
chSysInit();
// Activates the USB serial driver and then the USB bus pull-up on D+.
// Note, a delay is inserted in order to not have to disconnect the cable after a reset.
sduObjectInit(&SDU1); // Clear the buffer to prevent old data from propagating.
sduStart(&SDU1, &serusbcfg);
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(2500);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(2500);
printf("Just booted Version 1\r\n");
while (true) {
...
ProcessSerial((unsigned char*)buffer); // <<<< Several printf's happen in this sub routine.
...
} // while true
I have debug enabled, and I stepped through chprintf. However it is written at a higher level than I was able to understand. So I was not able to identify if I could some how prevent the full buffer.
Perhaps I can change a parameter in usbcfg.c or similar to disable the handshake and prevent the full buffer. I'm OK with discarding extra data.
This is ChibiOS 20.3 with GCC 7.0