Statistics
| Branch: | Tag: | Revision:

root / LUFA / Drivers / USB / Class / Common / StillImage.h @ 978b99e5

History | View | Annotate | Download (6.91 KB)

1
/*
2
             LUFA Library
3
     Copyright (C) Dean Camera, 2011.
4

5
  dean [at] fourwalledcubicle [dot] com
6
           www.lufa-lib.org
7
*/
8

    
9
/*
10
  Copyright 2011  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
 *  \brief Common definitions and declarations for the library USB Still Image Class driver.
33
 *
34
 *  Common definitions and declarations for the library USB Still Image Class driver.
35
 *
36
 *  \note This file should not be included directly. It is automatically included as needed by the USB module driver
37
 *        dispatch header located in LUFA/Drivers/USB.h.
38
 */
39

    
40
/** \ingroup Group_USBClassSI
41
 *  \defgroup Group_USBClassSICommon  Common Class Definitions
42
 *
43
 *  \section Sec_ModDescription Module Description
44
 *  Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
45
 *  Still Image Class.
46
 *
47
 *  @{
48
 */
49

    
50
#ifndef _SI_CLASS_COMMON_H_
51
#define _SI_CLASS_COMMON_H_
52

    
53
        /* Includes: */
54
                #include "../../Core/StdDescriptors.h"
55

    
56
        /* Enable C linkage for C++ Compilers: */
57
                #if defined(__cplusplus)
58
                        extern "C" {
59
                #endif
60

    
61
        /* Preprocessor Checks: */
62
                #if !defined(__INCLUDE_FROM_SI_DRIVER)
63
                        #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
64
                #endif
65

    
66
        /* Macros: */
67
                /** Length in bytes of a given Unicode string's character length.
68
                 *
69
                 *  \param[in] Chars  Total number of Unicode characters in the string.
70
                 *
71
                 *  \return Number of bytes of the given unicode string.
72
                 */
73
                #define UNICODE_STRING_LENGTH(Chars)  ((Chars) << 1)
74

    
75
                /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
76
                 *  a command container.
77
                 *
78
                 *  \param[in] Params  Number of parameters which are to be sent in the \c Param field of the container.
79
                 */
80
                #define PIMA_COMMAND_SIZE(Params)     ((sizeof(PIMA_Container_t) - 12) + ((Params) * sizeof(uint32_t)))
81

    
82
                /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
83
                 *  a data container.
84
                 *
85
                 *  \param[in] DataLen  Length in bytes of the data in the container.
86
                 */
87
                #define PIMA_DATA_SIZE(DataLen)       ((sizeof(PIMA_Container_t) - 12) + (DataLen))
88

    
89
        /* Enums: */
90
                /** Enum for the possible PIMA contains types. */
91
                enum PIMA_Container_Types_t
92
                {
93
                        PIMA_CONTAINER_Undefined     = 0, /**< Undefined container type. */
94
                        PIMA_CONTAINER_CommandBlock  = 1, /**< Command Block container type. */
95
                        PIMA_CONTAINER_DataBlock     = 2, /**< Data Block container type. */
96
                        PIMA_CONTAINER_ResponseBlock = 3, /**< Response container type. */
97
                        PIMA_CONTAINER_EventBlock    = 4, /**< Event Block container type. */
98
                };
99

    
100
        /* Enums: */
101
                /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the
102
                 *  Still Image device class.
103
                 */
104
                enum SI_Descriptor_ClassSubclassProtocol_t
105
                {
106
                        SI_CSCP_StillImageClass             = 0x06, /**< Descriptor Class value indicating that the device or interface
107
                                                                     *   belongs to the Still Image class.
108
                                                                     */
109
                        SI_CSCP_StillImageSubclass          = 0x01, /**< Descriptor Subclass value indicating that the device or interface
110
                                                                     *   belongs to the Still Image subclass.
111
                                                                     */
112
                        SI_CSCP_BulkOnlyProtocol            = 0x01, /**< Descriptor Protocol value indicating that the device or interface
113
                                                                     *   belongs to the Bulk Only Transport protocol of the Still Image class.
114
                                                                     */
115
                };
116

    
117
                /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */
118
                enum PIMA_ResponseCodes_t
119
                {
120
                        PIMA_RESPONSE_OK                    = 1, /**< Response code indicating no error in the issued command. */
121
                        PIMA_RESPONSE_GeneralError          = 2, /**< Response code indicating a general error while processing the
122
                                                                     *  issued command.
123
                                                                     */
124
                        PIMA_RESPONSE_SessionNotOpen        = 3, /**< Response code indicating that the sent command requires an open
125
                                                                     *   session before being issued.
126
                                                                     */
127
                        PIMA_RESPONSE_InvalidTransaction    = 4, /**< Response code indicating an invalid transaction occurred. */
128
                        PIMA_RESPONSE_OperationNotSupported = 5, /**< Response code indicating that the issued command is not supported
129
                                                                     *   by the attached device.
130
                                                                     */
131
                        PIMA_RESPONSE_ParameterNotSupported = 6, /**< Response code indicating that one or more of the issued command's
132
                                                                     *   parameters are not supported by the device.
133
                                                                     */
134
                };
135

    
136
        /* Type Defines: */
137
                /** \brief PIMA Still Image Device Command/Response Container.
138
                 *
139
                 *  Type define for a PIMA container, use to send commands and receive responses to and from an
140
                 *  attached Still Image device.
141
                 *
142
                 *  \note Regardless of CPU architecture, these values should be stored as little endian.
143
                 */
144
                typedef struct
145
                {
146
                        uint32_t DataLength; /**< Length of the container and data, in bytes. */
147
                        uint16_t Type; /**< Container type, a value from the \ref PIMA_Container_Types_t enum. */
148
                        uint16_t Code; /**< Command, event or response code of the container. */
149
                        uint32_t TransactionID; /**< Unique container ID to link blocks together. */
150
                        uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only). */
151
                } ATTR_PACKED PIMA_Container_t;
152

    
153
        /* Disable C linkage for C++ Compilers: */
154
                #if defined(__cplusplus)
155
                        }
156
                #endif
157

    
158
#endif
159

    
160
/** @} */
161