Removed SerialStream module, rolled functionality into the base USART Serial peripheral driver instead through the new Serial_CreateStream() and Serial_CreateBlockingStream() methods.

Renamed the Serial byte send/receive functions to remain consistent with the CDC driver's byte functions.

Altered the serial byte receive function to make it non-blocking.
This commit is contained in:
Dean Camera 2011-01-30 19:47:31 +00:00
parent 30f6d2bfd8
commit afd828c095
107 changed files with 518 additions and 560 deletions

View File

@ -41,7 +41,7 @@
#include <avr/pgmspace.h>
#include <stdio.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "EthernetProtocols.h"
#include "Ethernet.h"

View File

@ -104,8 +104,11 @@ void SetupHardware(void)
/* Hardware Initialization */
LEDs_Init();
SerialStream_Init(9600, false);
Serial_Init(9600, false);
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the library USB Connection event. */

View File

@ -52,7 +52,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Stream.h>
#include <LUFA/Drivers/USB/USB.h>
/* Macros: */

View File

@ -149,8 +149,7 @@ SRC = $(TARGET).c \
Lib/Webserver.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -80,7 +80,10 @@ void SetupHardware(void)
/* Hardware Initialization */
LEDs_Init();
USB_Init();
SerialStream_Init(9600, false);
Serial_Init(9600, false);
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
void EVENT_USB_Device_Connect(void)

View File

@ -43,7 +43,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
/* Macros: */
/** Device control request for used in the Microsoft OS Descriptor for retrieving the OS Feature

View File

@ -135,8 +135,7 @@ SRC = $(TARGET).c \
Lib/SideshowCommon.c \
Lib/SideshowContent.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -41,7 +41,7 @@
#include <avr/pgmspace.h>
#include <stdio.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "EthernetProtocols.h"
#include "Ethernet.h"

View File

@ -71,8 +71,11 @@ void SetupHardware(void)
/* Hardware Initialization */
LEDs_Init();
SerialStream_Init(9600, false);
Serial_Init(9600, false);
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and

View File

@ -149,8 +149,7 @@ SRC = $(TARGET).c \
Lib/Webserver.c \
Lib/RNDIS.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -76,11 +76,14 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
Joystick_Init();
Buttons_Init();
USB_Init(USB_MODE_UID);
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the library USB mode change event. */

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/Board/Buttons.h>

View File

@ -133,8 +133,7 @@ SRC = $(TARGET).c \
HostFunctions.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -182,9 +182,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -174,9 +174,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -200,9 +200,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -141,11 +141,14 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
Buttons_Init();
Joystick_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
void CheckJoystickMovement(void)

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Board/Joystick.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -243,9 +243,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -129,8 +129,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -161,9 +161,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -191,9 +191,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -165,9 +165,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -190,9 +190,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,6 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -159,9 +159,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -61,7 +61,7 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface =
int main(void)
{
SetupHardware();
puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
@ -135,9 +135,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_USBCLASS) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -45,7 +45,7 @@
#include "Lib/SDP.h"
#include "Lib/RFCOMM.h"
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */

View File

@ -77,9 +77,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -52,7 +52,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */

View File

@ -43,7 +43,7 @@
#include <stdio.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "BluetoothStack.h"

View File

@ -43,7 +43,7 @@
#include <stdio.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "BluetoothStack.h"
#include "BluetoothClassCodes.h"

View File

@ -44,7 +44,7 @@
#include <stdio.h>
#include <LUFA/Common/Common.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "BluetoothStack.h"
#include "RFCOMMControl.h"

View File

@ -44,7 +44,7 @@
#include <stdio.h>
#include <LUFA/Common/Common.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "BluetoothStack.h"
#include "RFCOMM.h"

View File

@ -44,7 +44,7 @@
#include <stdio.h>
#include <LUFA/Common/Common.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include "BluetoothStack.h"
#include "SDPServices.h"

View File

@ -137,8 +137,7 @@ SRC = $(TARGET).c \
Lib/RFCOMM.c \
Lib/RFCOMMControl.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include "ConfigDescriptor.h"

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
ConfigDescriptor.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -129,8 +129,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
HIDReport.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include "ConfigDescriptor.h"

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
ConfigDescriptor.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -42,7 +42,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include "ConfigDescriptor.h"

View File

