X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/071e02c6b6b4837fa9cf0b6d4c749994e02638d7..5cae54154506176d64a581c5b3d9550c901b570c:/Projects/RelayBoard/RelayBoard.c?ds=sidebyside diff --git a/Projects/RelayBoard/RelayBoard.c b/Projects/RelayBoard/RelayBoard.c index 2f084f3e7..f2ba464ec 100644 --- a/Projects/RelayBoard/RelayBoard.c +++ b/Projects/RelayBoard/RelayBoard.c @@ -1,14 +1,14 @@ /* LUFA Library - Copyright (C) Dean Camera, 2010. + Copyright (C) Dean Camera, 2013. dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com + www.lufa-lib.org */ /* Copyright 2010 OBinou (obconseil [at] gmail [dot] com) - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2013 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 @@ -19,7 +19,7 @@ advertising or publicity pertaining to distribution of the software without specific, written prior permission. - The author disclaim all warranties with regard to this + The author disclaims 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 @@ -44,8 +44,8 @@ int main(void) { SetupHardware(); - - sei(); + + GlobalInterruptEnable(); for (;;) USB_USBTask(); @@ -54,12 +54,14 @@ int main(void) /** Configures the board hardware and chip peripherals for the project's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#endif /* Hardware Initialization */ USB_Init(); @@ -69,15 +71,8 @@ void SetupHardware(void) PORTC &= ~ALL_RELAYS; } - -/** Event handler for the library USB Configuration Changed event. */ -void EVENT_USB_Device_ConfigurationChanged(void) -{ - USB_Device_EnableSOFEvents(); -} - -/** Event handler for the library USB Unhandled Control Packet event. */ -void EVENT_USB_Device_UnhandledControlRequest(void) +/** Event handler for the library USB Control Request reception event. */ +void EVENT_USB_Device_ControlRequest(void) { const uint8_t SerialNumber[5] = { 0, 0, 0, 0, 1 }; uint8_t ControlData[2] = { 0, 0 }; @@ -110,7 +105,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) break; } } - + break; case 0x01: if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) @@ -137,7 +132,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) ControlData[1] = (PORTC & RELAY4) ? 2 : 3; break; } - + if (ControlData[1]) Endpoint_Write_Control_Stream_LE(ControlData, sizeof(ControlData)); @@ -147,3 +142,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void) break; } } +