summaryrefslogtreecommitdiff
path: root/tinyusb/common
diff options
context:
space:
mode:
Diffstat (limited to 'tinyusb/common')
-rw-r--r--tinyusb/common/common.h15
1 files changed, 15 insertions, 0 deletions
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)
{