@ -129,8 +129,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
HIDReport.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,11 +66,14 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
Buttons_Init();
Joystick_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Board/Joystick.h>

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
ConfigDescriptor.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -70,10 +70,13 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
Buttons_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -53,7 +53,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h>

View File

@ -130,8 +130,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
Lib/MassStoreCommands.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include "ConfigDescriptor.h"

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
ConfigDescriptor.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -46,7 +46,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h>

View File

@ -129,8 +129,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
HIDReport.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -51,7 +51,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */

View File

@ -129,8 +129,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
Lib/PrinterCommands.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include "Lib/RNDISCommands.h"

View File

@ -129,8 +129,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
Lib/RNDISCommands.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -67,9 +67,12 @@ void SetupHardware(void)
CLKPR = 0;
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -49,7 +49,7 @@
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */

View File

@ -129,8 +129,7 @@ SRC = $(TARGET).c \
ConfigDescriptor.c \
Lib/StillImageCommands.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

View File

@ -66,9 +66,12 @@ void SetupHardware(void)
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
Serial_Init(9600, false);
LEDs_Init();
USB_Init();
/* Create a stdio stream for the serial port for stdin and stdout */
Serial_CreateStream(NULL);
}
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and

View File

@ -47,7 +47,7 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Peripheral/Serial.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include "ConfigDescriptor.h"

View File

@ -128,8 +128,7 @@ include $(LUFA_PATH)/LUFA/makefile
SRC = $(TARGET).c \
ConfigDescriptor.c \
$(LUFA_SRC_USB) \
$(LUFA_SRC_SERIAL) \
$(LUFA_SRC_SERIALSTREAM)
$(LUFA_SRC_SERIAL)
# List C++ source files here. (C dependencies are automatically generated.)

File diff suppressed because one or more lines are too long

View File

@ -30,24 +30,53 @@
#include "Serial.h"
void Serial_TxString_P(const char* FlashStringPtr)
FILE USARTSerialStream;
int Serial_putchar(char DataByte,
FILE *Stream)
{
(void)Stream;
Serial_SendByte(DataByte);
return 0;
}
int Serial_getchar(FILE *Stream)
{
(void)Stream;
if (!(Serial_IsCharReceived()))
return _FDEV_EOF;
return Serial_ReceiveByte();
}
int Serial_getchar_Blocking(FILE *Stream)
{
(void)Stream;
while (!(Serial_IsCharReceived()));
return Serial_ReceiveByte();
}
void Serial_SendString_P(const char* FlashStringPtr)
{
uint8_t CurrByte;
while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)
{
Serial_TxByte(CurrByte);
Serial_SendByte(CurrByte);
FlashStringPtr++;
}
}
void Serial_TxString(const char* StringPtr)
void Serial_SendString(const char* StringPtr)
{
uint8_t CurrByte;
while ((CurrByte = *StringPtr) != 0x00)
{
Serial_TxByte(CurrByte);
Serial_SendByte(CurrByte);
StringPtr++;
}
}

View File

