Add tag for the 120219 release.
[pub/USBasp.git] / Demos / Device / Incomplete / Sideshow / Lib / SideshowCommon.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2012.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all 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 #ifndef _SIDESHOW_COMMON_H_
32 #define _SIDESHOW_COMMON_H_
33
34 /* Includes: */
35 #include <avr/io.h>
36 #include <string.h>
37
38 #include <LUFA/Drivers/USB/USB.h>
39
40 /* Macros: */
41 #define GUID_COMPARE(a, b) (memcmp(a, b, sizeof(GUID_t)) == 0)
42
43 #define ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
44
45 #define UNICODE_STRING_t(x) struct \
46 { \
47 uint16_t LengthInBytes; \
48 int UnicodeString[x]; \
49 }
50
51 // {A33F248B-882F-4531-82C2-ED3B90C5C520}
52 #define STANDARD_PROTOCOL_GUID {0xA33F248B, 0x4531882F, 0x3BEDC282, 0x20C5C590}
53 // {A9A5353F-2D4B-47CE-93EE-759F3A7DDA4F}
54 #define SIMPLE_CONTENT_FORMAT_GUID {0xA9A5353F, 0x47CE2D4B, 0x9F75EE93, 0x4FDA7D3A}
55 // {8ABC88A8-857B-4ad7-A35A-B5942F492B99}
56 #define SIDESHOW_PROPERTY_GUID {0x8ABC88A8, 0x4AD7857B, 0x94B55AA3, 0x992B492F}
57 // {26D4979A-E643-4626-9E2B-736DC0C92FDC}
58 #define DEVICE_PROPERTY_GUID {0x26D4979A, 0x4626E643, 0x6D732B9E, 0xDC2FC9C0}
59
60 #define SECURITY_INTERACTIVE_RID_SID L"S-1-5-4"
61
62 #define MAX_APPLICATIONS 4
63 #define MAX_CONTENTBUFFER_PER_APP 1024
64
65 /* Type Defines: */
66 typedef struct
67 {
68 uint32_t Chunks[4];
69 } GUID_t;
70
71 typedef struct
72 {
73 uint16_t LengthInBytes;
74 int UnicodeString[];
75 } Unicode_String_t;
76
77 typedef union
78 {
79 uint32_t TypeLong;
80
81 struct
82 {
83 uint8_t TypeBytes[3];
84
85 unsigned ErrorCode : 6;
86 unsigned NAK : 1;
87 unsigned Response : 1;
88 } TypeFields;
89 } SideShowPacketType_t;
90
91 typedef struct
92 {
93 uint32_t Length;
94 SideShowPacketType_t Type;
95 uint16_t Number;
96 } SideShow_PacketHeader_t;
97
98 /* Function Prototypes: */
99 uint16_t SideShow_Read_Unicode_String(void* UnicodeString,
100 const uint16_t MaxBytes);
101 void SideShow_Write_Unicode_String(void* UnicodeString);
102 void SideShow_Discard_Byte_Stream(void);
103
104 #endif
105