Fixed HALT condition handling and data toggle.

This commit is contained in:
Gareth McMullin
2010-11-04 16:49:03 +13:00
parent d6eacce827
commit 87960830f4
6 changed files with 57 additions and 29 deletions

View File

@@ -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); \

View File

@@ -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
******************************************************************************/

View File

@@ -64,7 +64,8 @@ usbd_ep_write_packet(uint8_t addr, const void *buf, uint16_t len);
extern uint16_t
usbd_ep_read_packet(uint8_t addr, void *buf, uint16_t len);
extern void usbd_ep_stall(uint8_t addr);
extern void usbd_ep_stall_set(uint8_t addr, uint8_t stall);
extern uint8_t usbd_ep_stall_get(uint8_t addr);
/* Optional */
extern void usbd_cable_connect(uint8_t on);