added const (USB)

This commit is contained in:
Damjan Adamic
2014-09-02 10:07:22 +02:00
parent 9f8a908ff5
commit a3d9ec8a65
16 changed files with 51 additions and 48 deletions
@@ -89,7 +89,7 @@
* @{
*/
extern USBD_Class_cb_TypeDef USBD_HID_cb;
extern const USBD_Class_cb_TypeDef USBD_HID_cb;
/**
* @}
*/
@@ -101,7 +101,7 @@ uint8_t USBD_MSC_DataIn (void *pdev,
uint8_t USBD_MSC_DataOut (void *pdev,
uint8_t epnum);
uint8_t *USBD_MSC_GetCfgDesc (uint8_t speed,
const uint8_t *USBD_MSC_GetCfgDesc (uint8_t speed,
uint16_t *length);
#ifdef USB_OTG_HS_CORE
@@ -458,7 +458,7 @@ uint8_t USBD_MSC_DataOut (void *pdev,
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetCfgDesc (uint8_t speed, uint16_t *length)
const uint8_t *USBD_MSC_GetCfgDesc (uint8_t speed, uint16_t *length)
{
*length = sizeof (USBD_MSC_CfgDesc);
return USBD_MSC_CfgDesc;
@@ -90,9 +90,9 @@ typedef enum {
*/
void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
USB_OTG_CORE_ID_TypeDef coreID,
USBD_DEVICE *pDevice,
USBD_Class_cb_TypeDef *class_cb,
USBD_Usr_cb_TypeDef *usr_cb);
const USBD_DEVICE *pDevice,
const USBD_Class_cb_TypeDef *class_cb,
const USBD_Usr_cb_TypeDef *usr_cb);
USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev);
@@ -83,7 +83,7 @@
*/
USBD_Status USBD_CtlSendData (USB_OTG_CORE_HANDLE *pdev,
uint8_t *buf,
const uint8_t *buf,
uint16_t len);
USBD_Status USBD_CtlContinueSendData (USB_OTG_CORE_HANDLE *pdev,
@@ -51,9 +51,9 @@
* @{
*/
extern USBD_Usr_cb_TypeDef USR_cb;
extern USBD_Usr_cb_TypeDef USR_FS_cb;
extern USBD_Usr_cb_TypeDef USR_HS_cb;
extern const USBD_Usr_cb_TypeDef USR_cb;
extern const USBD_Usr_cb_TypeDef USR_FS_cb;
extern const USBD_Usr_cb_TypeDef USR_HS_cb;
@@ -96,7 +96,7 @@ static uint8_t USBD_RunTestMode (USB_OTG_CORE_HANDLE *pdev) ;
__IO USB_OTG_DCTL_TypeDef SET_TEST_MODE;
USBD_DCD_INT_cb_TypeDef USBD_DCD_INT_cb =
const USBD_DCD_INT_cb_TypeDef USBD_DCD_INT_cb =
{
USBD_DataOutStage,
USBD_DataInStage,
@@ -113,7 +113,7 @@ USBD_DevDisconnected,
#endif
};
USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops = &USBD_DCD_INT_cb;
const USBD_DCD_INT_cb_TypeDef * const USBD_DCD_INT_fops = &USBD_DCD_INT_cb;
/**
* @}
*/
@@ -133,9 +133,9 @@ USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops = &USBD_DCD_INT_cb;
*/
void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
USB_OTG_CORE_ID_TypeDef coreID,
USBD_DEVICE *pDevice,
USBD_Class_cb_TypeDef *class_cb,
USBD_Usr_cb_TypeDef *usr_cb)
const USBD_DEVICE *pDevice,
const USBD_Class_cb_TypeDef *class_cb,
const USBD_Usr_cb_TypeDef *usr_cb)
{
/* Hardware Init */
USB_OTG_BSP_Init(pdev);
@@ -93,7 +93,7 @@
* @retval status
*/
USBD_Status USBD_CtlSendData (USB_OTG_CORE_HANDLE *pdev,
uint8_t *pbuf,
const uint8_t *pbuf,
uint16_t len)
{
USBD_Status ret = USBD_OK;
@@ -83,7 +83,7 @@ __ALIGN_BEGIN uint32_t USBD_ep_status __ALIGN_END = 0;
#pragma data_alignment=4
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
__ALIGN_BEGIN uint32_t USBD_default_cfg __ALIGN_END = 0;
__ALIGN_BEGIN const uint32_t USBD_default_cfg __ALIGN_END = 0;
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
@@ -381,7 +381,7 @@ static void USBD_GetDescriptor(USB_OTG_CORE_HANDLE *pdev,
break;
case USB_DESC_TYPE_CONFIGURATION:
pbuf = (uint8_t *)pdev->dev.class_cb->GetConfigDescriptor(pdev->cfg.speed, &len);
pbuf = (uint8_t *)pdev->dev.class_cb->GetConfigDescriptor(pdev->cfg.speed, &len);
#ifdef USB_OTG_HS_CORE
if((pdev->cfg.speed == USB_OTG_SPEED_FULL )&&
(pdev->cfg.phy_itface == USB_OTG_ULPI_PHY))
@@ -397,7 +397,7 @@ static void USBD_GetDescriptor(USB_OTG_CORE_HANDLE *pdev,
switch ((uint8_t)(req->wValue))
{
case USBD_IDX_LANGID_STR:
pbuf = pdev->dev.usr_device->GetLangIDStrDescriptor(pdev->cfg.speed, &len);
pbuf = pdev->dev.usr_device->GetLangIDStrDescriptor(pdev->cfg.speed, &len);
break;
case USBD_IDX_MFC_STR:
@@ -625,7 +625,7 @@ static void USBD_GetConfig(USB_OTG_CORE_HANDLE *pdev,
case USB_OTG_ADDRESSED:
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_default_cfg,
(const uint8_t *)&USBD_default_cfg,
1);
break;
@@ -222,9 +222,9 @@ typedef struct _Device_cb
uint8_t (*IsoINIncomplete) (void *pdev);
uint8_t (*IsoOUTIncomplete) (void *pdev);
uint8_t *(*GetConfigDescriptor)( uint8_t speed , uint16_t *length);
const uint8_t *(*GetConfigDescriptor)( uint8_t speed , uint16_t *length);
#ifdef USB_OTG_HS_CORE
uint8_t *(*GetOtherConfigDescriptor)( uint8_t speed , uint16_t *length);
const uint8_t *(*GetOtherConfigDescriptor)( uint8_t speed , uint16_t *length);
#endif
#ifdef USB_SUPPORT_USER_STRING_DESC
@@ -262,9 +262,9 @@ typedef struct _DCD
USB_OTG_EP in_ep [USB_OTG_MAX_TX_FIFOS];
USB_OTG_EP out_ep [USB_OTG_MAX_TX_FIFOS];
uint8_t setup_packet [8*3];
USBD_Class_cb_TypeDef *class_cb;
USBD_Usr_cb_TypeDef *usr_cb;
USBD_DEVICE *usr_device;
const USBD_Class_cb_TypeDef *class_cb;
const USBD_Usr_cb_TypeDef *usr_cb;
const USBD_DEVICE *usr_device;
uint8_t *pConfig_descriptor;
}
DCD_DEV , *DCD_PDEV;
@@ -127,7 +127,7 @@ uint32_t DCD_EP_PrepareRx ( USB_OTG_CORE_HANDLE *pdev,
uint32_t DCD_EP_Tx (USB_OTG_CORE_HANDLE *pdev,
uint8_t ep_addr,
uint8_t *pbuf,
const uint8_t *pbuf,
uint32_t buf_len);
uint32_t DCD_EP_Stall (USB_OTG_CORE_HANDLE *pdev,
uint8_t epnum);
@@ -65,7 +65,7 @@ typedef struct _USBD_DCD_INT
}USBD_DCD_INT_cb_TypeDef;
extern USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops;
extern const USBD_DCD_INT_cb_TypeDef * const USBD_DCD_INT_fops;
/**
* @}
*/
@@ -260,7 +260,7 @@ uint32_t DCD_EP_PrepareRx( USB_OTG_CORE_HANDLE *pdev,
*/
uint32_t DCD_EP_Tx ( USB_OTG_CORE_HANDLE *pdev,
uint8_t ep_addr,
uint8_t *pbuf,
const uint8_t *pbuf,
uint32_t buf_len)
{
USB_OTG_EP *ep;
@@ -270,7 +270,7 @@ uint32_t DCD_EP_Tx ( USB_OTG_CORE_HANDLE *pdev,
/* Setup and start the Transfer */
ep->is_in = 1;
ep->num = ep_addr & 0x7F;
ep->xfer_buff = pbuf;
ep->xfer_buff = (uint8_t*)pbuf; //remove const qualifier, safe to do because we are sending
ep->dma_addr = (uint32_t)pbuf;
ep->xfer_count = 0;
ep->xfer_len = buf_len;
+9 -6
View File
@@ -26,6 +26,7 @@
*/
/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_req.h"
@@ -81,7 +82,7 @@
#endif
#endif
USBD_DEVICE USR_desc =
const USBD_DEVICE USR_desc =
{
USBD_USR_DeviceDescriptor,
USBD_USR_LangIDStrDescriptor,
@@ -93,7 +94,7 @@ USBD_DEVICE USR_desc =
};
/* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
__ALIGN_BEGIN const uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
@@ -116,7 +117,7 @@ __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
} ; /* USB_DeviceDescriptor */
/* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
__ALIGN_BEGIN const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
{
USB_LEN_DEV_QUALIFIER_DESC,
USB_DESC_TYPE_DEVICE_QUALIFIER,
@@ -131,7 +132,7 @@ __ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALI
};
/* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END =
__ALIGN_BEGIN const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END =
{
USB_SIZ_STRING_LANGID,
USB_DESC_TYPE_STRING,
@@ -149,7 +150,8 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END =
uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length)
{
*length = sizeof(USBD_DeviceDesc);
return USBD_DeviceDesc;
memcpy(USBD_StrDesc, USBD_DeviceDesc, *length);
return USBD_StrDesc;
}
/**
@@ -162,7 +164,8 @@ uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length)
uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length)
{
*length = sizeof(USBD_LangIDDesc);
return USBD_LangIDDesc;
memcpy(USBD_StrDesc, USBD_LangIDDesc, *length);
return USBD_StrDesc;
}
+6 -6
View File
@@ -77,12 +77,12 @@
/** @defgroup USBD_DESC_Exported_Variables
* @{
*/
extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC];
extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ];
extern uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC];
extern uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC];
extern uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID];
extern USBD_DEVICE USR_desc;
extern const uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC];
extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ];
extern const uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC];
extern const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC];
extern const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID];
extern const USBD_DEVICE USR_desc;
/**
* @}
*/
@@ -102,7 +102,7 @@ static uint8_t USBD_HID_DeInit (void *pdev,
static uint8_t USBD_HID_Setup (void *pdev,
USB_SETUP_REQ *req);
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length);
static const uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length);
static uint8_t USBD_HID_DataIn (void *pdev, uint8_t epnum);
/**
@@ -135,7 +135,7 @@ static uint8_t USBD_HID_DataIn (void *pdev, uint8_t epnum);
uint8_t S2; //analog value, mapped to channel 8
}
*/
__ALIGN_BEGIN static uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
__ALIGN_BEGIN static const uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Game Pad)
@@ -172,7 +172,7 @@ __ALIGN_BEGIN static uint8_t HID_JOYSTICK_ReportDesc[] __ALIGN_END =
* @{
*/
USBD_Class_cb_TypeDef USBD_HID_cb =
const USBD_Class_cb_TypeDef USBD_HID_cb =
{
USBD_HID_Init,
USBD_HID_DeInit,
@@ -217,7 +217,7 @@ __ALIGN_BEGIN static uint32_t USBD_HID_IdleState __ALIGN_END = 0;
#endif
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
/* USB HID device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
__ALIGN_BEGIN static const uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
@@ -334,7 +334,7 @@ static uint8_t USBD_HID_Setup (void *pdev,
USB_SETUP_REQ *req)
{
uint16_t len = 0;
uint8_t *pbuf = NULL;
const uint8_t *pbuf = NULL;
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
@@ -439,7 +439,7 @@ uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev,
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
static uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length)
static const uint8_t *USBD_HID_GetCfgDesc (uint8_t speed, uint16_t *length)
{
*length = sizeof (USBD_HID_CfgDesc);
return USBD_HID_CfgDesc;
+1 -1
View File
@@ -35,7 +35,7 @@ extern "C" {
/* The purpose of this register is to speed up the execution */
USBD_Usr_cb_TypeDef USR_cb =
const USBD_Usr_cb_TypeDef USR_cb =
{
USBD_USR_Init,
USBD_USR_DeviceReset,