@ -70,6 +70,7 @@
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <stdbool.h>
#include <stdio.h>
#include "../../Common/Common.h"
#include "../Misc/TerminalCodes.h"
@ -79,6 +80,18 @@
extern "C" {
#endif
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* External Variables: */
extern FILE USARTSerialStream;
/* Function Prototypes: */
int Serial_putchar(char DataByte,
FILE *Stream);
int Serial_getchar(FILE *Stream);
int Serial_getchar_Blocking(FILE *Stream);
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
@ -96,14 +109,14 @@
*
* \param[in] FlashStringPtr Pointer to a string located in program space.
*/
void Serial_TxString_P(const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);
void Serial_SendString_P(const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);
/** Transmits a given string located in SRAM memory through the USART.
*
* \param[in] StringPtr Pointer to a string located in SRAM space.
*/
void Serial_TxString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1);
void Serial_SendString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1);
/* Inline Functions: */
/** Initializes the USART, ready for serial data transmission and reception. This initializes the interface to
* standard 8-bit, no parity, 1 stop bit settings suitable for most applications.
@ -137,6 +150,52 @@
PORTD &= ~(1 << 2);
}
/** Creates a standard character stream from the USART so that it can be used with all the regular functions
* in the avr-libc \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
* stream is bidirectional and can be used for both input and output functions.
*
* Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
* fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
* be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
* line buffering.
*
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL stdio
* and stdin will be configured to use the USART.
*
* \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.
*/
static inline void Serial_CreateStream(FILE* Stream)
{
if (!(Stream))
{
Stream = &USARTSerialStream;
stdin = Stream;
stdout = Stream;
}
*Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW);
}
/** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates
* the transfer.
*
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL stdio
* and stdin will be configured to use the USART.
*
* \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.
*/
static inline void Serial_CreateBlockingStream(FILE* Stream)
{
if (!(Stream))
{
Stream = &USARTSerialStream;
stdin = Stream;
stdout = Stream;
}
*Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW);
}
/** Indicates whether a character has been received through the USART.
*
* \return Boolean \c true if a character has been received, \c false otherwise.
@ -151,23 +210,23 @@
*
* \param[in] DataByte Byte to transmit through the USART.
*/
static inline void Serial_TxByte(const char DataByte) ATTR_ALWAYS_INLINE;
static inline void Serial_TxByte(const char DataByte)
static inline void Serial_SendByte(const char DataByte) ATTR_ALWAYS_INLINE;
static inline void Serial_SendByte(const char DataByte)
{
while (!(UCSR1A & (1 << UDRE1)));
UDR1 = DataByte;
}
/** Receives a byte from the USART. This function blocks until a byte has been
* received; if non-blocking behaviour is required, test for a received character
* beforehand with \ref Serial_IsCharReceived().
/** Receives the next byte from the USART.
*
* \return Byte received from the USART.
* \return Next byte received from the USART, or a negative value if no byte has been received.
*/
static inline char Serial_RxByte(void) ATTR_ALWAYS_INLINE;
static inline char Serial_RxByte(void)
static inline int16_t Serial_ReceiveByte(void) ATTR_ALWAYS_INLINE;
static inline int16_t Serial_ReceiveByte(void)
{
while (!(UCSR1A & (1 << RXC1)));
if (!(Serial_IsCharReceived()))
return -1;
return UDR1;
}

View File

@ -1,54 +0,0 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#define __INCLUDE_FROM_SERIALSTREAM_C
#include "SerialStream.h"
FILE USARTStream = FDEV_SETUP_STREAM(SerialStream_TxByte, SerialStream_RxByte, _FDEV_SETUP_RW);
static int SerialStream_TxByte(char DataByte,
FILE *Stream)
{
(void)Stream;
Serial_TxByte(DataByte);
return 0;
}
static int SerialStream_RxByte(FILE *Stream)
{
(void)Stream;
if (!(Serial_IsCharReceived()))
return _FDEV_EOF;
return Serial_RxByte();
}

View File

@ -1,139 +0,0 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
* \brief Standard avr-libc character stream driver for the USART.
*
* Serial stream driver for the USART subsystem on supported USB AVRs. This makes use of the functions in the
* regular USART driver (see \ref Group_Serial), but allows the avr-libc standard stream functions (\c printf,
* \c puts, etc.) to work with the
* USART.
*/
/** \ingroup Group_PeripheralDrivers
* @defgroup Group_SerialStream Serial Stream Driver - LUFA/Drivers/Peripheral/SerialStream.h
*
* \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module:
* - LUFA/Drivers/Peripheral/SerialStream.c <i>(Makefile source module name: LUFA_SRC_SERIALSTREAM)</i>
*
* \section Sec_ModDescription Module Description
* Serial stream driver for the USART subsystem on supported USB AVRs. This makes use of the functions in the
* regular USART driver (see \ref Group_Serial), but allows the avr-libc standard stream functions (\c printf,
* \c puts, etc.) to work with the USART. Upon configuration, this will redirect the \c stdin standard input
* and \c stdout output streams to the USART.
*
* \section Sec_ExampleUsage Example Usage
* The following snippet is an example of how this module may be used within a typical
* application.
*
* \code
* // Initialise the Serial Stream driver before first use, with 9600 baud (and no double-speed mode)
* SerialStream_Init(9600, false);
*
* // Write a string to the USART via the implicit stdout stream
* printf("Test String using stdout\r\n");
*
* // Write a string to the USART via the explicit USART stream
* fprintf(&USARTStream, "Test String using explicit stream handle\r\n");
*
* // Read in an integer from the USART using the implicit stdin stream
* uint16_t TestValue;
* scanf("%d", &TestValue);
* \endcode
*
* @{
*/
#ifndef __SERIAL_STREAM_H__
#define __SERIAL_STREAM_H__
/* Includes: */
#include <avr/io.h>
#include <stdio.h>
#include "Serial.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
#endif
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Function Prototypes: */
#if defined(__INCLUDE_FROM_SERIALSTREAM_C)
static int SerialStream_TxByte(char DataByte,
FILE *Stream) ATTR_NON_NULL_PTR_ARG(2);
static int SerialStream_RxByte(FILE *Stream) ATTR_NON_NULL_PTR_ARG(1);
#endif
#endif
/* Public Interface - May be used in end-application: */
/* External Variables: */
/** Named stream for the USART, once \ref SerialStream_Init() has been called. This may be used with the
* file based stream functions (fprintf, fscanf, etc.) that require a handle to the stream rather than
* using the stdin and stdout named streams.
*/
extern FILE USARTStream;
/* Inline Functions: */
/** Initialises the serial stream (and regular USART driver) so that both the stream and regular
* USART driver functions can be used. Must be called before any stream or regular USART functions.
*
* \param[in] BaudRate Baud rate to configure the USART to.
* \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate.
*/
static inline void SerialStream_Init(const uint32_t BaudRate,
const bool DoubleSpeed)
{
Serial_Init(BaudRate, DoubleSpeed);
stdout = &USARTStream;
stdin = &USARTStream;
}
/** Turns off the serial stream (and regular USART driver), disabling and returning used hardware to
* their default configuration.
*/
static inline void SerialStream_ShutDown(void)
{
Serial_ShutDown();
}
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
#endif
#endif
/** @} */

