summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-07-04 10:47:31 +0700
committerhathach <[email protected]>2013-07-04 10:47:31 +0700
commitd3aed0187446ceffb6009a5f32a9f266a09bab29 (patch)
treea9abe9f20efdd6a25e6241bff56939dafcfae336 /tinyusb
parentc5afb9d50f3aea59dfdf016a1ae33ab511249de7 (diff)
add some printf when a class is mounted
add initial tests for rndis
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/cdc_host.c3
-rw-r--r--tinyusb/common/common.h15
2 files changed, 17 insertions, 1 deletions
diff --git a/tinyusb/class/cdc_host.c b/tinyusb/class/cdc_host.c
index 3831fc243..ac4338853 100644
--- a/tinyusb/class/cdc_host.c
+++ b/tinyusb/class/cdc_host.c
@@ -134,7 +134,8 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
return TUSB_ERROR_CDCH_UNSUPPORTED_SUBCLASS;
}
- if (CDC_COMM_PROTOCOL_ATCOMMAND != p_interface_desc->bInterfaceProtocol)
+ if ( !(is_in_range(CDC_COMM_PROTOCOL_ATCOMMAND, p_interface_desc->bInterfaceProtocol, CDC_COMM_PROTOCOL_ATCOMMAND_CDMA) ||
+ 0xff == p_interface_desc->bInterfaceProtocol) )
{
return TUSB_ERROR_CDCH_UNSUPPORTED_PROTOCOL;
}
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index ed543de00..3a43f123c 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -192,6 +192,21 @@ static inline uint32_t offset4k(uint32_t value)
}
//------------- Mathematics -------------//
+/// inclusive range checking
+static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST;
+static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper)
+{
+ return (lower <= value) && (value <= upper);
+}
+
+/// exclusive range checking
+static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST;
+static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper)
+{
+ return (lower < value) && (value < upper);
+}
+
+
static inline uint8_t log2_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
static inline uint8_t log2_of(uint32_t value)
{