X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/c830fcb0e1d42c1300ebe78a8b33924054b63a87..5930f47bf4b9b4490daf80d44595ff14ee7ce165:/Demos/Host/LowLevel/CDCHost/CDCHost.c diff --git a/Demos/Host/LowLevel/CDCHost/CDCHost.c b/Demos/Host/LowLevel/CDCHost/CDCHost.c index 0068a5951..c4322587e 100644 --- a/Demos/Host/LowLevel/CDCHost/CDCHost.c +++ b/Demos/Host/LowLevel/CDCHost/CDCHost.c @@ -36,8 +36,54 @@ #include "CDCHost.h" +#if 0 +/* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in + * can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string). + */ + +static int CDC_putchar(char c, FILE *stream) +{ + Pipe_SelectPipe(CDC_DATAPIPE_OUT); + + if (Pipe_WaitUntilReady()) + return -1; + + Pipe_Write_Byte(c); + Pipe_ClearIN(); + + return 0; +} + +static int CDC_getchar(FILE *stream) +{ + int c; + + Pipe_SelectPipe(CDC_DATAPIPE_IN); + + for (;;) + { + if (Pipe_WaitUntilReady()) + return -1; + + if (!(Pipe_BytesInPipe())) + { + Pipe_ClearOUT(); + } + else + { + c = Pipe_Read_Byte(); + break; + } + } + + return c; +} + +static FILE USBSerial = FDEV_SETUP_STREAM(CDC_putchar, CDC_getchar, _FDEV_SETUP_RW); +#endif + /** Main program entry point. This routine configures the hardware required by the application, then - * starts the scheduler to run the application tasks. + * enters a loop to run the application tasks in sequence. */ int main(void) { @@ -170,8 +216,9 @@ void CDC_Host_Task(void) USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: - /* Select and the data IN pipe */ + /* Select the data IN pipe */ Pipe_SelectPipe(CDC_DATAPIPE_IN); + Pipe_SetPipeToken(PIPE_TOKEN_IN); Pipe_Unfreeze(); /* Check to see if a packet has been received */