Fix MassStorageKeyboard demo USE_INTERNAL_SERIAL check being performed before the...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 4 Jan 2010 13:34:02 +0000 (13:34 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 4 Jan 2010 13:34:02 +0000 (13:34 +0000)
Added notes to the class driver functions indicating which functions require what Device/Host state machine states to function.

17 files changed:
Demos/Device/ClassDriver/MassStorageKeyboard/Descriptors.c
Demos/Device/ClassDriver/MassStorageKeyboard/makefile
LUFA/Drivers/USB/Class/Device/Audio.h
LUFA/Drivers/USB/Class/Device/CDC.h
LUFA/Drivers/USB/Class/Device/HID.c
LUFA/Drivers/USB/Class/Device/HID.h
LUFA/Drivers/USB/Class/Device/MIDI.h
LUFA/Drivers/USB/Class/Host/CDC.h
LUFA/Drivers/USB/Class/Host/HID.c
LUFA/Drivers/USB/Class/Host/HID.h
LUFA/Drivers/USB/Class/Host/MIDI.h
LUFA/Drivers/USB/Class/Host/MassStorage.h
LUFA/Drivers/USB/Class/Host/Printer.h
LUFA/Drivers/USB/Class/Host/RNDIS.h
LUFA/Drivers/USB/Class/Host/StillImage.h
LUFA/ManPages/LUFAPoweredProjects.txt
Projects/Incomplete/StandaloneProgrammer/DiskHost.c

index b779ea3..d3e4214 100644 (file)
   this software.\r
 */\r
 \r
-#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR)\r
-       #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor.\r
-#endif\r
-\r
 /** \file\r
  *\r
  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special \r
 \r
 #include "Descriptors.h"\r
 \r
+/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as\r
+ * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL.\r
+ * This allows the host to track a device across insertions on different ports, allowing them to retain allocated\r
+ * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices\r
+ * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value\r
+ * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and\r
+ * port location).\r
+ */\r
+#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR)\r
+       #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor.\r
+#endif\r
+\r
 /** HID class report descriptor. This is a special descriptor constructed with values from the\r
  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This\r
  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding)\r
index 30efdea..3fc8293 100644 (file)
@@ -123,8 +123,7 @@ LUFA_PATH = ../../../..
 \r
 \r
 # LUFA library compile-time options\r
-LUFA_OPTS  = -D USE_NONSTANDARD_DESCRIPTOR_NAMES\r
-LUFA_OPTS += -D USB_DEVICE_ONLY\r
+LUFA_OPTS  = -D USB_DEVICE_ONLY\r
 LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8\r
 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1\r
 LUFA_OPTS += -D USE_FLASH_DESCRIPTORS\r
@@ -132,6 +131,7 @@ LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENAB
 LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT\r
 \r
 \r
+\r
 # List C source files here. (C dependencies are automatically generated.)\r
 SRC = $(TARGET).c                                                 \\r
          Descriptors.c                                               \\r
index fcfd65d..e516b71 100644 (file)
                        /** Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming\r
                         *  OUT endpoint ready for reading.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class configuration and state\r
                         *\r
                         *  \return Boolean true if the given Audio interface has a sample to be read, false otherwise\r
                        /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects\r
                         *  the streaming IN endpoint ready for writing.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class configuration and state\r
                         *\r
                         *  \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise\r
index fb64d9e..30d3526 100644 (file)
                        /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the\r
                         *  string is discarded.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
                         *  \param[in] Data  Pointer to the string to send to the host\r
                         *  \param[in] Length  Size in bytes of the string to send to the host\r
                        /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the\r
                         *  byte is discarded.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
                         *  \param[in] Data  Byte of data to send to the host\r
                         *\r
                        \r
                        /** Determines the number of bytes received by the CDC interface from the host, waiting to be read.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
                         *\r
                         *  \return Total number of buffered bytes received from the host\r
                         *  returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is received to ensure that no data\r
                         *  underflow occurs.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
                         *\r
                         *  \return Next received byte from the host, or 0 if no data received\r
                        \r
                        /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
                         *\r
                         *  \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum\r
                         *  until they are cleared via a second notification. This should be called each time the CDC class driver's \r
                         *  ControlLineStates.DeviceToHost value is updated to push the new states to the USB host.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class configuration and state\r
                         */\r
                        void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
index 1c638bc..a5c03f7 100644 (file)
@@ -186,10 +186,4 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
        }\r
 }\r
 \r
