Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 26 Jul 2009 10:22:16 +0000 (10:22 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 26 Jul 2009 10:22:16 +0000 (10:22 +0000)
LUFA/Drivers/USB/LowLevel/Host.c
LUFA/Drivers/USB/LowLevel/Pipe.c
LUFA/Drivers/USB/LowLevel/Pipe.h
LUFA/ManPages/ChangeLog.txt

index ae7525b..3d99b25 100644 (file)
@@ -187,7 +187,6 @@ void USB_Host_ProcessNextHostState(void)
 \r
                        EVENT_USB_DeviceEnumerationComplete();\r
                        USB_HostState = HOST_STATE_Addressed;\r
 \r
                        EVENT_USB_DeviceEnumerationComplete();\r
                        USB_HostState = HOST_STATE_Addressed;\r
-\r
                        break;\r
        }\r
 \r
                        break;\r
        }\r
 \r
index 7d3e876..0a32f18 100644 (file)
@@ -70,6 +70,22 @@ void Pipe_ClearPipes(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+bool Pipe_IsEndpointBound(uint8_t EndpointAddress)\r
+{\r
+       uint8_t PrevPipeNumber = Pipe_GetPipeNumber();\r
+\r
+       for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+       {\r
+               Pipe_SelectPipe(PNum);\r
+               \r
+               if (Pipe_IsConfigured() && (Pipe_BoundEndpointAddress() == EndpointAddress))\r
+                 return true;\r
+       }\r
+       \r
+       Pipe_SelectPipe(PrevPipeNumber);\r
+       return false;\r
+}\r
+\r
 uint8_t Pipe_WaitUntilReady(void)\r
 {\r
        #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
 uint8_t Pipe_WaitUntilReady(void)\r
 {\r
        #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
index fae8105..b6fad51 100644 (file)
                                 */\r
                                static inline bool Pipe_IsConfigured(void);\r
                                \r
                                 */\r
                                static inline bool Pipe_IsConfigured(void);\r
                                \r
+                               /** Retrieves the endpoint number of the endpoint within the attached device that the currently selected\r
+                                *  pipe is bound to.\r
+                                *\r
+                                *  \return Endpoint number the currently selected pipe is bound to\r
+                                */\r
+                               static inline uint8_t Pipe_BoundEndpointNumber(void);\r
+\r
                                /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
                                 *\r
                                 *  \param[in] Milliseconds  Number of milliseconds between each pipe poll\r
                                /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
                                 *\r
                                 *  \param[in] Milliseconds  Number of milliseconds between each pipe poll\r
 \r
                                #define Pipe_IsConfigured()            ((UPSTAX  & (1 << CFGOK)) ? true : false)\r
 \r
 \r
                                #define Pipe_IsConfigured()            ((UPSTAX  & (1 << CFGOK)) ? true : false)\r
 \r
+                               #define Pipe_BoundEndpointNumber()     ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK)\r
+                               \r
                                #define Pipe_SetInterruptPeriod(ms)    MACROS{ UPCFG2X = ms; }MACROE\r
 \r
                                #define Pipe_GetPipeInterrupts()       UPINT\r
                                #define Pipe_SetInterruptPeriod(ms)    MACROS{ UPCFG2X = ms; }MACROE\r
 \r
                                #define Pipe_GetPipeInterrupts()       UPINT\r
                        bool Pipe_ConfigurePipe(const uint8_t  Number, const uint8_t Type, const uint8_t Token, const uint8_t EndpointNumber,\r
                                                const uint16_t Size, const uint8_t Banks);\r
 \r
                        bool Pipe_ConfigurePipe(const uint8_t  Number, const uint8_t Type, const uint8_t Token, const uint8_t EndpointNumber,\r
                                                const uint16_t Size, const uint8_t Banks);\r
 \r
-                       /** Spinloops until the currently selected non-control pipe is ready for the next packed of data\r
-                        *  to be read or written to it.\r
+                       /** Spinloops until the currently selected non-control pipe is ready for the next packed of data to be read \r
+                        *  or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).\r
                         *\r
                         *  \ingroup Group_PipeRW\r
                         *\r
                         *  \return A value from the Pipe_WaitUntilReady_ErrorCodes_t enum.\r
                         */\r
                         *\r
                         *  \ingroup Group_PipeRW\r
                         *\r
                         *  \return A value from the Pipe_WaitUntilReady_ErrorCodes_t enum.\r
                         */\r
-                       uint8_t Pipe_WaitUntilReady(void);              \r
+                       uint8_t Pipe_WaitUntilReady(void);\r
+                       \r
+                       /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given\r
+                        *  endpoint is found, it is automatically selected.\r
+                        *\r
+                        *  \param EndpointAddress Address of the endpoint within the attached device to check\r
+                        *\r
+                        *  \return Boolean true if a pipe bound to the given endpoint address is found, false otherwise\r
+                        */\r
+                       bool Pipe_IsEndpointBound(uint8_t EndpointAddress);\r
                \r
                        /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
                         *  as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
                \r
                        /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
                         *  as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
index eb6c89e..f96168f 100644 (file)
@@ -33,6 +33,7 @@
   *  - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers\r
   *  - Added new Benito Arduino Programmer project\r
   *  - Added new LEDs_ToggleLEDs() function to the LEDs driver\r
   *  - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers\r
   *  - Added new Benito Arduino Programmer project\r
   *  - Added new LEDs_ToggleLEDs() function to the LEDs driver\r
+  *  - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions\r
   *  \r
   *  <b>Changed:</b>\r
   *  - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)\r
   *  \r
   *  <b>Changed:</b>\r
   *  - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)\r