aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/LowLevel
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-13 12:38:30 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-13 12:38:30 +0000
commit73d9fafc0fe42741ad8f609dd4762e2bc14cbd01 (patch)
treed3ac19b144cbb6bb48b8b04bdf37f5f14fca976e /Demos/Device/LowLevel
parent1d26e78258c10dcca63e31e66732f1e525b5dade (diff)
downloadlufa-73d9fafc0fe42741ad8f609dd4762e2bc14cbd01.tar.gz
lufa-73d9fafc0fe42741ad8f609dd4762e2bc14cbd01.tar.bz2
lufa-73d9fafc0fe42741ad8f609dd4762e2bc14cbd01.zip
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.
Diffstat (limited to 'Demos/Device/LowLevel')
-rw-r--r--Demos/Device/LowLevel/CDC/CDC.c52
-rw-r--r--Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c2
2 files changed, 51 insertions, 3 deletions
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
+ * <stdio.h> 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;