audioMux/firmware/Src/usbd_cdc_syscalls.c
Julian Daube 41ee7ab012 firmware: completed
firmware accepts commands over usb and
switches inputs based on button presses
2019-10-20 19:18:52 +02:00

28 lines
457 B
C

#include "usbd_cdc_if.h"
const long USB_SEND_TIMEOUT = 10000L;
uint8_t buffer[128];
volatile int bufferindex = 0;
void __io_flush() {
long count = 0;
while(count < USB_SEND_TIMEOUT && CDC_Transmit_FS(buffer, bufferindex) == USBD_BUSY) {
++count;
}
bufferindex = 0;
}
int __io_putchar( int ch )
{
if (ch == '\n') __io_putchar('\r');
buffer[bufferindex++] = ch;
if (ch == '\n' || bufferindex == sizeof(buffer)) __io_flush();
return 1;
}