Commit fef185a4 authored by Dean Camera's avatar Dean Camera
Browse files

Cleanup USBMode.h to simplify preprocessor logic.

parent bb05712e
...@@ -33,15 +33,8 @@ ...@@ -33,15 +33,8 @@
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */
#if ((defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
defined(__AVR_ATmega32U6__)) && !defined(USB_DEVICE_ONLY))
#define USB_DEVICE_ONLY
#endif
#if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
#define USB_SERIES_2_AVR #define USB_SERIES_2_AVR
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
...@@ -52,31 +45,27 @@ ...@@ -52,31 +45,27 @@
#define USB_SERIES_7_AVR #define USB_SERIES_7_AVR
#endif #endif
#if !defined(USB_SERIES_7_AVR)
#if defined(USB_HOST_ONLY)
#error USB_HOST_ONLY is not available for the currently selected USB AVR model.
#endif
#define USB_DEVICE_ONLY
#endif
#if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY)) #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))
#define USB_CAN_BE_BOTH #define USB_CAN_BE_BOTH
#define USB_CAN_BE_HOST #define USB_CAN_BE_HOST
#define USB_CAN_BE_DEVICE #define USB_CAN_BE_DEVICE
#elif defined(USB_HOST_ONLY) #elif defined(USB_HOST_ONLY)
#define USB_CAN_BE_HOST #define USB_CAN_BE_HOST
#define USB_CurrentMode USB_MODE_HOST
#elif defined(USB_DEVICE_ONLY) #elif defined(USB_DEVICE_ONLY)
#define USB_CAN_BE_DEVICE #define USB_CAN_BE_DEVICE
#define USB_CurrentMode USB_MODE_DEVICE
#endif
#if (!defined(USB_SERIES_7_AVR) && defined(USB_HOST_ONLY))
#error USB_HOST_ONLY is not available for the currently selected USB AVR model.
#endif #endif
#if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY)) #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
#error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive. #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
#endif #endif
#if defined(USE_STATIC_OPTIONS)
#define USB_Options USE_STATIC_OPTIONS
#endif
#endif #endif
#endif #endif
...@@ -301,6 +301,10 @@ ...@@ -301,6 +301,10 @@
* changed in value. * changed in value.
*/ */
extern volatile uint8_t USB_CurrentMode; extern volatile uint8_t USB_CurrentMode;
#elif defined(USB_HOST_ONLY)
#define USB_CurrentMode USB_MODE_HOST
#elif defined(USB_DEVICE_ONLY)
#define USB_CurrentMode USB_MODE_DEVICE
#endif #endif
#if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
...@@ -311,6 +315,8 @@ ...@@ -311,6 +315,8 @@
* changed in value. * changed in value.
*/ */
extern volatile uint8_t USB_Options; extern volatile uint8_t USB_Options;
#elif defined(USE_STATIC_OPTIONS)
#define USB_Options USE_STATIC_OPTIONS
#endif #endif
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment