3      Copyright (C) Dean Camera, 2009. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  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. 
  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) 
  55                 /** Length in bytes of a given Unicode string's character length 
  57                  *  \param[in] chars  Total number of Unicode characters in the string 
  59                 #define UNICODE_STRING_LENGTH(chars)   (chars << 1) 
  61                 /** Timeout period between the issuing of a command to a device, and the reception of the first packet */ 
  62                 #define COMMAND_DATA_TIMEOUT_MS        5000 
  64                 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for 
  65                  *  a command container. 
  67                  *  \param[in] params  Number of parameters which are to be sent in the Param field of the container 
  69                 #define PIMA_COMMAND_SIZE(params)      ((sizeof(PIMA_SendBlock) - sizeof(PIMA_SendBlock.Params)) + \ 
  70                                                         (params * sizeof(PIMA_SendBlock.Params[0]))) 
  72                 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for 
  75                  *  \param[in] datalen  Length in bytes of the data in the container 
  77                 #define PIMA_DATA_SIZE(datalen)        ((sizeof(PIMA_SendBlock) - sizeof(PIMA_SendBlock.Params)) + datalen) 
  80                 /** Type define for a PIMA container, use to send commands and receive responses to and from an 
  81                  *  attached Still Image device. 
  85                         uint32_t DataLength
; /**< Length of the container and data, in bytes */ 
  86                         uint16_t Type
; /**< Container type, a value from the PIMA_Container_Types_t enum */ 
  87                         uint16_t Code
; /**< Command, event or response code of the container */ 
  88                         uint32_t TransactionID
; /**< Unique container ID to link blocks together */ 
  89                         uint32_t Params
[4]; /**< Block parameters to be issued along with the block code (command blocks only) */ 
  90                 } SI_PIMA_Container_t
; 
  93                 /** Enum for the possible PIMA contains types. */ 
  94                 enum SI_PIMA_Container_Types_t
 
  96                         CType_Undefined         
= 0, /**< Undefined container type */ 
  97                         CType_CommandBlock      
= 1, /**< Command Block container type */ 
  98                         CType_DataBlock         
= 2, /**< Data Block container type */ 
  99                         CType_ResponseBlock     
= 3, /**< Response container type */ 
 100                         CType_EventBlock        
= 4, /**< Event Block container type */ 
 109         /* Disable C linkage for C++ Compilers: */ 
 110                 #if defined(__cplusplus)