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
33 * Header file for StillImageCommands.c.
36 #ifndef _STILL_IMAGE_COMMANDS_H_
37 #define _STILL_IMAGE_COMMANDS_H_
40 #include <LUFA/Drivers/USB/USB.h> // USB Functionality
42 #include "PIMACodes.h"
45 /** Pipe number of the Still Image data IN pipe */
46 #define SIMAGE_DATA_IN_PIPE 0x01
48 /** Pipe number of the Still Image data OUT pipe */
49 #define SIMAGE_DATA_OUT_PIPE 0x02
51 /** Pipe number of the Still Image events pipe */
52 #define SIMAGE_EVENTS_PIPE 0x03
54 /** Timeout period between the issuing of a command to a device, and the reception of the first packet */
55 #define COMMAND_DATA_TIMEOUT_MS 5000
57 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
58 * a command container.
60 * \param params Number of parameters which are to be sent in the Param field of the container
62 #define PIMA_COMMAND_SIZE(params) ((sizeof(PIMA_SendBlock) - sizeof(PIMA_SendBlock.Params)) + \
63 (params * sizeof(PIMA_SendBlock.Params[0])))
65 /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
68 * \param datalen Length in bytes of the data in the container
70 #define PIMA_DATA_SIZE(datalen) ((sizeof(PIMA_SendBlock) - sizeof(PIMA_SendBlock.Params)) + datalen)
73 /** Type define for a PIMA container, use to send commands and receive responses to and from an
74 * attached Still Image device.
78 uint32_t DataLength
; /**< Length of the container and data, in bytes */
79 uint16_t Type
; /**< Container type, a value from the PIMA_Container_Types_t enum */
80 uint16_t Code
; /**< Command, event or response code of the container */
81 uint32_t TransactionID
; /**< Unique container ID to link blocks together */
82 uint32_t Params
[4]; /**< Block parameters to be issued along with the block code (command blocks only) */
86 /** Enum for the possible PIMA contains types. */
87 enum PIMA_Container_Types_t
89 CType_Undefined
= 0, /**< Undefined container type */
90 CType_CommandBlock
= 1, /**< Command Block container type */
91 CType_DataBlock
= 2, /**< Data Block container type */
92 CType_ResponseBlock
= 3, /**< Response container type */
93 CType_EventBlock
= 4, /**< Event Block container type */
96 /* External Variables: */
97 extern PIMA_Container_t PIMA_SendBlock
;
98 extern PIMA_Container_t PIMA_ReceivedBlock
;
99 extern PIMA_Container_t PIMA_EventBlock
;
101 /* Function Prototypes: */
102 void SImage_SendBlockHeader(void);
103 uint8_t SImage_RecieveBlockHeader(void);
104 void SImage_RecieveEventHeader(void);
105 void SImage_SendData(void* Buffer
, uint16_t Bytes
);
106 uint8_t SImage_ReadData(void* Buffer
, uint16_t Bytes
);
107 bool SImage_IsEventReceived(void);
108 uint8_t SImage_ClearPipeStall(const uint8_t EndpointNum
);