From a51417bf61da53c19c61333ded2f565b40a0118c Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Fri, 31 May 2019 15:58:13 -0400 Subject: [PATCH] fix epout connection --- targets/stm32l432/lib/usbd/usbd_ccid.c | 33 +++++++++++++++++--------- targets/stm32l432/lib/usbd/usbd_ccid.h | 2 ++ targets/stm32l432/lib/usbd/usbd_conf.c | 5 +++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/targets/stm32l432/lib/usbd/usbd_ccid.c b/targets/stm32l432/lib/usbd/usbd_ccid.c index e202ffe..c452aa3 100644 --- a/targets/stm32l432/lib/usbd/usbd_ccid.c +++ b/targets/stm32l432/lib/usbd/usbd_ccid.c @@ -32,7 +32,7 @@ USBD_ClassTypeDef USBD_CCID = NULL, /* EP0_TxSent, */ USBD_CCID_EP0_RxReady, USBD_CCID_DataIn, - USBD_CCID_DataOut, + usb_ccid_recieve_callback, NULL, NULL, NULL, @@ -259,7 +259,7 @@ void ccid_send_status(CCID_HEADER * c) memset(msg,0,sizeof(msg)); msg[0] = CCID_SLOT_STATUS_RES; - msg[6] = c->seq; + msg[6] = 1; USBD_CCID_TransmitPacket(msg, sizeof(msg)); @@ -277,6 +277,12 @@ void handle_ccid(uint8_t * msg, int len) ccid_send_status(h); break; default: + // while(1) + // { + // led_rgb(0xff3520); + // } + //Y + ccid_send_status(h); break; } } @@ -288,12 +294,9 @@ void handle_ccid(uint8_t * msg, int len) * @param epnum: endpoint number * @retval status */ -static uint8_t USBD_CCID_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) +uint8_t usb_ccid_recieve_callback(USBD_HandleTypeDef *pdev, uint8_t epnum) { - while(1) - { - led_rgb(0xff3520); - } + USBD_CCID_HandleTypeDef *hcdc = (USBD_CCID_HandleTypeDef*) pdev->pClassData; /* Get the received data length */ @@ -312,10 +315,18 @@ static uint8_t USBD_CCID_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) } else { + + + while(1) + { + led_rgb(0xff3520); + } + return USBD_FAIL; } } + /** * @brief USBD_CDC_EP0_RxReady * Handle EP0 Rx Ready event @@ -326,9 +337,9 @@ static uint8_t USBD_CCID_EP0_RxReady (USBD_HandleTypeDef *pdev) { USBD_CCID_HandleTypeDef *hcdc = (USBD_CCID_HandleTypeDef*) pdev->pClassData; - if((pdev->pUserData != NULL) && (hcdc->CmdOpCode != 0xFFU)) - { - hcdc->CmdOpCode = 0xFFU; - } + // if((pdev->pUserData != NULL) && (hcdc->CmdOpCode != 0xFFU)) + // { + // hcdc->CmdOpCode = 0xFFU; + // } return USBD_OK; } diff --git a/targets/stm32l432/lib/usbd/usbd_ccid.h b/targets/stm32l432/lib/usbd/usbd_ccid.h index cecf170..6535987 100644 --- a/targets/stm32l432/lib/usbd/usbd_ccid.h +++ b/targets/stm32l432/lib/usbd/usbd_ccid.h @@ -38,4 +38,6 @@ typedef struct } USBD_CCID_HandleTypeDef; +uint8_t usb_ccid_recieve_callback(USBD_HandleTypeDef *pdev, uint8_t epnum); + #endif diff --git a/targets/stm32l432/lib/usbd/usbd_conf.c b/targets/stm32l432/lib/usbd/usbd_conf.c index 793a0a2..61bcecd 100644 --- a/targets/stm32l432/lib/usbd/usbd_conf.c +++ b/targets/stm32l432/lib/usbd/usbd_conf.c @@ -119,9 +119,12 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); switch(epnum) { - case HID_ENDPOINT: + case HID_EPOUT_ADDR: usb_hid_recieve_callback(epnum); break; + case CCID_OUT_EP: + usb_ccid_recieve_callback((USBD_HandleTypeDef*)hpcd->pData, epnum); + break; } }