void stdio_usb_init(void) { stdio_base = NULL; ptr_put = stdio_usb_putchar; ptr_get = stdio_usb_getchar; /* * Start and attach USB CDC device interface for devices with * integrated USB interfaces. Assume the VBUS is present if * VBUS monitoring is not available. */ udc_start (); if (!udc_include_vbus_monitoring()) { stdio_usb_vbus_event(true); } #if defined(__GNUC__) # if XMEGA // For AVR GCC libc print redirection uses fdevopen. fdevopen((int (*)(char, FILE*))(_write),(int (*)(FILE*))(_read)); # endif # if UC3 || SAM // For AVR32 and SAM GCC // Specify that stdout and stdin should not be buffered. setbuf(stdout, NULL); setbuf(stdin, NULL); // Note: Already the case in IAR's Normal DLIB default configuration // and AVR GCC library: // - printf() emits one character at a time. // - getchar() requests only 1 byte to exit. # endif #endif }
void stdio_usb_init (volatile void * usart) { stdio_base = usart; ptr_put = stdio_usb_putchar; ptr_get = stdio_usb_getchar; /* * Start and attach USB CDC device interface for devices with * integrated USB interfaces. Assume the VBUS is present if * VBUS monitoring is not available. */ udc_start (); if (! udc_include_vbus_monitoring ()) { stdio_usb_vbus_event (true); } // For AVR GCC libc print redirection uses fdevopen. #if defined(XMEGA) && defined(__GNUC__) fdevopen((int (*)(char, FILE*))(_write),(int (*)(FILE*))(_read)); #endif }