From 73d9fafc0fe42741ad8f609dd4762e2bc14cbd01 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 13 Jul 2009 12:38:30 +0000 Subject: Added new EEPROM and FLASH buffer versions of the Endpoint and Pipe stream functions. Changed Endpoint.c and Pipe.c to use a templated system to build the seperate functions, rather than duplicating each function's code many times. --- Demos/Device/Incomplete/Sideshow/Sideshow.c | 2 +- Demos/Device/LowLevel/CDC/CDC.c | 52 ++++++++++++++++++++++++- Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c | 2 +- 3 files changed, 52 insertions(+), 4 deletions(-) (limited to 'Demos/Device') diff --git a/Demos/Device/Incomplete/Sideshow/Sideshow.c b/Demos/Device/Incomplete/Sideshow/Sideshow.c index 8454f9de8..41e36cc70 100644 --- a/Demos/Device/Incomplete/Sideshow/Sideshow.c +++ b/Demos/Device/Incomplete/Sideshow/Sideshow.c @@ -131,7 +131,7 @@ void EVENT_USB_UnhandledControlPacket(void) Endpoint_ClearSETUP(); - Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); + Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); Endpoint_ClearOUT(); } diff --git a/Demos/Device/LowLevel/CDC/CDC.c b/Demos/Device/LowLevel/CDC/CDC.c index 99343894e..ac0623a4d 100644 --- a/Demos/Device/LowLevel/CDC/CDC.c +++ b/Demos/Device/LowLevel/CDC/CDC.c @@ -50,6 +50,54 @@ CDC_Line_Coding_t LineCoding = { .BaudRateBPS = 9600, .ParityType = Parity_None, .DataBits = 8 }; +#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) +{ + if (!(USB_IsConnected)) + return -1; + + Endpoint_SelectEndpoint(CDC_TX_EPNUM); + while (!(Endpoint_IsReadWriteAllowed())); + Endpoint_Write_Byte(c); + Endpoint_ClearIN(); + + return 0; +} + +static int CDC_getchar (FILE *stream) +{ + int c; + + Endpoint_SelectEndpoint(CDC_RX_EPNUM); + + for (;;) + { + if (!(USB_IsConnected)) + return -1; + + while (!(Endpoint_IsReadWriteAllowed())); + + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + } + else + { + c = Endpoint_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 contains the overall program flow, including initial * setup of all components and the main program loop. */ @@ -208,8 +256,8 @@ void CDC_Task(void) #if 0 /* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232 - handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code: - */ + * handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code: + */ USB_Notification_Header_t Notification = (USB_Notification_Header_t) { .NotificationType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), diff --git a/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c b/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c index 454d1b495..ced33390f 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c +++ b/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c @@ -112,7 +112,7 @@ void ProcessRNDISControlMessage(void) ResponseReady = true; - RNDIS_Initialize_Message_t* INITIALIZE_Message = (RNDIS_Initialize_Message_t*)&RNDISMessageBuffer; + RNDIS_Initialize_Message_t* INITIALIZE_Message = (RNDIS_Initialize_Message_t*)&RNDISMessageBuffer; RNDIS_Initialize_Complete_t* INITIALIZE_Response = (RNDIS_Initialize_Complete_t*)&RNDISMessageBuffer; INITIALIZE_Response->MessageType = REMOTE_NDIS_INITIALIZE_CMPLT; -- cgit v1.2.3