Fix Doxygen treating the license as a documentation source file.
[pub/USBasp.git] / Bootloaders / CDC / BootloaderCDC.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
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 BootloaderCDC.c.
34 */
35
36 #ifndef _CDC_H_
37 #define _CDC_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/wdt.h>
42 #include <avr/boot.h>
43 #include <avr/eeprom.h>
44 #include <avr/power.h>
45 #include <avr/interrupt.h>
46 #include <stdbool.h>
47
48 #include "Descriptors.h"
49
50 #include <LUFA/Drivers/USB/USB.h>
51
52 /* Macros: */
53 /** CDC Class Specific request to get the line encoding on a CDC-ACM virtual serial port, including the
54 * baud rate, parity, stop bits and data bits.
55 */
56 #define REQ_GetLineEncoding 0x21
57
58 /** CDC Class Specific request to set the line encoding on a CDC-ACM virtual serial port, including the
59 * baud rate, parity, stop bits and data bits.
60 */
61 #define REQ_SetLineEncoding 0x20
62
63 /** CDC Class Specific request to set the state of the serial handshake lines (such as DCD and RTS) on
64 * a CDC-ACM virtual serial port.
65 */
66 #define REQ_SetControlLineState 0x22
67
68 /** Version major of the CDC bootloader. */
69 #define BOOTLOADER_VERSION_MAJOR 0x01
70
71 /** Version minor of the CDC bootloader. */
72 #define BOOTLOADER_VERSION_MINOR 0x00
73
74 /** Hardware version major of the CDC bootloader. */
75 #define BOOTLOADER_HWVERSION_MAJOR 0x01
76
77 /** Hardware version minor of the CDC bootloader. */
78 #define BOOTLOADER_HWVERSION_MINOR 0x00
79
80 /** Eight character bootloader firmware identifier reported to the host when requested */
81 #define SOFTWARE_IDENTIFIER "LUFACDC"
82
83 /* Type Defines: */
84 /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
85 typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
86
87 /** Type define for the CDC-ACM virtual serial port line encoding options, including baud rate, format, parity
88 * and size of each data chunk in bits.
89 */
90 typedef struct
91 {
92 uint32_t BaudRateBPS; /**< Baud rate in BPS */
93 uint8_t CharFormat; /**< Character format, an entry from the BootloaderCDC_CDC_LineCodingFormats_t enum */
94 uint8_t ParityType; /**< Parity mode, an entry from the BootloaderCDC_CDC_LineCodeingParity_t enum */
95 uint8_t DataBits; /**< Size of each data chunk, in bits */
96 } CDC_Line_Coding_t;
97
98 /* Enums: */
99 /** Enum for the possible line encoding formats on a CDC-ACM virtual serial port */
100 enum BootloaderCDC_CDC_LineCodingFormats_t
101 {
102 OneStopBit = 0, /**< Single stop bit */
103 OneAndAHalfStopBits = 1, /**< 1.5 stop bits */
104 TwoStopBits = 2, /**< Two stop bits */
105 };
106
107 /** Enum for the possible parity modes on a CDC-ACM virtual serial port */
108 enum BootloaderCDC_CDC_LineCodingParity_t
109 {
110 Parity_None = 0, /**< No data parity checking */
111 Parity_Odd = 1, /**< Odd data parity checking */
112 Parity_Even = 2, /**< Even data parity checking */
113 Parity_Mark = 3, /**< Mark data parity checking */
114 Parity_Space = 4, /**< Space data parity checking */
115 };
116
117 /* Function Prototypes: */
118 void CDC_Task(void);
119 void SetupHardware(void);
120
121 void EVENT_USB_Device_ConfigurationChanged(void);
122 void EVENT_USB_Device_UnhandledControlRequest(void);
123
124 #if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__)
125 static void ReadWriteMemoryBlock(const uint8_t Command);
126 static uint8_t FetchNextCommandByte(void);
127 static void WriteNextResponseByte(const uint8_t Response);
128 #endif
129
130 #endif