/* simple USB terminal demo */
/* This demo implements an */
/* USB virtual COM port, */
/* which echos all inputs */
/* in capital letters. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <avr/io.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#if (F_CPU != 32000000)
#warning clock should better be 32MHz - USB needs it
#endif
/* initialize the USB on chip hardware
* - also switches to 32MHz
* - enables medium priority interrupts
* - also enables global interrupts
*/
extern void USBInit(void);
/* process the USB */
extern void USBPoll(void);
extern FILE *USBtty0;
int main(void) {
/* Init the USB (and clock + interrupts) */
USBInit();
for (;;) {
/* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
int c = fgetc(USBtty0);
/* simple demo: implement an uppercase echo */
if (!(c<0)) {
fputc(toupper(c), USBtty0);
}
USBPoll();
}
}