Add const keyword to the demo function parameters where possible.
[pub/USBasp.git] / Demos / Host / LowLevel / StillImageHost / Lib / StillImageCommands.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 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 *
33 * Header file for StillImageCommands.c.
34 */
35
36 #ifndef _STILL_IMAGE_COMMANDS_H_
37 #define _STILL_IMAGE_COMMANDS_H_
38
39 /* Includes: */
40 #include <LUFA/Drivers/USB/USB.h>
41
42 #include "PIMACodes.h"
43
44 /* Macros: */
45 /** Pipe number of the Still Image data IN pipe */
46 #define SIMAGE_DATA_IN_PIPE 0x01
47
48 /** Pipe number of the Still Image data OUT pipe */
49 #define SIMAGE_DATA_OUT_PIPE 0x02
50
51 /** Pipe number of the Still Image events pipe */
52 #define SIMAGE_EVENTS_PIPE 0x03
53
54 /** Length in bytes of a given Unicode string's character length
55 *
56 * \param[in] chars Total number of Unicode characters in the string
57 */
58 #define UNICODE_STRING_LENGTH(chars) ((chars) << 1)
59
60 /** Timeout period between the issuing of a command to a device, and the reception of the first packet */
61 #define COMMAND_DATA_TIMEOUT_MS 10000
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(PIMA_SendBlock) - sizeof(PIMA_SendBlock.Params)) + \
69 ((params) * sizeof(PIMA_SendBlock.Params[0])))
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(PIMA_SendBlock) - sizeof(PIMA_SendBlock.Params)) + datalen)
77
78 /* Type Defines: */
79 /** Type define for a PIMA container, use to send commands and receive responses to and from an
80 * attached Still Image device.
81 */
82 typedef struct
83 {
84 uint32_t DataLength; /**< Length of the container and data, in bytes */
85 uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */
86 uint16_t Code; /**< Command, event or response code of the container */
87 uint32_t TransactionID; /**< Unique container ID to link blocks together */
88 uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */
89 } PIMA_Container_t;
90
91 /* Enums: */
92 /** Enum for the possible PIMA contains types. */
93 enum PIMA_Container_Types_t
94 {
95 CType_Undefined = 0, /**< Undefined container type */
96 CType_CommandBlock = 1, /**< Command Block container type */
97 CType_DataBlock = 2, /**< Data Block container type */
98 CType_ResponseBlock = 3, /**< Response container type */
99 CType_EventBlock = 4, /**< Event Block container type */
100 };
101
102 /* External Variables: */
103 extern PIMA_Container_t PIMA_SendBlock;
104 extern PIMA_Container_t PIMA_ReceivedBlock;
105 extern PIMA_Container_t PIMA_EventBlock;
106
107 /* Function Prototypes: */
108 void SImage_SendBlockHeader(void);
109 uint8_t SImage_ReceiveBlockHeader(void);
110 uint8_t SImage_ReceiveEventHeader(void);
111 uint8_t SImage_SendData(void* const Buffer, const uint16_t Bytes);
112 uint8_t SImage_ReadData(void* const Buffer, const uint16_t Bytes);
113 bool SImage_IsEventReceived(void);
114
115 #endif