3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 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
31 #include "TestAndMeasurement.h"
33 /** Main program entry point. This routine contains the overall program flow, including initial
34 * setup of all components and the main program loop.
40 LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY
);
50 /** Configures the board hardware and chip peripherals for the demo's functionality. */
51 void SetupHardware(void)
53 /* Disable watchdog if enabled by bootloader/fuses */
54 MCUSR
&= ~(1 << WDRF
);
57 /* Disable clock division */
58 clock_prescale_set(clock_div_1
);
60 /* Hardware Initialization */
65 void EVENT_USB_Device_Connect(void)
67 LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING
);
70 void EVENT_USB_Device_Disconnect(void)
72 LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY
);
75 void EVENT_USB_Device_ConfigurationChanged(void)
77 LEDs_SetAllLEDs(LEDMASK_USB_READY
);
79 /* Setup TMC In and Out Endpoints */
80 if (!(Endpoint_ConfigureEndpoint(TMC_IN_EPNUM
, EP_TYPE_BULK
,
81 ENDPOINT_DIR_IN
, TMC_IO_EPSIZE
,
82 ENDPOINT_BANK_SINGLE
)))
84 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
);
87 if (!(Endpoint_ConfigureEndpoint(TMC_OUT_EPNUM
, EP_TYPE_BULK
,
88 ENDPOINT_DIR_OUT
, TMC_IO_EPSIZE
,
89 ENDPOINT_BANK_SINGLE
)))
91 LEDs_SetAllLEDs(LEDMASK_USB_ERROR
);
95 void EVENT_USB_Device_UnhandledControlRequest(void)
97 switch (USB_ControlRequest
.bRequest
)
99 case Req_InitiateAbortBulkOut
:
100 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_ENDPOINT
))
106 case Req_CheckAbortBulkOutStatus
:
107 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_ENDPOINT
))
113 case Req_InitiateAbortBulkIn
:
114 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_ENDPOINT
))
120 case Req_CheckAbortBulkInStatus
:
121 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_ENDPOINT
))
127 case Req_InitiateClear
:
128 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_INTERFACE
))
134 case Req_CheckClearStatus
:
135 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_INTERFACE
))
141 case Req_GetCapabilities
:
142 if (USB_ControlRequest
.bmRequestType
== (REQDIR_DEVICETOHOST
| REQTYPE_CLASS
| REQREC_INTERFACE
))
153 /* Device must be connected and configured for the task to run */
154 if (USB_DeviceState
!= DEVICE_STATE_Configured
)