3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
31 /** \ingroup Group_USBClassSI
32 * @defgroup Group_USBClassSICommon Common Class Definitions
34 * \section Module Description
35 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
41 #ifndef _SI_CLASS_COMMON_H_
42 #define _SI_CLASS_COMMON_H_
45 #include "../../USB.h"
49 /* Enable C linkage for C++ Compilers: */
50 #if defined(__cplusplus)
54 /* Preprocessor Checks: */
55 #if !defined(__INCLUDE_FROM_SI_DRIVER)
56 #error Do not include this file directly. Include LUFA/Drivers/Class/StillImage.h instead.
60 /** Length in bytes of a given Unicode string's character length
62 * \param[in] chars Total number of Unicode characters in the string
64 * \return Number of bytes of the given unicode string
66 #define UNICODE_STRING_LENGTH(chars) (chars << 1)
68 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
69 * a command container.
71 * \param[in] params Number of parameters which are to be sent in the Param field of the container
73 #define PIMA_COMMAND_SIZE(params) ((sizeof(SI_PIMA_Container_t) - sizeof(((SI_PIMA_Container_t*)NULL)->Params)) + \
74 (params * sizeof(uint32_t)))
76 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
79 * \param[in] datalen Length in bytes of the data in the container
81 #define PIMA_DATA_SIZE(datalen) ((sizeof(SI_PIMA_Container_t) - sizeof(((SI_PIMA_Container_t*)NULL)->Params)) + \
85 /** Enum for the possible PIMA contains types. */
86 enum SI_PIMA_Container_Types_t
88 CType_Undefined
= 0, /**< Undefined container type */
89 CType_CommandBlock
= 1, /**< Command Block container type */
90 CType_DataBlock
= 2, /**< Data Block container type */
91 CType_ResponseBlock
= 3, /**< Response container type */
92 CType_EventBlock
= 4, /**< Event Block container type */
96 /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */
97 enum SI_PIMA_ResponseCodes_t
99 PIMA_RESPONSE_OK
= 1, /**< Response code indicating no error in the issued command */
100 PIMA_RESPONSE_GeneralError
= 2, /**< Response code indicating a general error while processing the
103 PIMA_RESPONSE_SessionNotOpen
= 3, /**< Response code indicating that the sent command requires an open
104 * session before being issued
106 PIMA_RESPONSE_InvalidTransaction
= 4, /**< Response code indicating an invalid transaction occurred */
107 PIMA_RESPONSE_OperationNotSupported
= 5, /**< Response code indicating that the issued command is not supported
108 * by the attached device
110 PIMA_RESPONSE_ParameterNotSupported
= 6, /**< Response code indicating that one or more of the issued command's
111 * parameters are not supported by the device
116 /** Type define for a PIMA container, use to send commands and receive responses to and from an
117 * attached Still Image device.
121 uint32_t DataLength
; /**< Length of the container and data, in bytes */
122 uint16_t Type
; /**< Container type, a value from the PIMA_Container_Types_t enum */
123 uint16_t Code
; /**< Command, event or response code of the container */
124 uint32_t TransactionID
; /**< Unique container ID to link blocks together */
125 uint32_t Params
[5]; /**< Block parameters to be issued along with the block code (command blocks only) */
126 } SI_PIMA_Container_t
;
128 /* Disable C linkage for C++ Compilers: */
129 #if defined(__cplusplus)