Added new USB_DeviceState variable to keep track of the current Device mode USB state.
[pub/USBasp.git] / Demos / Device / LowLevel / AudioOutput / AudioOutput.h
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 * Header file for AudioOutput.c.
34 */
35
36 #ifndef _AUDIO_OUTPUT_H_
37 #define _AUDIO_OUTPUT_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/wdt.h>
42 #include <avr/power.h>
43
44 #include "Descriptors.h"
45
46 #include <LUFA/Version.h>
47 #include <LUFA/Drivers/USB/USB.h>
48 #include <LUFA/Drivers/Board/LEDs.h>
49
50 /* Macros: */
51 #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
52 #define TCCRxA TCCR3A
53 #define TCCRxB TCCR3B
54 #define OCRxA OCR3A
55 #define OCRxB OCR3B
56 #define WGMx0 WGM30
57 #define WGMx2 WGM32
58 #define COMxA1 COM3A1
59 #define COMxA0 COM3A0
60 #define COMxB1 COM3B1
61 #define COMxB0 COM3B0
62 #define CSx0 CS30
63 #else
64 /** Timer count register used for left channel PWM audio output (or mixed output in mono output mode) */
65 #define TCCRxA TCCR1A
66
67 /** Timer count register used for right channel PWM audio output */
68 #define TCCRxB TCCR1B
69
70 /** Timer compare register used for left channel PWM audio output (or mixed output in mono output mode) */
71 #define OCRxA OCR1A
72
73 /** Timer compare register used for right channel PWM audio output */
74 #define OCRxB OCR1B
75
76 /** Timer control register mask used to select PWM mode */
77 #define WGMx0 WGM10
78
79 /** Timer control register mask used to select PWM mode */
80 #define WGMx2 WGM12
81
82 /** Timer control register mask used to set, clear or toggle channel output pin on match */
83 #define COMxA1 COM1A1
84
85 /** Timer control register mask used to set, clear or toggle channel output pin on match */
86 #define COMxA0 COM1A0
87
88 /** Timer control register mask used to set, clear or toggle channel output pin on match */
89 #define COMxB1 COM1B1
90
91 /** Timer control register mask used to set, clear or toggle channel output pin on match */
92 #define COMxB0 COM1B0
93
94 /** Timer control register mask used to start the timer at Fcpu clock rate */
95 #define CSx0 CS10
96 #endif
97
98 /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
99 #define LEDMASK_USB_NOTREADY LEDS_LED1
100
101 /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
102 #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
103
104 /** LED mask for the library LED driver, to indicate that the USB interface is ready. */
105 #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
106
107 /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
108 #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
109
110 /* Function Prototypes: */
111 void SetupHardware(void);
112 void USB_Audio_Task(void);
113
114 void EVENT_USB_Connect(void);
115 void EVENT_USB_Disconnect(void);
116 void EVENT_USB_ConfigurationChanged(void);
117 void EVENT_USB_UnhandledControlPacket(void);
118
119 #endif