Skip to content

Commit

Permalink
解决EP4不自动反转带来的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-kirisame committed Mar 16, 2020
1 parent bafea8d commit 4460c1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
12 changes: 5 additions & 7 deletions usb/DAP_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ volatile static uint8_t ep4_len = 0;
void EP4_OUT()
{
if (ep4_len > 0) {
EP_OUT_RESP(4, UEP_T_RES_NAK);
UEP4_CTRL = UEP4_CTRL ^ bUEP_R_TOG & ~(MASK_UEP_R_RES) | UEP_R_RES_NAK;
return;
}

Expand All @@ -24,8 +24,8 @@ void EP4_OUT()
return;
}

EP_OUT_RESP(4, UEP_T_RES_ACK);
ep4_len = USB_RX_LEN;
UEP4_CTRL = UEP4_CTRL ^ bUEP_R_TOG & ~(MASK_UEP_R_RES) | UEP_R_RES_ACK;
}

void Dap_Init()
Expand All @@ -37,11 +37,9 @@ void Dap_Routine()
{
if (ep4_len > 0 && !usb_state.is_busy) {
uint8_t len = DAP_ExecuteCommand(EP4_OUT_BUF, EP4_IN_BUF) & 0xFF;
if (len <= MAX_PACKET_SIZE) {
usb_state.is_busy = true;
UEP4_T_LEN = MAX_PACKET_SIZE;
EP_IN_RESP(4, UEP_T_RES_ACK);
}
usb_state.is_busy = true;
UEP4_T_LEN = MAX_PACKET_SIZE;
UEP4_CTRL = UEP4_CTRL & ~(MASK_UEP_T_RES) | UEP_T_RES_ACK;

ep4_len = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions usb/dap_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
uint8_t DAP_GetFirmwareVersionString(char* str)
{
const char* data = "0254";
memcpy(str, data, sizeof(data));
return sizeof(data);
#define VER "0254"
memcpy(str, VER, sizeof(VER));
return sizeof(VER);
}
1 change: 1 addition & 0 deletions usb/endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ void EP3_IN()
void EP4_IN()
{
EP_IN_FINISH(4);
UEP4_CTRL ^= bUEP_T_TOG;
usb_state.is_busy = false;
}

Expand Down

0 comments on commit 4460c1d

Please sign in to comment.