View File

@ -343,11 +343,11 @@
* Where \c uintA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the
* ranges of the signed \c MinAxisVal and \c MaxAxisVal values.
*
* \param[in] MinAxisVal Minimum X/Y logical axis value
* \param[in] MaxAxisVal Maximum X/Y logical axis value
* \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations
* \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations
* \param[in] Buttons Total number of buttons in the device
* \param[in] MinAxisVal Minimum X/Y logical axis value.
* \param[in] MaxAxisVal Maximum X/Y logical axis value.
* \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations.
* \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations.
* \param[in] Buttons Total number of buttons in the device.
*/
#define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \
HID_RI_USAGE_PAGE(8, 0x01), \
@ -393,7 +393,7 @@
* \endcode
*
* \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (a value between 1 and
* (ENDPOINT_SIZE - 2) )
* (ENDPOINT_SIZE - 2) ).
*/
#define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \
HID_RI_USAGE_PAGE(8, 0x01), \
@ -446,12 +446,12 @@
* Where \c intA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the
* ranges of the signed \c MinAxisVal and \c MaxAxisVal values.
*
* \param[in] MinAxisVal Minimum X/Y logical axis value
* \param[in] MaxAxisVal Maximum X/Y logical axis value
* \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations
* \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations
* \param[in] Buttons Total number of buttons in the device
* \param[in] AbsoluteCoords Boolean true to use absolute X/Y coordinates (e.g. touchscreen)
* \param[in] MinAxisVal Minimum X/Y logical axis value.
* \param[in] MaxAxisVal Maximum X/Y logical axis value.
* \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations.
* \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations.
* \param[in] Buttons Total number of buttons in the device.
* \param[in] AbsoluteCoords Boolean true to use absolute X/Y coordinates (e.g. touchscreen).
*/
#define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \
HID_RI_USAGE_PAGE(8, 0x01), \
@ -488,11 +488,11 @@
* used for transporting abitrary data between the USB host and device via HID reports. The resulting report should be
* a uint8_t byte array of the specified length in both Device to Host (IN) and Host to Device (OUT) directions.
*
* \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF
* \param[in] CollectionUsage Vendor Usage for the encompasing report IN and OUT collection, ranging from 0x00 to 0xFF
* \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF
* \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF
* \param[in] NumBytes Length of the data IN and OUT reports
* \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF.
* \param[in] CollectionUsage Vendor Usage for the encompasing report IN and OUT collection, ranging from 0x00 to 0xFF.
* \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF.
* \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF.
* \param[in] NumBytes Length of the data IN and OUT reports.
*/
#define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \
HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \

View File

