Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit cc9b2dd

Browse files
committed
Optimize isr_SUDAV().
1 parent b06923b commit cc9b2dd

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

firmware/library/usb.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,67 +68,70 @@ __asm
6868
mov _DPS, #0
6969
__endasm;
7070

71+
uint8_t bmRequestType = req->bmRequestType;
72+
uint8_t bRequest = req->bRequest;
73+
7174
// Get Descriptor
72-
if(req->bmRequestType == (USB_RECIP_DEVICE|USB_DIR_IN) &&
73-
req->bRequest == USB_REQ_GET_DESCRIPTOR) {
75+
if(bmRequestType == (USB_RECIP_DEVICE|USB_DIR_IN) &&
76+
bRequest == USB_REQ_GET_DESCRIPTOR) {
7477
enum usb_descriptor type = (enum usb_descriptor)(req->wValue >> 8);
7578
uint8_t index = req->wValue & 0xff;
7679
handle_usb_get_descriptor(type, index);
7780
// Set Configuration
78-
} else if(req->bmRequestType == (USB_RECIP_DEVICE|USB_DIR_OUT) &&
79-
req->bRequest == USB_REQ_SET_CONFIGURATION) {
81+
} else if(bmRequestType == (USB_RECIP_DEVICE|USB_DIR_OUT) &&
82+
bRequest == USB_REQ_SET_CONFIGURATION) {
8083
if(handle_usb_set_configuration((uint8_t)req->wValue)) {
8184
ACK_EP0();
8285
} else {
8386
STALL_EP0();
8487
}
8588
// Get Configuration
86-
} else if(req->bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_STANDARD|USB_DIR_IN) &&
87-
req->bRequest == USB_REQ_GET_CONFIGURATION) {
89+
} else if(bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_STANDARD|USB_DIR_IN) &&
90+
bRequest == USB_REQ_GET_CONFIGURATION) {
8891
handle_usb_get_configuration();
8992
// Set Interface
90-
} else if(req->bmRequestType == (USB_RECIP_IFACE|USB_TYPE_STANDARD|USB_DIR_OUT) &&
91-
req->bRequest == USB_REQ_SET_INTERFACE) {
93+
} else if(bmRequestType == (USB_RECIP_IFACE|USB_TYPE_STANDARD|USB_DIR_OUT) &&
94+
bRequest == USB_REQ_SET_INTERFACE) {
9295
if(handle_usb_set_interface((uint8_t)req->wIndex, (uint8_t)req->wValue)) {
9396
ACK_EP0();
9497
} else {
9598
STALL_EP0();
9699
}
97100
// Get Interface
98-
} else if(req->bmRequestType == (USB_RECIP_IFACE|USB_TYPE_STANDARD|USB_DIR_IN) &&
99-
req->bRequest == USB_REQ_GET_INTERFACE) {
101+
} else if(bmRequestType == (USB_RECIP_IFACE|USB_TYPE_STANDARD|USB_DIR_IN) &&
102+
bRequest == USB_REQ_GET_INTERFACE) {
100103
handle_usb_get_interface((uint8_t)req->wIndex);
101104
// Set Feature - Device
102-
} else if(req->bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_STANDARD|USB_DIR_OUT) &&
103-
req->bRequest == USB_REQ_SET_FEATURE) {
105+
} else if(bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_STANDARD|USB_DIR_OUT) &&
106+
bRequest == USB_REQ_SET_FEATURE) {
104107
if(req->wValue == USB_FEAT_DEVICE_REMOTE_WAKEUP) {
105108
usb_remote_wakeup = true;
106109
ACK_EP0();
107110
} else if(req->wValue == USB_FEAT_TEST_MODE) {
108111
ACK_EP0();
109112
}
110113
// Get Status - Device
111-
} else if(req->bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_STANDARD|USB_DIR_IN) &&
112-
req->bRequest == USB_REQ_GET_STATUS) {
114+
} else if(bmRequestType == (USB_RECIP_DEVICE|USB_TYPE_STANDARD|USB_DIR_IN) &&
115+
bRequest == USB_REQ_GET_STATUS) {
113116
EP0BUF[0] = (usb_self_powered << 0) |
114117
(usb_remote_wakeup << 1);
115118
EP0BUF[1] = 0;
116119
SETUP_EP0_IN_BUF(2);
117120
// Get Status - Interface
118-
} else if(req->bmRequestType == (USB_RECIP_IFACE|USB_TYPE_STANDARD|USB_DIR_IN) &&
119-
req->bRequest == USB_REQ_GET_STATUS) {
121+
} else if(bmRequestType == (USB_RECIP_IFACE|USB_TYPE_STANDARD|USB_DIR_IN) &&
122+
bRequest == USB_REQ_GET_STATUS) {
120123
EP0BUF[0] = 0;
121124
EP0BUF[1] = 0;
122125
SETUP_EP0_IN_BUF(2);
123126
// Set Feature - Endpoint
124127
// Clear Feature - Endpoint
125-
} else if(req->bmRequestType == (USB_RECIP_ENDPT|USB_TYPE_STANDARD|USB_DIR_OUT) &&
126-
(req->bRequest == USB_REQ_SET_FEATURE ||
127-
req->bRequest == USB_REQ_CLEAR_FEATURE)) {
128+
} else if(bmRequestType == (USB_RECIP_ENDPT|USB_TYPE_STANDARD|USB_DIR_OUT) &&
129+
(bRequest == USB_REQ_SET_FEATURE ||
130+
bRequest == USB_REQ_CLEAR_FEATURE)) {
128131
if(req->wValue == USB_FEAT_ENDPOINT_HALT) {
129132
__xdata volatile uint8_t *EPnCS = EPnCS_for_n(req->wIndex);
130133
if(EPnCS != 0) {
131-
if(req->bRequest == USB_REQ_SET_FEATURE) {
134+
if(bRequest == USB_REQ_SET_FEATURE) {
132135
*EPnCS |= _STALL;
133136
ACK_EP0();
134137
} else {
@@ -141,8 +144,8 @@ __endasm;
141144
}
142145
}
143146
// Get Status - Endpoint
144-
} else if(req->bmRequestType == (USB_RECIP_ENDPT|USB_TYPE_STANDARD|USB_DIR_IN) &&
145-
req->bRequest == USB_REQ_GET_STATUS) {
147+
} else if(bmRequestType == (USB_RECIP_ENDPT|USB_TYPE_STANDARD|USB_DIR_IN) &&
148+
bRequest == USB_REQ_GET_STATUS) {
146149
__xdata volatile uint8_t *EPnCS = EPnCS_for_n(req->wIndex);
147150
if(EPnCS != 0) {
148151
EP0BUF[0] = ((*EPnCS & _STALL) != 0);

0 commit comments

Comments
 (0)