aboutsummaryrefslogtreecommitdiff
path: root/include/libopenstm32
diff options
context:
space:
mode:
Diffstat (limited to 'include/libopenstm32')
-rw-r--r--include/libopenstm32/tools.h4
-rw-r--r--include/libopenstm32/usb.h12
2 files changed, 14 insertions, 2 deletions
diff --git a/include/libopenstm32/tools.h b/include/libopenstm32/tools.h
index 2a7a0f1..8b32413 100644
--- a/include/libopenstm32/tools.h
+++ b/include/libopenstm32/tools.h
@@ -52,10 +52,10 @@
*/
#define TOG_SET_REG_BIT_MSK(REG, MSK, BIT) \
do { \
- register u16 toggle_mask = GET_REG(REG) & MSK; \
+ register u16 toggle_mask = GET_REG(REG) & (MSK); \
register u16 bit_selector; \
for (bit_selector = 1; bit_selector; bit_selector <<= 1) { \
- if ((bit_selector & BIT) != 0) \
+ if ((bit_selector & (BIT)) != 0) \
toggle_mask ^= bit_selector; \
} \
SET_REG(REG, toggle_mask); \
diff --git a/include/libopenstm32/usb.h b/include/libopenstm32/usb.h
index 3e0efe9..6edfee3 100644
--- a/include/libopenstm32/usb.h
+++ b/include/libopenstm32/usb.h
@@ -244,6 +244,18 @@
(USB_EP_NTOGGLE_MSK & \
(~USB_EP_ADDR))) | ADDR))
+/* Macros for clearing DTOG bits */
+#define USB_CLR_EP_TX_DTOG(EP) \
+ SET_REG(USB_EP_REG(EP), \
+ (GET_REG(USB_EP_REG(EP)) & \
+ USB_EP_NTOGGLE_MSK) | USB_EP_TX_DTOG)
+
+#define USB_CLR_EP_RX_DTOG(EP) \
+ SET_REG(USB_EP_REG(EP), \
+ (GET_REG(USB_EP_REG(EP)) & \
+ USB_EP_NTOGGLE_MSK) | USB_EP_RX_DTOG)
+
+
/******************************************************************************
* USB BTABLE registers
******************************************************************************/