@ -44,13 +44,20 @@
* - LUFA/Drivers/USB/Class/Host/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
*
* \section Sec_ModDescription Module Description
* Functions, macros, variables, enums and types related to the parsing of HID class device report descriptors.
* Human Interface Device (HID) class report descriptor parser. This module implements a parser than is
* capable of processing a complete HID report descriptor, and outputting a flat structure containing the
* contents of the report in an a more friendly format. The parsed data may then be further processed and used
* within an application to process sent and received HID reports to and from an attached HID device.
*
* The processed HID report is presented back to the user application as a flat structure containing each report
* item's IN, OUT and FEATURE items along with each item's attributes.
* A HID report descriptor consists of a set of HID report items, which describe the function and layout
* of data exchanged between a HID device and a host, including both the physical encoding of each item
* (such as a button, key press or joystick axis) in the sent and received data packets - known as "reports" -
* as well as other information about each item such as the usages, data range, physical location and other
* characterstics. In this way a HID device can retain a high degree of flexibility in its capabilities, as it
* is not forced to comply with a given report layout or featureset.
*
* This library portion also allows for easy setting and retrieval of data from a HID report, including devices
* with multiple reports on the one HID interface.
* This module also contains routines for the processing of data in an actual HID report, using the parsed report
* descritor data as a guide for the encoding.
*
* @{
*/
@ -159,8 +166,8 @@
*/
typedef struct
{
uint32_t Minimum; /**< Minimum value for the attribute. */
uint32_t Maximum; /**< Maximum value for the attribute. */
uint32_t Minimum; /**< Minimum value for the attribute. */
uint32_t Maximum; /**< Maximum value for the attribute. */
} HID_MinMax_t;
/** \brief HID Parser Report Item Unit Structure.
@ -169,8 +176,8 @@
*/
typedef struct
{
uint32_t Type; /**< Unit type (refer to HID specifications for details). */
uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */
uint32_t Type; /**< Unit type (refer to HID specifications for details). */
uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */
} HID_Unit_t;
/** \brief HID Parser Report Item Usage Structure.
@ -179,8 +186,8 @@
*/
typedef struct
{
uint16_t Page; /**< Usage page of the report item. */
uint16_t Usage; /**< Usage of the report item. */
uint16_t Page; /**< Usage page of the report item. */
uint16_t Usage; /**< Usage of the report item. */
} HID_Usage_t;
/** \brief HID Parser Report Item Collection Path Structure.
@ -188,11 +195,11 @@
* Type define for a COLLECTION object. Contains the collection attributes and a reference to the
* parent collection if any.
*/
typedef struct CollectionPath
typedef struct HID_CollectionPath
{
uint8_t Type; /**< Collection type (e.g. "Generic Desktop"). */
HID_Usage_t Usage; /**< Collection usage. */
struct CollectionPath* Parent; /**< Reference to parent collection, or \c NULL if root collection. */
uint8_t Type; /**< Collection type (e.g. "Generic Desktop"). */
HID_Usage_t Usage; /**< Collection usage. */
struct HID_CollectionPath* Parent; /**< Reference to parent collection, or \c NULL if root collection. */
} HID_CollectionPath_t;
/** \brief HID Parser Report Item Attributes Structure.
@ -201,12 +208,12 @@
*/
typedef struct
{
uint8_t BitSize; /**< Size in bits of the report item's data. */
uint8_t BitSize; /**< Size in bits of the report item's data. */
HID_Usage_t Usage; /**< Usage of the report item. */
HID_Unit_t Unit; /**< Unit type and exponent of the report item. */
HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */
HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */
HID_Usage_t Usage; /**< Usage of the report item. */
HID_Unit_t Unit; /**< Unit type and exponent of the report item. */
HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */
HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */
} HID_ReportItem_Attributes_t;
/** \brief HID Parser Report Item Details Structure.
@ -215,18 +222,18 @@
*/
typedef struct
{
uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */
uint8_t ItemType; /**< Report item type, a value in \ref HID_ReportItemTypes_t. */
uint16_t ItemFlags; /**< Item data flags, a mask of HID_IOF_* constants. */
uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */
HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */
uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */
uint8_t ItemType; /**< Report item type, a value in \ref HID_ReportItemTypes_t. */
uint16_t ItemFlags; /**< Item data flags, a mask of HID_IOF_* constants. */
uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */
HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */
HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */
HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */
uint32_t Value; /**< Current value of the report item - use \ref HID_ALIGN_DATA() when processing
* a retrieved value so that it is aligned to a specific type.
*/
uint32_t PreviousValue; /**< Previous value of the report item. */
uint32_t Value; /**< Current value of the report item - use \ref HID_ALIGN_DATA() when processing
* a retrieved value so that it is aligned to a specific type.
*/
uint32_t PreviousValue; /**< Previous value of the report item. */
} HID_ReportItem_t;
/** \brief HID Parser Report Size Structure.
@ -235,10 +242,10 @@
*/
typedef struct
{
uint8_t ReportID; /**< Report ID of the report within the HID interface. */
uint16_t ReportSizeBits[3]; /**< Total number of bits in each report type for the given Report ID,
* indexed by the \ref HID_ReportItemTypes_t enum.
*/
uint8_t ReportID; /**< Report ID of the report within the HID interface. */
uint16_t ReportSizeBits[3]; /**< Total number of bits in each report type for the given Report ID,
* indexed by the \ref HID_ReportItemTypes_t enum.
*/
} HID_ReportSizeInfo_t;
/** \brief HID Parser State Structure.
@ -247,21 +254,19 @@
*/
typedef struct
{
uint8_t TotalReportItems; /**< Total number of report items stored in the
* \c ReportItems array.
*/
HID_ReportItem_t ReportItems[HID_MAX_REPORTITEMS]; /**< Report items array, including
* all IN, OUT and FEATURE items.
*/
HID_CollectionPath_t CollectionPaths[HID_MAX_COLLECTIONS]; /**< All collection items, referenced
* by the report items.
*/
uint8_t TotalDeviceReports; /**< Number of reports within the HID interface */
HID_ReportSizeInfo_t ReportIDSizes[HID_MAX_REPORT_IDS]; /**< Report sizes for each report in the interface */
uint16_t LargestReportSizeBits; /**< Largest report that the attached device will generate, in bits */
bool UsingReportIDs; /**< Indicates if the device has at least one REPORT ID
* element in its HID report descriptor.
*/
uint8_t TotalReportItems; /**< Total number of report items stored in the \c ReportItems array. */
HID_ReportItem_t ReportItems[HID_MAX_REPORTITEMS]; /**< Report items array, including all IN, OUT
* and FEATURE items.
*/
HID_CollectionPath_t CollectionPaths[HID_MAX_COLLECTIONS]; /**< All collection items, referenced
* by the report items.
*/
uint8_t TotalDeviceReports; /**< Number of reports within the HID interface */
HID_ReportSizeInfo_t ReportIDSizes[HID_MAX_REPORT_IDS]; /**< Report sizes for each report in the interface */
uint16_t LargestReportSizeBits; /**< Largest report that the attached device will generate, in bits */
bool UsingReportIDs; /**< Indicates if the device has at least one REPORT ID
* element in its HID report descriptor.
*/
} HID_ReportInfo_t;
/* Function Prototypes: */

View File

@ -280,12 +280,12 @@
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular
* functions in the avr-libc <stdio.h> library that accept a FILE stream as a destination (e.g. fprintf). The created
* functions in the avr-libc <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
* stream is bidirectional and can be used for both input and output functions.
*
* Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
* fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
* be used when the read data is processed byte-per-bye (via getc()) or when the user application will implement its own
* be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
* line buffering.
*
* \note The created stream can be given as stdout if desired to direct the standard output from all <stdio.h> functions
@ -297,7 +297,7 @@
void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
/** Identical to CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates
/** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates
* the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.

View File

@ -270,9 +270,14 @@
uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular
* functions in the avr-libc \c <stdio.h> library that accept a FILE stream as a destination (e.g. fprintf). The created
* functions in the avr-libc \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
* stream is bidirectional and can be used for both input and output functions.
*
* Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
* fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
* be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
* line buffering.
*
* \note The created stream can be given as stdout if desired to direct the standard output from all \c <stdio.h> functions
* to the given CDC interface.
*
@ -282,7 +287,7 @@
void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
FILE* const Stream);
/** Identical to CDC_Host_CreateStream(), except that reads are blocking until the calling stream function terminates
/** Identical to \ref CDC_Host_CreateStream(), except that reads are blocking until the calling stream function terminates
* the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.

Some files were not shown because too many files have changed in this diff Show More