Move new Class Driver powered demos to a new ClassDriver subdirectory, re-add old...
[pub/USBasp.git] / Demos / Device / LowLevel / DualCDC / DualCDC.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for DualCDC.c.
34 */
35
36 #ifndef _DUAL_CDC_H_
37 #define _DUAL_CDC_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/wdt.h>
42 #include <avr/power.h>
43 #include <string.h>
44
45 #include "Descriptors.h"
46
47 #include <LUFA/Version.h> // Library Version Information
48 #include <LUFA/Drivers/USB/USB.h> // USB Functionality
49 #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
50 #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
51 #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
52
53 /* Macros: */
54 /** CDC Class specific request to get the current virtual serial port configuration settings. */
55 #define REQ_GetLineEncoding 0x21
56
57 /** CDC Class specific request to set the current virtual serial port configuration settings. */
58 #define REQ_SetLineEncoding 0x20
59
60 /** CDC Class specific request to set the current virtual serial port handshake line states. */
61 #define REQ_SetControlLineState 0x22
62
63 /* Type Defines: */
64 /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration
65 * as set by the host via a class specific request.
66 */
67 typedef struct
68 {
69 uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */
70 uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the
71 * CDCDevice_CDC_LineCodingFormats_t enum
72 */
73 uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the
74 * CDCDevice_LineCodingParity_t enum
75 */
76 uint8_t DataBits; /**< Bits of data per character of the virtual serial port */
77 } CDC_Line_Coding_t;
78
79 /* Enums: */
80 /** Enum for the possible line encoding formats of a virtual serial port. */
81 enum CDCDevice_CDC_LineCodingFormats_t
82 {
83 OneStopBit = 0, /**< Each frame contains one stop bit */
84 OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
85 TwoStopBits = 2, /**< Each frame contains two stop bits */
86 };
87
88 /** Enum for the possible line encoding parity settings of a virtual serial port. */
89 enum CDCDevice_LineCodingParity_t
90 {
91 Parity_None = 0, /**< No parity bit mode on each frame */
92 Parity_Odd = 1, /**< Odd parity bit mode on each frame */
93 Parity_Even = 2, /**< Even parity bit mode on each frame */
94 Parity_Mark = 3, /**< Mark parity bit mode on each frame */
95 Parity_Space = 4, /**< Space parity bit mode on each frame */
96 };
97
98 /** Enum for the possible status codes for passing to the UpdateStatus() function. */
99 enum DualCDC_StatusCodes_t
100 {
101 Status_USBNotReady = 0, /**< USB is not ready (disconnected from a USB host) */
102 Status_USBEnumerating = 1, /**< USB interface is enumerating */
103 Status_USBReady = 2, /**< USB interface is connected and ready */
104 };
105
106 /* Tasks: */
107 TASK(CDC1_Task);
108 TASK(CDC2_Task);
109
110 /* Function Prototypes: */
111 void EVENT_USB_Connect(void);
112 void EVENT_USB_Disconnect(void);
113 void EVENT_USB_ConfigurationChanged(void);
114 void EVENT_USB_UnhandledControlPacket(void);
115
116 void UpdateStatus(uint8_t CurrentStatus);
117
118 #endif