From ce3ea6fb2513d3aa14c354e2ed78c7eb4a38ee0e Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 30 Jul 2009 10:54:57 +0000 Subject: [PATCH] Added standard stream example to the ClassDriver CDC device demo. Fix incorrect HWB button mask in the STK526 Buttons driver. --- Demos/Device/ClassDriver/CDC/CDC.c | 22 ++++++++++++++++++++++ Demos/Device/LowLevel/CDC/CDC.c | 4 ++-- LUFA/Drivers/Board/STK526/Buttons.h | 2 +- LUFA/ManPages/ChangeLog.txt | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Demos/Device/ClassDriver/CDC/CDC.c b/Demos/Device/ClassDriver/CDC/CDC.c index 3e83ec2696..836a6e098f 100644 --- a/Demos/Device/ClassDriver/CDC/CDC.c +++ b/Demos/Device/ClassDriver/CDC/CDC.c @@ -57,6 +57,28 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = }, }; +#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) +{ + CDC_Device_SendByte(&VirtualSerial_CDC_Interface, c); + return 0; +} + +static int CDC_getchar(FILE *stream) +{ + if (!(CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface))) + return -1; + + return CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); +} + +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. */ diff --git a/Demos/Device/LowLevel/CDC/CDC.c b/Demos/Device/LowLevel/CDC/CDC.c index e63257dbdc..8a992c7670 100644 --- a/Demos/Device/LowLevel/CDC/CDC.c +++ b/Demos/Device/LowLevel/CDC/CDC.c @@ -55,7 +55,7 @@ CDC_Line_Coding_t LineCoding = { .BaudRateBPS = 9600, * 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) +static int CDC_putchar(char c, FILE *stream) { Endpoint_SelectEndpoint(CDC_TX_EPNUM); @@ -71,7 +71,7 @@ static int CDC_putchar (char c, FILE *stream) return 0; } -static int CDC_getchar (FILE *stream) +static int CDC_getchar(FILE *stream) { int c; diff --git a/LUFA/Drivers/Board/STK526/Buttons.h b/LUFA/Drivers/Board/STK526/Buttons.h index fba578cb20..9d392f2dee 100644 --- a/LUFA/Drivers/Board/STK526/Buttons.h +++ b/LUFA/Drivers/Board/STK526/Buttons.h @@ -64,7 +64,7 @@ /* Public Interface - May be used in end-application: */ /* Macros: */ /** Button mask for the first button on the board. */ - #define BUTTONS_BUTTON1 (1 << 2) + #define BUTTONS_BUTTON1 (1 << 7) /* Inline Functions: */ #if !defined(__DOXYGEN__) diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 483e0a6fd6..02146a20a0 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -76,6 +76,7 @@ * - Fixed incorrect PIPE_EPNUM_MASK mask causing pipe failures on devices with endpoint addresses of 8 and above (thanks to John Andrews) * - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits * - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered + * - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target * * * \section Sec_ChangeLog090605 Version 090605