diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-06-22 02:13:15 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-06-22 02:13:15 +0200 |
commit | 653a3bdc8b5fc7938d633bf158fbc38dd9b8624c (patch) | |
tree | 2253e72f500298f7c950719f5043929e6d340338 /usb-led2 | |
parent | added 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/Makefile | 2 | ||||
-rw-r--r-- | usb-led2/usb-led2.c | 22 |
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); } |