3 Copyright (C) Dean Camera, 2012.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
32 SideShow Class demonstration application. This give a reference
33 for implementing Microsoft SideShow compatible devices in an
34 embedded environment. SideShow allows for gadget data displayed
35 on a Windows Vista or later machine to also be displayed on an
36 externally connected interactive display. Upon enumeration, this will
37 appear as a new SideShow device which can have gadgets loaded onto
40 Note that while the incoming content is buffered in packet struct
41 form, the data is not actually displayed. It is left to the user to
42 write sufficient code to read out the packed data for display to a
45 Installed gadgets can be accessed through the InstalledApplications
46 array, with entries that have their InUse flag set being active. As
47 only the active content is displayed on the device due to memory
48 constraints, new content can be requested as needed.
53 /** Main program entry point. This routine contains the overall program flow, including initial
54 * setup of all components and the main program loop.
60 LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY
);
70 /** Configures the board hardware and chip peripherals for the demo's functionality. */
71 void SetupHardware(void)
73 /* Disable watchdog if enabled by bootloader/fuses */
74 MCUSR
&= ~(1 << WDRF
);
77 /* Disable clock division */
78 clock_prescale_set(clock_div_1
);
80 /* Hardware Initialization */
83 Serial_Init(9600, false);
85 /* Create a stdio stream for the serial port for stdin and stdout */
86 Serial_CreateStream(NULL
);
89 void EVENT_USB_Device_Connect(void)
91 LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING
);
94 void EVENT_USB_Device_Disconnect(void)
96 LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY
);
99 void EVENT_USB_Device_ConfigurationChanged(void)
101 bool ConfigSuccess
= true;
103 /* Setup Sideshow Data Endpoints */
104 ConfigSuccess
&= Endpoint_ConfigureEndpoint(SIDESHOW_IN_EPNUM
, EP_TYPE_BULK
, ENDPOINT_DIR_IN
,
105 SIDESHOW_IO_EPSIZE
, ENDPOINT_BANK_SINGLE
);
106 ConfigSuccess
&= Endpoint_ConfigureEndpoint(SIDESHOW_OUT_EPNUM
, EP_TYPE_BULK
, ENDPOINT_DIR_OUT
,
107 SIDESHOW_IO_EPSIZE
, ENDPOINT_BANK_SINGLE
);
109 /* Indicate endpoint configuration success or failure */
110 LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY
: LEDMASK_USB_ERROR
);
113 void EVENT_USB_Device_ControlRequest(void)
115 switch (USB_ControlRequest
.bRequest
)
117 case REQ_GetOSFeatureDescriptor
:
118 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_VENDOR
| REQREC_DEVICE
))
120 const void* DescriptorPointer
;
121 uint16_t DescriptorSize
= USB_GetOSFeatureDescriptor(USB_ControlRequest
.wValue
,
122 USB_ControlRequest
.wIndex
,
125 if (DescriptorSize
== NO_DESCRIPTOR
)
128 Endpoint_ClearSETUP();
130 Endpoint_Write_Control_PStream_LE(DescriptorPointer
, DescriptorSize
);
138 void SideShow_Task(void)
140 /* Device must be connected and configured for the task to run */
141 if (USB_DeviceState
!= DEVICE_STATE_Configured
)
144 /* Select the SideShow data out endpoint */
145 Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM
);
147 /* Check to see if a new SideShow message has been received */
148 if (Endpoint_IsReadWriteAllowed())
150 /* Process the received SideShow message */
151 Sideshow_ProcessCommandPacket();