aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/USB/Class')
-rw-r--r--LUFA/Drivers/USB/Class/Common/MIDI.h2
-rw-r--r--LUFA/Drivers/USB/Class/Common/StillImage.h12
-rw-r--r--LUFA/Drivers/USB/Class/Host/StillImage.c12
3 files changed, 14 insertions, 12 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/MIDI.h b/LUFA/Drivers/USB/Class/Common/MIDI.h
index 8eed10198..755006a70 100644
--- a/LUFA/Drivers/USB/Class/Common/MIDI.h
+++ b/LUFA/Drivers/USB/Class/Common/MIDI.h
@@ -87,7 +87,7 @@
*
* \param[in] channel MIDI channel number to address
*/
- #define MIDI_CHANNEL(channel) (channel - 1)
+ #define MIDI_CHANNEL(channel) ((channel) - 1)
/* Type Defines: */
/** Type define for an Audio class specific MIDI streaming interface descriptor. This indicates to the host
diff --git a/LUFA/Drivers/USB/Class/Common/StillImage.h b/LUFA/Drivers/USB/Class/Common/StillImage.h
index 7b3df201a..e65b2dbfd 100644
--- a/LUFA/Drivers/USB/Class/Common/StillImage.h
+++ b/LUFA/Drivers/USB/Class/Common/StillImage.h
@@ -63,23 +63,23 @@
*
* \return Number of bytes of the given unicode string
*/
- #define UNICODE_STRING_LENGTH(chars) (chars << 1)
+ #define UNICODE_STRING_LENGTH(chars) ((chars) << 1)
/** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
* a command container.
*
* \param[in] params Number of parameters which are to be sent in the Param field of the container
*/
- #define PIMA_COMMAND_SIZE(params) ((sizeof(SI_PIMA_Container_t) - sizeof(((SI_PIMA_Container_t*)NULL)->Params)) + \
- (params * sizeof(uint32_t)))
+ #define PIMA_COMMAND_SIZE(params) ((sizeof(SI_PIMA_Container_t) - 12) + \
+ ((params) * sizeof(uint32_t)))
/** Used in the DataLength field of a PIMA container, to give the total container size in bytes for
* a data container.
*
* \param[in] datalen Length in bytes of the data in the container
*/
- #define PIMA_DATA_SIZE(datalen) ((sizeof(SI_PIMA_Container_t) - sizeof(((SI_PIMA_Container_t*)NULL)->Params)) + \
- datalen)
+ #define PIMA_DATA_SIZE(datalen) ((sizeof(SI_PIMA_Container_t) - 12) + \
+ (datalen))
/* Enums: */
/** Enum for the possible PIMA contains types. */
@@ -122,7 +122,7 @@
uint16_t Type; /**< Container type, a value from the PIMA_Container_Types_t enum */
uint16_t Code; /**< Command, event or response code of the container */
uint32_t TransactionID; /**< Unique container ID to link blocks together */
- uint32_t Params[5]; /**< Block parameters to be issued along with the block code (command blocks only) */
+ uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */
} SI_PIMA_Container_t;
/* Disable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.c b/LUFA/Drivers/USB/Class/Host/StillImage.c
index 577f619c8..d116ceb74 100644
--- a/LUFA/Drivers/USB/Class/Host/StillImage.c
+++ b/LUFA/Drivers/USB/Class/Host/StillImage.c
@@ -315,12 +315,15 @@ uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
uint8_t ErrorCode;
+ SIInterfaceInfo->State.TransactionID = 0;
+ SIInterfaceInfo->State.IsSessionOpen = false;
+
SI_PIMA_Container_t PIMABlock = (SI_PIMA_Container_t)
{
- .DataLength = PIMA_COMMAND_SIZE(0),
+ .DataLength = PIMA_COMMAND_SIZE(1),
.Type = CType_CommandBlock,
.Code = 0x1002,
- .Params = {},
+ .Params = {1},
};
if ((ErrorCode = SImage_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
@@ -332,7 +335,6 @@ uint8_t SImage_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
if ((PIMABlock.Type != CType_ResponseBlock) || (PIMABlock.Code != 0x2001))
return SI_ERROR_LOGICAL_CMD_FAILED;
- SIInterfaceInfo->State.TransactionID = 0;
SIInterfaceInfo->State.IsSessionOpen = true;
return PIPE_RWSTREAM_NoError;
@@ -347,10 +349,10 @@ uint8_t SImage_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
SI_PIMA_Container_t PIMABlock = (SI_PIMA_Container_t)
{
- .DataLength = PIMA_COMMAND_SIZE(0),
+ .DataLength = PIMA_COMMAND_SIZE(1),
.Type = CType_CommandBlock,
.Code = 0x1003,
- .Params = {},
+ .Params = {1},
};
if ((ErrorCode = SImage_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)