Un-inline the SendAddress function in NVMTarget.c/.h of the AVRISP project.
[pub/USBasp.git] / Projects / HotmailNotifier / HotmailNotifier.c
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 * Main source file for the HotmailNotfier project. This file contains the main tasks of
34 * the demo and is responsible for the initial application hardware configuration.
35 */
36
37 #include "HotmailNotifier.h"
38
39 /** LUFA CDC Class driver interface configuration and state information. This structure is
40 * passed to all CDC Class driver functions, so that multiple instances of the same class
41 * within a device can be differentiated from one another.
42 */
43 USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
44 {
45 .Config =
46 {
47 .ControlInterfaceNumber = 0,
48
49 .DataINEndpointNumber = CDC_TX_EPNUM,
50 .DataINEndpointSize = CDC_TXRX_EPSIZE,
51 .DataINEndpointDoubleBank = false,
52
53 .DataOUTEndpointNumber = CDC_RX_EPNUM,
54 .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
55 .DataOUTEndpointDoubleBank = false,
56
57 .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
58 .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
59 .NotificationEndpointDoubleBank = false,
60 },
61 };
62
63 /** Standard file stream for the CDC interface when set up, so that the virtual CDC COM port can be
64 * used like any regular character stream in the C APIs
65 */
66 static FILE USBSerialStream;
67
68 /** Main program entry point. This routine contains the overall program flow, including initial
69 * setup of all components and the main program loop.
70 */
71 int main(void)
72 {
73 SetupHardware();
74
75 /* Create a regular blocking character stream for the interface so that it can be used with the stdio.h functions */
76 CDC_Device_CreateBlockingStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
77
78 for (;;)
79 {
80 /* Read next character - if a '1' turn on red led, if a '0' turn on green LED */
81 if (fgetc(&USBSerialStream) == '1')
82 LEDs_SetAllLEDs(LEDS_LED3);
83 else
84 LEDs_SetAllLEDs(LEDS_LED2);
85
86 CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
87 USB_USBTask();
88 }
89 }
90
91 /** Configures the board hardware and chip peripherals for the demo's functionality. */
92 void SetupHardware(void)
93 {
94 /* Disable watchdog if enabled by bootloader/fuses */
95 MCUSR &= ~(1 << WDRF);
96 wdt_disable();
97
98 /* Disable clock division */
99 clock_prescale_set(clock_div_1);
100
101 /* Hardware Initialization */
102 LEDs_Init();
103 USB_Init();
104 }
105
106 /** Event handler for the library USB Configuration Changed event. */
107 void EVENT_USB_Device_ConfigurationChanged(void)
108 {
109 LEDs_SetAllLEDs(LEDS_ALL_LEDS);
110
111 if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface)))
112 LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED3);
113 }
114
115 /** Event handler for the library USB Unhandled Control Request event. */
116 void EVENT_USB_Device_UnhandledControlRequest(void)
117 {
118 CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface);
119 }