-void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo)\r
-{\r
-       if (HIDInterfaceInfo->State.IdleMSRemaining)\r
-         HIDInterfaceInfo->State.IdleMSRemaining--;\r
-}\r
-\r
 #endif\r
index fcea5ae..14a5ff6 100644 (file)
                         *\r
                         *  \param[in,out] HIDInterfaceInfo  Pointer to a structure containing a HID Class configuration and state\r
                         */\r
-                       void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+                       static inline void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);\r
+                       static inline void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo)\r
+                       {\r
+                               if (HIDInterfaceInfo->State.IdleMSRemaining)\r
+                                 HIDInterfaceInfo->State.IdleMSRemaining--;\r
+                       }\r
                        \r
                        /** HID class driver callback for the user creation of a HID IN report. This callback may fire in response to either\r
                         *  HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the\r
index bccaa20..3899f6e 100644 (file)
 \r
                        /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] MIDIInterfaceInfo  Pointer to a structure containing a MIDI Class configuration and state\r
                         *  \param[in] Event  Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send\r
                         *\r
 \r
                        /** Receives a MIDI event packet from the host.\r
                         *\r
+                        *  \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or\r
+                        *        the call will fail.\r
+                        *\r
                         *  \param[in,out] MIDIInterfaceInfo  Pointer to a structure containing a MIDI Class configuration and state\r
                         *  \param[out] Event  Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed\r
                         *\r
index d2e98c0..20ee320 100644 (file)
                        /** Sends a given string to the attached USB device, if connected. If a device is not connected when the function is called, the\r
                         *  string is discarded.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *  \param[in] Data  Pointer to the string to send to the device\r
                         *  \param[in] Length  Size in bytes of the string to send to the device\r
                        /** Sends a given byte to the attached USB device, if connected. If a host is not connected when the function is called, the\r
                         *  byte is discarded.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *  \param[in] Data  Byte of data to send to the device\r
                         *\r
 \r
                        /** Determines the number of bytes received by the CDC interface from the device, waiting to be read.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *\r
                         *  \return Total number of buffered bytes received from the device\r
                         *  returns 0. The \ref CDC_Host_BytesReceived() function should be queried before data is received to ensure that no data\r
                         *  underflow occurs.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *\r
                         *  \return Next received byte from the device, or 0 if no data received\r
                        \r
                        /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] CDCInterfaceInfo  Pointer to a structure containing a CDC Class host configuration and state\r
                         *\r
                         *  \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum\r
index 010b27b..e297ee5 100644 (file)
@@ -220,6 +220,9 @@ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
                                 void* Buffer, const uint16_t ReportSize)\r
 {\r
 #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+       if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))\r
+         return false;\r
+\r
        if (HIDInterfaceInfo->State.DeviceUsesOUTPipe)\r
        {\r
                uint8_t ErrorCode;\r
index 01174c5..72478c2 100644 (file)
 \r
                        /** Receives a HID IN report from the attached HID device, when a report has been received on the HID IN Data pipe.\r
                         *  \r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \note The destination buffer should be large enough to accommodate the largest report that the attached device\r
                         *        can generate.\r
                         *\r
                        #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
                        /** Receives a HID IN report from the attached device, by the report ID.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable.\r
                         *\r
                         *  \param[in,out] HIDInterfaceInfo  Pointer to a structure containing a HID Class host configuration and state\r
                        /** Sends an OUT report to the currently attached HID device, using the device's OUT pipe if available or the device's\r
                         *  Control pipe if not.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, the ReportID parameter is removed\r
                         *        from the parameter list of this function.\r
                         *\r
 \r
                        /** Determines if a HID IN report has been received from the attached device on the data IN pipe.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] HIDInterfaceInfo  Pointer to a structure containing a HID Class host configuration and state\r
                         *\r
                         *  \return Boolean true if a report has been received, false otherwise\r
index 31b7991..2a64dc0 100644 (file)
 \r
                        /** Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MIDIInterfaceInfo  Pointer to a structure containing a MIDI Class configuration and state\r
                         *  \param[in] Event  Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send\r
                         *\r
 \r
                        /** Receives a MIDI event packet from the device.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MIDIInterfaceInfo  Pointer to a structure containing a MIDI Class configuration and state\r
                         *  \param[out] Event  Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed\r
                         *\r
index c6ca67c..7c30409 100644 (file)
                        /** Retrieves the Mass Storage device's inquiry data for the specified LUN, indicating the device characteristics and\r
                         *  properties.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[in] LUNIndex  LUN index within the device the command is being issued to\r
                         *  \param[out] InquiryData  Location where the read inquiry data should be stored\r
 \r
                        /** Retrieves the total capacity of the attached USB Mass Storage device, in blocks, and block size.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[in] LUNIndex  LUN index within the device the command is being issued to\r
                         *  \param[out] DeviceCapacity  Pointer to the location where the capacity information should be stored\r
                        /** Retrieves the device sense data, indicating the current device state and error codes for the previously\r
                         *  issued command.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[in] LUNIndex  LUN index within the device the command is being issued to\r
                         *  \param[out] SenseData  Pointer to the location where the sense information should be stored\r
                        /** Issues a PREVENT MEDIUM REMOVAL command, to logically (or, depending on the type of device, physically) lock\r
                         *  the device from removal so that blocks of data on the medium can be read or altered.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[in] LUNIndex  LUN index within the device the command is being issued to\r
                         *  \param[in] PreventRemoval  Boolean true if the device should be locked from removal, false otherwise\r
                        \r
                        /** Reads blocks of data from the attached Mass Storage device's medium.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[in] LUNIndex  LUN index within the device the command is being issued to\r
                         *  \param[in] BlockAddress  Starting block address within the device to read from\r
                \r
                        /** Writes blocks of data to the attached Mass Storage device's medium.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] MSInterfaceInfo  Pointer to a structure containing a MS Class host configuration and state\r
                         *  \param[in] LUNIndex  LUN index within the device the command is being issued to\r
                         *  \param[in] BlockAddress  Starting block address within the device to write to\r
index b7a1ae7..c424daf 100644 (file)
                         *  printer is able to understand - for example, PCL data. Not all printers accept all printer languages; see\r
                         *  \ref PRNT_Host_GetDeviceID() for details on determining acceptable languages for an attached printer.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] PRNTInterfaceInfo  Pointer to a structure containing a Printer Class host configuration and state\r
                         *  \param[in] PrinterCommands  Pointer to a buffer containing the raw command stream to send to the printer\r
                         *  \param[in] CommandSize  Size in bytes of the command stream to be sent\r
index 827cd65..fad27b9 100644 (file)
 \r
                        /** Determines if a packet is currently waiting for the host to read in and process.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] RNDISInterfaceInfo  Pointer to a structure containing an RNDIS Class host configuration and state\r
                         *\r
                         *  \return Boolean true if a packet is waiting to be read in by the host, false otherwise\r
                        /** Retrieves the next pending packet from the device, discarding the remainder of the RNDIS packet header to leave\r
                         *  only the packet contents for processing by the host in the nominated buffer.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] RNDISInterfaceInfo  Pointer to a structure containing an RNDIS Class host configuration and state\r
                         *  \param[out] Buffer  Pointer to a buffer where the packer data is to be written to\r
                         *  \param[out] PacketLength  Pointer to where the length in bytes of the read packet is to be stored\r
 \r
                        /** Sends the given packet to the attached RNDIS device, after adding a RNDIS packet message header.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] RNDISInterfaceInfo  Pointer to a structure containing an RNDIS Class host configuration and state\r
                         *  \param[in] Buffer  Pointer to a buffer where the packer data is to be read from\r
                         *  \param[in] PacketLength  Length in bytes of the packet to send\r
index 5dec6f0..9b65596 100644 (file)
 \r
                        /** Opens a new PIMA session with the attached device. This should be used before any session-orientated PIMA commands\r
                         *  are issued to the device. Only one session can be open at the one time.\r
-                        *                       \r
+                        *      \r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *\r
                         *  \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
 \r
                        /** Closes an already opened PIMA session with the attached device. This should be used after all session-orientated\r
                         *  PIMA commands have been issued to the device.\r
-                        *                       \r
+                        *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *\r
                         *  \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
                        /** Sends a raw PIMA block header to the device, filling out the transaction ID automatically. This can be used to send\r
                         *  arbitrary PIMA blocks to the device with or without parameters.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *  \param[in] PIMAHeader  Pointer to a PIMA container structure that is to be sent\r
                         *\r
                        /** Receives a raw PIMA block header to the device. This can be used to receive arbitrary PIMA blocks from the device with\r
                         *  or without parameters.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *  \param[out] PIMAHeader  Pointer to a PIMA container structure where the received block is to be stored\r
                         *\r
                        uint8_t SImage_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, SI_PIMA_Container_t* const PIMAHeader);\r
 \r
                        /** Sends a given PIMA command to the attached device, filling out the PIMA command header's Transaction ID automatically.\r
-                        *                       \r
+                        *      \r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *  \param[in] Operation  PIMA operation code to issue to the device\r
                         *  \param[in] TotalParams  Total number of 32-bit parameters to send to the device in the issued command block\r
 \r
                        /** Receives and checks a response block from the attached PIMA device, once a command has been issued and all data\r
                         *  associated with the command has been transferred.\r
-                        *                       \r
+                        *      \r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *\r
                         *  \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
 \r
                        /** Indicates if the device has issued a PIMA event block to the host via the asynchronous events pipe.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *\r
                         *  \return Boolean true if an event is waiting to be read, false otherwise\r
 \r
                        /** Receives an asynchronous event block from the device via the asynchronous events pipe.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *  \param[out] PIMAHeader  Pointer to a PIMA container structure where the event should be stored\r
                         *\r
                        /** Sends arbitrary data to the attached device, for use in the data phase of PIMA commands which require data\r
                         *  transfer beyond the regular PIMA command block parameters.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *  \param[in] Buffer  Pointer to a buffer where the data to send has been stored\r
                         *  \param[in] Bytes  Length in bytes of the data in the buffer to send to the attached device\r
                        /** Receives arbitrary data from the attached device, for use in the data phase of PIMA commands which require data\r
                         *  transfer beyond the regular PIMA command block parameters.\r
                         *\r
+                        *  \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+                        *        call will fail.\r
+                        *\r
                         *  \param[in,out] SIInterfaceInfo  Pointer to a structure containing a Still Image Class host configuration and state\r
                         *  \param[out] Buffer  Pointer to a buffer where the received data is to be stored\r
                         *  \param[in] Bytes  Length in bytes of the data to read\r
index df31db8..f07750f 100644 (file)
@@ -18,6 +18,7 @@
  *  The following is a list of known AVR USB development boards, which recommend using LUFA for the USB stack. Some of these\r
  *  are open design, and all are available for purchase as completed development boards suitable for project development.\r
  *\r
+ *  - AT90USB162 Breadboard PCB (Russian): http://microsin.ru/content/view/685/44/\r
  *  - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/wiki/benito\r
  *  - Bumble-B, yet another AT90USB162 development board: http://fletchtronics.net/bumble-b\r
  *  - Micropendous, an open design/source set of AVR USB development boards: http://micropendous.org/\r
@@ -64,4 +65,8 @@
  *  - Lightweight CC110x USB dongle for 868MHz Protocols: http://busware.de/tiki-index.php?page=CUL\r
  *  - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3\r
  *  - SEGA Megadrive/Super Nintendo Cartridge Reader: http://www.snega2usb.com\r
+ *\r
+ *  \section Sec_LUFAPublications Publications Mentioning LUFA\r
+ *  - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue\r
+ *  - Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue\r
  */
\ No newline at end of file
index ef69df2..e50fc30 100644 (file)
@@ -79,8 +79,6 @@ void DiskHost_USBTask(void)
                        return;\r
                }\r
                \r
-               USB_HostState = HOST_STATE_Configured;\r
-               \r
                uint8_t MaxLUNIndex;\r
                if (MS_Host_GetMaxLUN(&DiskHost_MS_Interface, &MaxLUNIndex))\r
                {\r
@@ -96,6 +94,10 @@ void DiskHost_USBTask(void)
                        return;\r
                }\r
                \r
+               USB_HostState = HOST_STATE_Configured;\r
+               \r
+               /* Note: For the RequestSense call to work, the host state machine must be in the \r
+                *       Configured state, or the call will be aborted */\r
                SCSI_Request_Sense_Response_t SenseData;\r
                if (MS_Host_RequestSense(&DiskHost_MS_Interface, 0, &SenseData) != 0)\r
                {\r