From 4a175e1f110e0d6ad1b784054050be59a6e2c706 Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 17 Oct 2013 22:50:21 +0100 Subject: Fix up linker script; improve startup code; printf to USB. --- stm/lib/usbd_cdc_core.h | 2 +- stm/lib/usbd_cdc_vcp.c | 6 +++--- stm/lib/usbd_conf.h | 3 --- stm/lib/usbd_pyb_core.c | 14 +++++++------- 4 files changed, 11 insertions(+), 14 deletions(-) (limited to 'stm/lib') diff --git a/stm/lib/usbd_cdc_core.h b/stm/lib/usbd_cdc_core.h index 3187deb3d..026462143 100644 --- a/stm/lib/usbd_cdc_core.h +++ b/stm/lib/usbd_cdc_core.h @@ -97,7 +97,7 @@ typedef struct _CDC_IF_PROP uint16_t (*pIf_Init) (void); uint16_t (*pIf_DeInit) (void); uint16_t (*pIf_Ctrl) (uint32_t Cmd, uint8_t* Buf, uint32_t Len); - uint16_t (*pIf_DataTx) (uint8_t* Buf, uint32_t Len); + uint16_t (*pIf_DataTx) (const uint8_t* Buf, uint32_t Len); uint16_t (*pIf_DataRx) (uint8_t* Buf, uint32_t Len); } CDC_IF_Prop_TypeDef; diff --git a/stm/lib/usbd_cdc_vcp.c b/stm/lib/usbd_cdc_vcp.c index 9cf8fb258..b7330d9f6 100644 --- a/stm/lib/usbd_cdc_vcp.c +++ b/stm/lib/usbd_cdc_vcp.c @@ -60,7 +60,7 @@ extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to static uint16_t VCP_Init (void); static uint16_t VCP_DeInit (void); static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len); -static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len); +static uint16_t VCP_DataTx (const uint8_t* Buf, uint32_t Len); static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len); CDC_IF_Prop_TypeDef VCP_fops = @@ -181,7 +181,7 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) * @param Len: Number of data to be sent (in bytes) * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL */ -static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len) +static uint16_t VCP_DataTx (const uint8_t* Buf, uint32_t Len) { for (int i = 0; i < Len; i++) { APP_Rx_Buffer[APP_Rx_ptr_in] = Buf[i]; @@ -212,7 +212,7 @@ static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len) * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL */ static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len) { - printf("%.*s", (int)Len, Buf); + //printf("%.*s", (int)Len, Buf); return USBD_OK; } diff --git a/stm/lib/usbd_conf.h b/stm/lib/usbd_conf.h index 4bab9e3c2..60243d2f6 100644 --- a/stm/lib/usbd_conf.h +++ b/stm/lib/usbd_conf.h @@ -20,7 +20,4 @@ #define MSC_MAX_PACKET 64 #define MSC_MEDIA_PACKET 4096 -// for both? -#define APP_FOPS VCP_fops - #endif //__USBD_CONF__H__ diff --git a/stm/lib/usbd_pyb_core.c b/stm/lib/usbd_pyb_core.c index 9c0f1caa0..ea8f05a81 100644 --- a/stm/lib/usbd_pyb_core.c +++ b/stm/lib/usbd_pyb_core.c @@ -96,7 +96,7 @@ static uint8_t *usbd_pyb_GetCfgDesc (uint8_t speed, uint16_t *length); /** @defgroup usbd_cdc_Private_Variables * @{ */ -extern CDC_IF_Prop_TypeDef APP_FOPS; +extern CDC_IF_Prop_TypeDef VCP_fops; extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; __ALIGN_BEGIN static uint8_t usbd_cdc_AltSet __ALIGN_END = 0; @@ -322,7 +322,7 @@ static uint8_t usbd_pyb_Init(void *pdev, uint8_t cfgidx) { */ // Initialize the Interface physical components - APP_FOPS.pIf_Init(); + VCP_fops.pIf_Init(); // Prepare Out endpoint to receive next packet */ DCD_EP_PrepareRx(pdev, @@ -367,7 +367,7 @@ static uint8_t usbd_pyb_DeInit(void *pdev, uint8_t cfgidx) { DCD_EP_Close(pdev, CDC_CMD_EP); // Restore default state of the Interface physical components - APP_FOPS.pIf_DeInit(); + VCP_fops.pIf_DeInit(); //---------------------------------- // MSC component @@ -475,7 +475,7 @@ static uint8_t usbd_pyb_Setup(void *pdev, USB_SETUP_REQ *req) { // Device-to-Host request // Get the data to be sent to Host from interface layer - APP_FOPS.pIf_Ctrl(req->bRequest, CmdBuff, req->wLength); + VCP_fops.pIf_Ctrl(req->bRequest, CmdBuff, req->wLength); // Send the data to the host return USBD_CtlSendData(pdev, CmdBuff, req->wLength); @@ -495,7 +495,7 @@ static uint8_t usbd_pyb_Setup(void *pdev, USB_SETUP_REQ *req) { // Not a Data request // Transfer the command to the interface layer */ - return APP_FOPS.pIf_Ctrl(req->bRequest, NULL, 0); + return VCP_fops.pIf_Ctrl(req->bRequest, NULL, 0); } } else if (req->wIndex == 2) { @@ -537,7 +537,7 @@ static uint8_t usbd_pyb_Setup(void *pdev, USB_SETUP_REQ *req) { static uint8_t usbd_pyb_EP0_RxReady(void *pdev) { if (cdcCmd != NO_CMD) { // Process the data - APP_FOPS.pIf_Ctrl(cdcCmd, CmdBuff, cdcLen); + VCP_fops.pIf_Ctrl(cdcCmd, CmdBuff, cdcLen); // Reset the command variable to default value cdcCmd = NO_CMD; @@ -612,7 +612,7 @@ static uint8_t usbd_pyb_DataOut(void *pdev, uint8_t epnum) { /* USB data will be immediately processed, this allow next USB traffic being NAKed till the end of the application Xfer */ - APP_FOPS.pIf_DataRx(USB_Rx_Buffer, USB_Rx_Cnt); + VCP_fops.pIf_DataRx(USB_Rx_Buffer, USB_Rx_Cnt); // Prepare Out endpoint to receive next packet */ DCD_EP_PrepareRx(pdev, -- cgit v1.2.3