More porting of the USB core to the AVR32.
[pub/lufa.git] / LUFA / Drivers / USB / LowLevel / Host.h
index 1e4d3c9..82a90d2 100644 (file)
@@ -63,7 +63,7 @@
 \r
        /* Preprocessor Checks: */\r
                #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
-                       #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+                       #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
                #endif\r
                \r
        /* Public Interface - May be used in end-application: */\r
                                 */\r
                                static inline bool USB_Host_IsResumeFromWakeupRequestSent(void);\r
                        #else\r
-                               #define USB_Host_ResetBus()                MACROS{ UHCON |=  (1 << RESET);          }MACROE\r
-\r
-                               #define USB_Host_IsBusResetComplete()      ((UHCON &   (1 << RESET)) ? false : true)\r
-\r
-                               #define USB_Host_ResumeBus()               MACROS{ UHCON |=  (1 << SOFEN);          }MACROE \r
-\r
-                               #define USB_Host_SuspendBus()              MACROS{ UHCON &= ~(1 << SOFEN);          }MACROE \r
-                               \r
-                               #define USB_Host_IsBusSuspended()                ((UHCON &   (1 << SOFEN)) ? false : true)\r
-                       \r
-                               #define USB_Host_IsDeviceFullSpeed()             ((USBSTA &  (1 << SPEED)) ? true : false)\r
-\r
-                               #define USB_Host_IsRemoteWakeupSent()            ((UHINT &   (1 << RXRSMI)) ? true : false)\r
-\r
-                               #define USB_Host_ClearRemoteWakeupSent()   MACROS{ UHINT &= ~(1 << RXRSMI);         }MACROE\r
-\r
-                               #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |=  (1 << RESUME);         }MACROE\r
-                               \r
-                               #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON &   (1 << RESUME)) ? false : true)\r
+                               #if defined(__AVR32__)\r
+                                       #define USB_Host_ResetBus()                MACROS{ AVR32_USBB.UHCON.reset = true;   }MACROE\r
+                                       #define USB_Host_IsBusResetComplete()              AVR32_USBB.UHCON.reset\r
+                                       #define USB_Host_ResumeBus()               MACROS{ AVR32_USBB.UHCON.sofen = true;   }MACROE \r
+                                       #define USB_Host_SuspendBus()              MACROS{ AVR32_USBB.UHCON.sofen = false;  }MACROE \r
+                                       #define USB_Host_IsBusSuspended()                  AVR32_USBB.UHCON.sofen\r
+                                       #define USB_Host_IsDeviceFullSpeed()              (AVR32_USBB.USBSTA.speed == 0)   \r
+                                       #define USB_Host_IsRemoteWakeupSent()              AVR32_USBB.UHINT.rxrsmi\r
+                                       #define USB_Host_ClearRemoteWakeupSent()   MACROS{ AVR32_USBB.UHINTCLR.rxrsmic = true; }MACROE\r
+                                       #define USB_Host_ResumeFromWakeupRequest() MACROS{ AVR32_USBB.UHCON.resume = true;     }MACROE\r
+                                       #define USB_Host_IsResumeFromWakeupRequestSent()   AVR32_USBB.UHCON.resume                      \r
+                               #elif defined(__AVR__)\r
+                                       #define USB_Host_ResetBus()                MACROS{ UHCON |=  (1 << RESET);          }MACROE\r
+                                       #define USB_Host_IsBusResetComplete()            ((UHCON &   (1 << RESET))  ? false : true)\r
+                                       #define USB_Host_ResumeBus()               MACROS{ UHCON |=  (1 << SOFEN);          }MACROE \r
+                                       #define USB_Host_SuspendBus()              MACROS{ UHCON &= ~(1 << SOFEN);          }MACROE \r
+                                       #define USB_Host_IsBusSuspended()                ((UHCON &   (1 << SOFEN))  ? false : true)\r
+                                       #define USB_Host_IsDeviceFullSpeed()             ((USBSTA &  (1 << SPEED))  ? true : false)\r
+                                       #define USB_Host_IsRemoteWakeupSent()            ((UHINT &   (1 << RXRSMI)) ? true : false)\r
+                                       #define USB_Host_ClearRemoteWakeupSent()   MACROS{ UHINT &= ~(1 << RXRSMI);         }MACROE\r
+                                       #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |=  (1 << RESUME);         }MACROE\r
+                                       #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON &   (1 << RESUME)) ? false : true)\r
+                               #endif\r
                        #endif\r
 \r
                /* Function Prototypes: */\r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Macros: */\r
-                       #define USB_Host_HostMode_On()          MACROS{ USBCON |=  (1 << HOST);           }MACROE\r
-                       #define USB_Host_HostMode_Off()         MACROS{ USBCON &= ~(1 << HOST);           }MACROE\r
+                       #if defined(__AVR32__)\r
+                               #define USB_Host_HostMode_On()          MACROS{ AVR32_USBB.USBCON.uimod = false;  }MACROE\r
+                               #define USB_Host_HostMode_Off()         MACROS{ AVR32_USBB.USBCON.uimod = true;   }MACROE\r
+\r
+                               #define USB_Host_VBUS_Auto_Enable()     MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |=  (1 << UVCONE);                   }MACROE\r
+                               #define USB_Host_VBUS_Manual_Enable()   MACROS{ OTGCON |=  (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
+\r
+                               #define USB_Host_VBUS_Auto_On()         MACROS{ OTGCON |= (1 << VBUSREQ);         }MACROE\r
+                               #define USB_Host_VBUS_Manual_On()       MACROS{ PORTE  |= (1 << 7);               }MACROE\r
 \r
-                       #define USB_Host_VBUS_Auto_Enable()     MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |=  (1 << UVCONE);                   }MACROE\r
-                       #define USB_Host_VBUS_Manual_Enable()   MACROS{ OTGCON |=  (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
+                               #define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE\r
+                               #define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE\r
 \r
-                       #define USB_Host_VBUS_Auto_On()         MACROS{ OTGCON |= (1 << VBUSREQ);         }MACROE\r
-                       #define USB_Host_VBUS_Manual_On()       MACROS{ PORTE  |= (1 << 7);               }MACROE\r
+                               #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE                       \r
+                       #elif defined(__AVR__)\r
+                               #define USB_Host_HostMode_On()          MACROS{ USBCON |=  (1 << HOST);           }MACROE\r
+                               #define USB_Host_HostMode_Off()         MACROS{ USBCON &= ~(1 << HOST);           }MACROE\r
 \r
-                       #define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE\r
-                       #define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE\r
+                               #define USB_Host_VBUS_Auto_Enable()     MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |=  (1 << UVCONE);                   }MACROE\r
+                               #define USB_Host_VBUS_Manual_Enable()   MACROS{ OTGCON |=  (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
 \r
-                       #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE\r
+                               #define USB_Host_VBUS_Auto_On()         MACROS{ OTGCON |= (1 << VBUSREQ);         }MACROE\r
+                               #define USB_Host_VBUS_Manual_On()       MACROS{ PORTE  |= (1 << 7);               }MACROE\r
 \r
+                               #define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE\r
+                               #define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE\r
+\r
+                               #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE\r
+                       #endif\r
+                       \r
                /* Enums: */\r
                        enum USB_Host_WaitMSErrorCodes_t\r
                        {\r