Added documentation for the constants and enums of the new StillImage Host Class...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / StillImage.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 /** \ingroup Group_USBClassSI
32 * @defgroup Group_USBClassSICommon Common Class Definitions
33 *
34 * \section Module Description
35 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
36 * Still Image Class.
37 *
38 * @{
39 */
40
41 #ifndef _SI_CLASS_COMMON_H_
42 #define _SI_CLASS_COMMON_H_
43
44 /* Includes: */
45 #include "../../USB.h"
46
47 #include <string.h>
48
49 /* Enable C linkage for C++ Compilers: */
50 #if defined(__cplusplus)
51 extern "C" {
52 #endif
53
54 /* Macros: */
55 /** Length in bytes of a given Unicode string's character length
56 *
57 * \param[in] chars Total number of Unicode characters in the string
58 *
59 * \return Number of bytes of the given unicode string
60 */
61 #define UNICODE_STRING_LENGTH(chars) (chars << 1)
62
63 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
64 * a command container.
65 *
66 * \param[in] params Number of parameters which are to be sent in the Param field of the container
67 */
68 #define PIMA_COMMAND_SIZE(params) ((sizeof(SI_PIMA_Container_t) - sizeof(((SI_PIMA_Container_t*)NULL)->Params)) + \
69 (params * sizeof(uint32_t)))
70
71 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
72 * a data container.
73 *
74 * \param[in] datalen Length in bytes of the data in the container
75 */
76 #define PIMA_DATA_SIZE(datalen) ((sizeof(SI_PIMA_Container_t) - sizeof(((SI_PIMA_Container_t*)NULL)->Params)) + \
77 datalen)
78
79 /* Enums: */
80 /** Enum for the possible PIMA contains types. */
81 enum SI_PIMA_Container_Types_t
82 {
83 CType_Undefined = 0, /**< Undefined container type */
84 CType_CommandBlock = 1, /**< Command Block container type */
85 CType_DataBlock = 2, /**< Data Block container type */
86 CType_ResponseBlock = 3, /**< Response container type */
87 CType_EventBlock = 4, /**< Event Block container type */
88 };
89
90 /* Enums: */
91 /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */
92 enum SI_PIMA_ResponseCodes_t
93 {
94 PIMA_RESPONSE_OK = 1, /**< Response code indicating no error in the issued command */
95 PIMA_RESPONSE_GeneralError = 2, /**< Response code indicating a general error while processing the
96 * issued command
97 */
98 PIMA_RESPONSE_SessionNotOpen = 3, /**< Response code indicating that the sent command requires an open
99 * session before being issued
100 */
101 PIMA_RESPONSE_InvalidTransaction = 4, /**< Response code indicating an invalid transaction occurred */
102 PIMA_RESPONSE_OperationNotSupported = 5, /**< Response code indicating that the issued command is not supported
103 * by the attached device
104 */
105 PIMA_RESPONSE_ParameterNotSupported = 6, /**< Response code indicating that one or more of the issued command's
106 * parameters are not supported by the device
107 */
108 };
109
110 /* Type Defines: */
111 /** Type define for a PIMA container, use to send commands and receive responses to and from an
112 * attached Still Image device.
113 */
114 typedef struct
115 {
116 uint32_t DataLength; /**< Length of the container and data, in bytes */
117 uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */
118 uint16_t Code; /**< Command, event or response code of the container */
119 uint32_t TransactionID; /**< Unique container ID to link blocks together */
120 uint32_t Params[4]; /**< Block parameters to be issued along with the block code (command blocks only) */
121 } SI_PIMA_Container_t;
122
123 /* Disable C linkage for C++ Compilers: */
124 #if defined(__cplusplus)
125 }
126 #endif
127
128 #endif
129
130 /** @} */