summaryrefslogtreecommitdiff
path: root/usb-led2
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-06-22 02:13:15 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-06-22 02:13:15 +0200
commit653a3bdc8b5fc7938d633bf158fbc38dd9b8624c (patch)
tree2253e72f500298f7c950719f5043929e6d340338 /usb-led2
parentadded dualusbio lib and example for it (not fully working yet..) (diff)
improved dual usbio - fully working now
Diffstat (limited to 'usb-led2')
-rw-r--r--usb-led2/Makefile2
-rw-r--r--usb-led2/usb-led2.c22
2 files changed, 13 insertions, 11 deletions
diff --git a/usb-led2/Makefile b/usb-led2/Makefile
index 616bf62..f8cfc68 100644
--- a/usb-led2/Makefile
+++ b/usb-led2/Makefile
@@ -38,7 +38,7 @@ LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENAB
LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT
LUFA_OPTS += -D USB_MANUFACTURER="L\"equinox\"" -D USB_MANUFACTURER_LEN=7
-LUFA_OPTS += -D USB_PRODUCT="L\"spreadspace usb-led example\"" -D USB_PRODUCT_LEN=27
+LUFA_OPTS += -D USB_PRODUCT="L\"spreadspace usb-led2 example\"" -D USB_PRODUCT_LEN=28
LUFA_COMPONENTS := USB USBCLASS
diff --git a/usb-led2/usb-led2.c b/usb-led2/usb-led2.c
index 345f076..74d5bf2 100644
--- a/usb-led2/usb-led2.c
+++ b/usb-led2/usb-led2.c
@@ -31,15 +31,15 @@
#include "led.h"
#include "dualusbio.h"
-void handle_cmd1(uint8_t cmd)
+void handle_cmd(uint8_t cmd)
{
switch(cmd) {
case '0': led_off(); break;
case '1': led_on(); break;
case 't': led_toggle(); break;
- default: fprintf(&usbio_port1, "1: error\r\n"); return;
+ default: printf("std: error\r\n"); return;
}
- fprintf(&usbio_port1, "1: ok\r\n");
+ printf("std: ok\r\n");
}
void handle_cmd2(uint8_t cmd)
@@ -48,9 +48,9 @@ void handle_cmd2(uint8_t cmd)
case '0': led_on(); break;
case '1': led_off(); break;
case 't': led_toggle(); break;
- default: fprintf(&usbio_port2, "2: error\r\n"); return;
+ default: fprintf(usbio[1], "2: error\r\n"); return;
}
- fprintf(&usbio_port2, "2: ok\r\n");
+ fprintf(usbio[1], "2: ok\r\n");
}
int main(void)
@@ -63,19 +63,21 @@ int main(void)
dualusbio_init();
sei();
+ dualusbio_make_stdio(0);
+
for(;;) {
- int16_t BytesReceived = dualusbio_bytes_received(1);
+ int16_t BytesReceived = dualusbio_bytes_received(0);
while(BytesReceived > 0) {
- int ReceivedByte = fgetc(&usbio_port1);
+ int ReceivedByte = fgetc(stdin);
if(ReceivedByte != EOF) {
- handle_cmd1(ReceivedByte);
+ handle_cmd(ReceivedByte);
}
BytesReceived--;
}
- BytesReceived = dualusbio_bytes_received(2);
+ BytesReceived = dualusbio_bytes_received(1);
while(BytesReceived > 0) {
- int ReceivedByte = fgetc(&usbio_port2);
+ int ReceivedByte = fgetc(usbio[1]);
if(ReceivedByte != EOF) {
handle_cmd2(ReceivedByte);
}