From a3d9ec8a6572736296de85f136c8aea292dcd16f Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 2 Sep 2014 10:07:22 +0200 Subject: [PATCH 1/4] added const (USB) --- .../Class/hid/inc/usbd_hid_core.h | 2 +- .../Class/msc/src/usbd_msc_core.c | 4 ++-- .../STM32_USB_Device_Library/Core/inc/usbd_core.h | 6 +++--- .../Core/inc/usbd_ioreq.h | 2 +- .../STM32_USB_Device_Library/Core/inc/usbd_usr.h | 6 +++--- .../STM32_USB_Device_Library/Core/src/usbd_core.c | 10 +++++----- .../Core/src/usbd_ioreq.c | 2 +- .../STM32_USB_Device_Library/Core/src/usbd_req.c | 8 ++++---- .../Libraries/STM32_USB_OTG_Driver/inc/usb_core.h | 10 +++++----- .../Libraries/STM32_USB_OTG_Driver/inc/usb_dcd.h | 2 +- .../STM32_USB_OTG_Driver/inc/usb_dcd_int.h | 2 +- .../Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c | 4 ++-- radio/src/targets/taranis/usbd_desc.c | 15 +++++++++------ radio/src/targets/taranis/usbd_desc.h | 12 ++++++------ radio/src/targets/taranis/usbd_hid_joystick.c | 12 ++++++------ radio/src/targets/taranis/usbd_usr.cpp | 2 +- 16 files changed, 51 insertions(+), 48 deletions(-) diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc/usbd_hid_core.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc/usbd_hid_core.h index 96e654725..00971a591 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc/usbd_hid_core.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc/usbd_hid_core.h @@ -89,7 +89,7 @@ * @{ */ -extern USBD_Class_cb_TypeDef USBD_HID_cb; +extern const USBD_Class_cb_TypeDef USBD_HID_cb; /** * @} */ diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c index eef2b9c63..5af6c40d4 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c @@ -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; diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h index 184e8d4a7..40aa25cc4 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h @@ -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); diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h index 3f6aea1a9..8ffeb328a 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h @@ -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, diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h index bd5ff3e2e..9ee54928b 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_usr.h @@ -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; diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c index 80fc241f9..7e9fc3b99 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c @@ -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); diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c index a9e4a8636..ae06adb33 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c @@ -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; diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c index d94189f68..67de98d8d 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c @@ -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; diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_core.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_core.h index d44003b4f..f68d949ff 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_core.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_core.h @@ -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; diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd.h index a1eb7a5e3..5027c878c 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd.h @@ -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); diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h index e2369e5dd..351eeb232 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h @@ -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; /** * @} */ diff --git a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c index eac8c3371..85df8652e 100644 --- a/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c +++ b/radio/src/targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c @@ -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; diff --git a/radio/src/targets/taranis/usbd_desc.c b/radio/src/targets/taranis/usbd_desc.c index 9e476b161..d9e8b353e 100644 --- a/radio/src/targets/taranis/usbd_desc.c +++ b/radio/src/targets/taranis/usbd_desc.c @@ -26,6 +26,7 @@ */ /* Includes ------------------------------------------------------------------*/ +#include #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; } diff --git a/radio/src/targets/taranis/usbd_desc.h b/radio/src/targets/taranis/usbd_desc.h index a6dc86291..7a9d5b564 100644 --- a/radio/src/targets/taranis/usbd_desc.h +++ b/radio/src/targets/taranis/usbd_desc.h @@ -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; /** * @} */ diff --git a/radio/src/targets/taranis/usbd_hid_joystick.c b/radio/src/targets/taranis/usbd_hid_joystick.c index 29870a824..33a6c3d85 100644 --- a/radio/src/targets/taranis/usbd_hid_joystick.c +++ b/radio/src/targets/taranis/usbd_hid_joystick.c @@ -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; diff --git a/radio/src/targets/taranis/usbd_usr.cpp b/radio/src/targets/taranis/usbd_usr.cpp index 28717401e..a1d241f4c 100644 --- a/radio/src/targets/taranis/usbd_usr.cpp +++ b/radio/src/targets/taranis/usbd_usr.cpp @@ -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, From aa4ba74e1a909a35d8ef56ea02143721cbac6151 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 2 Sep 2014 10:12:40 +0200 Subject: [PATCH 2/4] added const (Audio) --- radio/src/audio_arm.cpp | 4 ++-- radio/src/targets/taranis/audio_driver.cpp | 6 +++--- radio/src/targets/taranis/audio_driver.h | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index a13255312..b2dae928c 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -147,7 +147,7 @@ const int16_t sineValues[] = }; #if defined(SDCARD) -const char * audioFilenames[] = { +const char * const audioFilenames[] = { "tada", "thralert", "swalert", @@ -278,7 +278,7 @@ void referenceSystemAudioFiles() sdAvailableSystemAudioFiles = availableAudioFiles; } -const char * suffixes[] = { "-off", "-on" }; +const char * const suffixes[] = { "-off", "-on" }; char * getModelAudioPath(char * path) { diff --git a/radio/src/targets/taranis/audio_driver.cpp b/radio/src/targets/taranis/audio_driver.cpp index 9c350b16a..3f4020e64 100644 --- a/radio/src/targets/taranis/audio_driver.cpp +++ b/radio/src/targets/taranis/audio_driver.cpp @@ -36,7 +36,7 @@ #include "../../opentx.h" -int dacIdle = 1; +bool dacIdle = true; void setSampleRate(uint32_t frequency) { @@ -96,7 +96,7 @@ void dacInit() bool dacQueue(AudioBuffer *buffer) { if (dacIdle) { - dacIdle = 0; + dacIdle = false; DMA1_Stream5->CR &= ~DMA_SxCR_EN ; // Disable DMA channel DMA1->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits DMA1_Stream5->M0AR = CONVERT_PTR_UINT(buffer->data); @@ -163,7 +163,7 @@ extern "C" void DMA1_Stream5_IRQHandler() DAC->SR = DAC_SR_DMAUDR1; // Write 1 to clear flag } else { - dacIdle = 1; + dacIdle = true; } } #endif diff --git a/radio/src/targets/taranis/audio_driver.h b/radio/src/targets/taranis/audio_driver.h index e357e8627..ea277a8ed 100644 --- a/radio/src/targets/taranis/audio_driver.h +++ b/radio/src/targets/taranis/audio_driver.h @@ -44,8 +44,6 @@ void dacStop(); extern void setSampleRate(uint32_t frequency); -extern int dacIdle; - #define VOLUME_LEVEL_MAX 23 #define VOLUME_LEVEL_DEF 12 static const int8_t volumeScale[VOLUME_LEVEL_MAX+1] = From 13a1c5ca3964a6fe170223f6ec414edbe55c23b6 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 2 Sep 2014 10:14:26 +0200 Subject: [PATCH 3/4] const APBAHBPrescTable const splash_lbm removed fnSwitchDuration --- radio/src/opentx.cpp | 6 +----- .../STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 9f1d6600e..e53281de1 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -82,7 +82,7 @@ const pm_uchar splashdata[] PROGMEM = { 'S','P','S',0, #include "bitmaps/splash_9x.lbm" #endif 'S','P','E',0}; -const pm_uchar * splash_lbm = splashdata+4; +const pm_uchar * const splash_lbm = splashdata+4; #endif #if LCD_W >= 212 @@ -1884,7 +1884,6 @@ uint8_t mSwitchDuration[1+NUM_ROTARY_ENCODERS] = { 0 }; uint8_t currentSpeakerVolume = 255; uint8_t requiredSpeakerVolume; getvalue_t requiredSpeakerVolumeRawLast = 1024 + 1; //initial value must be outside normal range -uint8_t fnSwitchDuration[NUM_CFN] = { 0 }; inline void playCustomFunctionFile(CustomFnData *sd, uint8_t id) { @@ -2181,9 +2180,6 @@ void evalFunctions() } else { lastFunctionTime[i] = 0; -#if defined(CPUARM) - fnSwitchDuration[i] = 0; -#endif } } } diff --git a/radio/src/targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c b/radio/src/targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c index a668c5a37..c5b26daf8 100644 --- a/radio/src/targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c +++ b/radio/src/targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c @@ -130,7 +130,7 @@ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ -static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; +static const uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ From e506a001bfe7ec2ca68becab18c56629aa1fe089 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 2 Sep 2014 10:18:17 +0200 Subject: [PATCH 4/4] const language packs (can't be const in simu (linker can't find it)) --- radio/src/gui/menu_general.cpp | 24 +++++----- radio/src/gui/menus.h | 2 +- radio/src/translations.cpp | 60 ++++++++++++------------ radio/src/translations.h | 85 ++++++++++++++++++---------------- 4 files changed, 89 insertions(+), 82 deletions(-) diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index a22495a7e..6e25fabe5 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -41,19 +41,19 @@ const pm_uchar sticks[] PROGMEM = { }; #if defined(CPUARM) -extern LanguagePack czLanguagePack; -extern LanguagePack enLanguagePack; -extern LanguagePack esLanguagePack; -extern LanguagePack frLanguagePack; -extern LanguagePack deLanguagePack; -extern LanguagePack itLanguagePack; -extern LanguagePack plLanguagePack; -extern LanguagePack ptLanguagePack; -extern LanguagePack skLanguagePack; -extern LanguagePack seLanguagePack; -extern LanguagePack huLanguagePack; +extern LP_CONST LanguagePack czLanguagePack; +extern LP_CONST LanguagePack enLanguagePack; +extern LP_CONST LanguagePack esLanguagePack; +extern LP_CONST LanguagePack frLanguagePack; +extern LP_CONST LanguagePack deLanguagePack; +extern LP_CONST LanguagePack itLanguagePack; +extern LP_CONST LanguagePack plLanguagePack; +extern LP_CONST LanguagePack ptLanguagePack; +extern LP_CONST LanguagePack skLanguagePack; +extern LP_CONST LanguagePack seLanguagePack; +extern LP_CONST LanguagePack huLanguagePack; -LanguagePack * languagePacks[] = { +const LanguagePack * LP_CONST languagePacks[] = { // alphabetical order &czLanguagePack, &deLanguagePack, diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index dad886430..eb0f4c1d5 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -40,7 +40,7 @@ #define NO_HI_LEN 25 void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr); -inline void displayColumnHeader(const char **headers, uint8_t index) +inline void displayColumnHeader(const char * const *headers, uint8_t index) { lcd_putsAtt(17*FW, 0, headers[index], 0); } diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index e4326afc0..298cdb09e 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -224,7 +224,7 @@ const pm_char STR_ALARMWARNING[] PROGMEM = TR_ALARMWARNING; const pm_char STR_RENAVIG[] PROGMEM = TR_RENAVIG; #endif const pm_char STR_THROTTLEREVERSE[] PROGMEM = TR_THROTTLEREVERSE; -const pm_char STR_TIMER_NAME[] PROGMEM = TR_TIMER_NAME; +const pm_char STR_TIMER_NAME[] PROGMEM = TR_TIMER_NAME; const pm_char STR_MINUTEBEEP[] PROGMEM = TR_MINUTEBEEP; const pm_char STR_BEEPCOUNTDOWN[] PROGMEM = TR_BEEPCOUNTDOWN; const pm_char STR_PERSISTENT[] PROGMEM = TR_PERSISTENT; @@ -243,12 +243,12 @@ const pm_char STR_SWITCHWARNING[] PROGMEM = TR_SWITCHWARNING; const pm_char STR_TIMEZONE[] PROGMEM = TR_TIMEZONE; const pm_char STR_GPSCOORD[] PROGMEM = TR_GPSCOORD; const pm_char STR_VARIO[] PROGMEM = TR_VARIO; -const pm_char STR_PITCH_AT_ZERO[] PROGMEM = TR_PITCH_AT_ZERO; -const pm_char STR_PITCH_AT_MAX[] PROGMEM = TR_PITCH_AT_MAX; -const pm_char STR_REPEAT_AT_ZERO[] PROGMEM = TR_REPEAT_AT_ZERO; +const pm_char STR_PITCH_AT_ZERO[] PROGMEM = TR_PITCH_AT_ZERO; +const pm_char STR_PITCH_AT_MAX[] PROGMEM = TR_PITCH_AT_MAX; +const pm_char STR_REPEAT_AT_ZERO[] PROGMEM = TR_REPEAT_AT_ZERO; #endif const pm_char STR_RXCHANNELORD[] PROGMEM = TR_RXCHANNELORD; -const pm_char STR_SWITCHES_DELAY[] PROGMEM = TR_SWITCHES_DELAY; +const pm_char STR_SWITCHES_DELAY[] PROGMEM = TR_SWITCHES_DELAY; const pm_char STR_SLAVE[] PROGMEM = TR_SLAVE; const pm_char STR_MODESRC[] PROGMEM = TR_MODESRC; const pm_char STR_MULTIPLIER[] PROGMEM = TR_MULTIPLIER; @@ -420,7 +420,7 @@ const pm_char STR_MODELS_EXT[] PROGMEM = MODELS_EXT; const pm_char STR_WARNING[] PROGMEM = TR_WARNING; const pm_char STR_EEPROMWARN[] PROGMEM = TR_EEPROMWARN; -const pm_char STR_EEPROM_CONVERTING[] PROGMEM = TR_EEPROM_CONVERTING; +const pm_char STR_EEPROM_CONVERTING[] PROGMEM = TR_EEPROM_CONVERTING; const pm_char STR_THROTTLEWARN[] PROGMEM = TR_THROTTLEWARN; const pm_char STR_ALARMSWARN[] PROGMEM = TR_ALARMSWARN; const pm_char STR_SWITCHWARN[] PROGMEM = TR_SWITCHWARN; @@ -445,10 +445,10 @@ const pm_char STR_SDHC_CARD[] PROGMEM = TR_SDHC_CARD; const pm_char STR_NO_SOUNDS_ON_SD[] PROGMEM = TR_NO_SOUNDS_ON_SD; const pm_char STR_NO_MODELS_ON_SD[] PROGMEM = TR_NO_MODELS_ON_SD; const pm_char STR_NO_BITMAPS_ON_SD[] PROGMEM = TR_NO_BITMAPS_ON_SD; -const pm_char STR_NO_SCRIPTS_ON_SD[] PROGMEM = TR_NO_SCRIPTS_ON_SD; +const pm_char STR_NO_SCRIPTS_ON_SD[] PROGMEM = TR_NO_SCRIPTS_ON_SD; const pm_char STR_PLAY_FILE[] PROGMEM = TR_PLAY_FILE; const pm_char STR_ASSIGN_BITMAP[] PROGMEM = TR_ASSIGN_BITMAP; -const pm_char STR_EXECUTE_FILE[] PROGMEM = TR_EXECUTE_FILE; +const pm_char STR_EXECUTE_FILE[] PROGMEM = TR_EXECUTE_FILE; const pm_char STR_DELETE_FILE[] PROGMEM = TR_DELETE_FILE; const pm_char STR_COPY_FILE[] PROGMEM = TR_COPY_FILE; const pm_char STR_RENAME_FILE[] PROGMEM = TR_RENAME_FILE; @@ -474,13 +474,13 @@ const pm_char STR_OWN[] PROGMEM = TR_OWN; const pm_char STR_ROTARY_ENCODER[] PROGMEM = TR_ROTARY_ENCODER; const pm_char STR_DATE[] PROGMEM = TR_DATE; const pm_char STR_CHANNELS_MONITOR[] PROGMEM = TR_CHANNELS_MONITOR; -const pm_char STR_PATH_TOO_LONG[] PROGMEM = TR_PATH_TOO_LONG; -const pm_char STR_VIEW_TEXT[] PROGMEM = TR_VIEW_TEXT; -const pm_char STR_FLASH_BOOTLOADER[] PROGMEM = TR_FLASH_BOOTLOADER; -const pm_char STR_WRITING[] PROGMEM = TR_WRITING; +const pm_char STR_PATH_TOO_LONG[] PROGMEM = TR_PATH_TOO_LONG; +const pm_char STR_VIEW_TEXT[] PROGMEM = TR_VIEW_TEXT; +const pm_char STR_FLASH_BOOTLOADER[] PROGMEM = TR_FLASH_BOOTLOADER; +const pm_char STR_WRITING[] PROGMEM = TR_WRITING; const pm_char STR_CONFIRM_FORMAT[] PROGMEM = TR_CONFIRM_FORMAT; const pm_char STR_EEBACKUP[] PROGMEM = TR_EEBACKUP; -const pm_char STR_TOO_MANY_LUA_SCRIPTS[] PROGMEM = TR_TO_MANY_LUA_SCRIPTS; +const pm_char STR_TOO_MANY_LUA_SCRIPTS[] PROGMEM = TR_TO_MANY_LUA_SCRIPTS; const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; #if LCD_W >= 212 @@ -492,9 +492,9 @@ const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; #endif #if LCD_W >= 212 - const char * STR_PHASES_HEADERS[] = TR_PHASES_HEADERS; - const char * STR_LIMITS_HEADERS[] = TR_LIMITS_HEADERS; - const char * STR_CSW_HEADERS[] = TR_CSW_HEADERS; + const char * const STR_PHASES_HEADERS[] = TR_PHASES_HEADERS; + const char * const STR_LIMITS_HEADERS[] = TR_LIMITS_HEADERS; + const char * const STR_CSW_HEADERS[] = TR_CSW_HEADERS; #endif #if defined(CPUARM) @@ -515,23 +515,23 @@ const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; const pm_char STR_BYTES[] PROGMEM = TR_BYTES; const pm_char STR_ANTENNAPROBLEM[] PROGMEM = TR_ANTENNAPROBLEM; const pm_char STR_MODULE[] PROGMEM = TR_MODULE; - const pm_char STR_ENABLE_POPUP[] PROGMEM = TR_ENABLE_POPUP; - const pm_char STR_DISABLE_POPUP[] PROGMEM = TR_DISABLE_POPUP; - const pm_char STR_CURVE_PRESET[] PROGMEM = TR_CURVE_PRESET; - const pm_char STR_PRESET[] PROGMEM = TR_PRESET; - const pm_char STR_MIRROR[] PROGMEM = TR_MIRROR; - const pm_char STR_CLEAR[] PROGMEM = TR_CLEAR; + const pm_char STR_ENABLE_POPUP[] PROGMEM = TR_ENABLE_POPUP; + const pm_char STR_DISABLE_POPUP[] PROGMEM = TR_DISABLE_POPUP; + const pm_char STR_CURVE_PRESET[] PROGMEM = TR_CURVE_PRESET; + const pm_char STR_PRESET[] PROGMEM = TR_PRESET; + const pm_char STR_MIRROR[] PROGMEM = TR_MIRROR; + const pm_char STR_CLEAR[] PROGMEM = TR_CLEAR; const pm_char STR_RESET[] PROGMEM = TR_RESET; - const pm_char STR_COUNT[] PROGMEM = TR_COUNT; - const pm_char STR_PT[] PROGMEM = TR_PT; - const pm_char STR_PTS[] PROGMEM = TR_PTS; - const pm_char STR_SMOOTH[] PROGMEM = TR_SMOOTH; - const pm_char STR_COPY_STICKS_TO_OFS[] PROGMEM = TR_COPY_STICKS_TO_OFS; -const pm_char STR_COPY_TRIMS_TO_OFS[] PROGMEM = TR_COPY_TRIMS_TO_OFS; + const pm_char STR_COUNT[] PROGMEM = TR_COUNT; + const pm_char STR_PT[] PROGMEM = TR_PT; + const pm_char STR_PTS[] PROGMEM = TR_PTS; + const pm_char STR_SMOOTH[] PROGMEM = TR_SMOOTH; + const pm_char STR_COPY_STICKS_TO_OFS[] PROGMEM = TR_COPY_STICKS_TO_OFS; +const pm_char STR_COPY_TRIMS_TO_OFS[] PROGMEM = TR_COPY_TRIMS_TO_OFS; const pm_char STR_TOP_BAR[] PROGMEM = TR_TOP_BAR; const pm_char STR_ALTITUDE[] PROGMEM = TR_ALTITUDE; - const pm_char STR_SCALE[] PROGMEM = TR_SCALE; - const pm_char STR_VIEW_CHANNELS[] PROGMEM = TR_VIEW_CHANNELS; + const pm_char STR_SCALE[] PROGMEM = TR_SCALE; + const pm_char STR_VIEW_CHANNELS[] PROGMEM = TR_VIEW_CHANNELS; const pm_char STR_POTWARNING[] PROGMEM = TR_POTWARNING; const pm_char STR_UART3MODE[] PROGMEM = TR_UART3MODE; const pm_char STR_THROTTLE_LABEL[] PROGMEM = TR_THROTTLE_LABEL; diff --git a/radio/src/translations.h b/radio/src/translations.h index 18c441b92..c6312007a 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -372,7 +372,7 @@ extern const pm_char STR_BLADES[]; extern const pm_char STR_SCREEN[]; extern const pm_char STR_SOUND_LABEL[]; extern const pm_char STR_LENGTH[]; -extern const pm_char STR_BEEP_LENGTH[]; +extern const pm_char STR_BEEP_LENGTH[]; #if defined(CPUARM) extern const pm_char STR_BEEP_LENGTH[]; #else @@ -392,7 +392,7 @@ extern const pm_char STR_MEMORYWARNING[]; extern const pm_char STR_ALARMWARNING[]; extern const pm_char STR_RENAVIG[]; extern const pm_char STR_THROTTLEREVERSE[]; -extern const pm_char STR_TIMER_NAME[]; +extern const pm_char STR_TIMER_NAME[]; extern const pm_char STR_MINUTEBEEP[]; extern const pm_char STR_BEEPCOUNTDOWN[]; extern const pm_char STR_PERSISTENT[]; @@ -408,11 +408,11 @@ extern const pm_char STR_SWITCHWARNING[]; extern const pm_char STR_TIMEZONE[]; extern const pm_char STR_GPSCOORD[]; extern const pm_char STR_VARIO[]; -extern const pm_char STR_PITCH_AT_ZERO[]; -extern const pm_char STR_PITCH_AT_MAX[]; -extern const pm_char STR_REPEAT_AT_ZERO[]; +extern const pm_char STR_PITCH_AT_ZERO[]; +extern const pm_char STR_PITCH_AT_MAX[]; +extern const pm_char STR_REPEAT_AT_ZERO[]; extern const pm_char STR_RXCHANNELORD[]; -extern const pm_char STR_SWITCHES_DELAY[]; +extern const pm_char STR_SWITCHES_DELAY[]; extern const pm_char STR_SLAVE[]; extern const pm_char STR_MODESRC[]; extern const pm_char STR_MULTIPLIER[]; @@ -472,8 +472,8 @@ extern const pm_char STR_MENUCURVE[]; extern const pm_char STR_MENULOGICALSWITCH[]; extern const pm_char STR_MENULOGICALSWITCHES[]; extern const pm_char STR_MENUCUSTOMFUNC[]; -extern const pm_char STR_MENUCUSTOMSCRIPTS[]; -extern const pm_char STR_MENUCUSTOMSCRIPT[]; +extern const pm_char STR_MENUCUSTOMSCRIPTS[]; +extern const pm_char STR_MENUCUSTOMSCRIPT[]; extern const pm_char STR_MENUTELEMETRY[]; extern const pm_char STR_MENUTEMPLATES[]; extern const pm_char STR_MENUSTAT[]; @@ -576,7 +576,7 @@ extern const pm_char STR_RESET_BTN[]; extern const pm_char STR_WARNING[]; extern const pm_char STR_EEPROMWARN[]; -extern const pm_char STR_EEPROM_CONVERTING[]; +extern const pm_char STR_EEPROM_CONVERTING[]; extern const pm_char STR_THROTTLEWARN[]; extern const pm_char STR_ALARMSWARN[]; extern const pm_char STR_SWITCHWARN[]; @@ -601,10 +601,10 @@ extern const pm_char STR_SDHC_CARD[]; extern const pm_char STR_NO_SOUNDS_ON_SD[]; extern const pm_char STR_NO_MODELS_ON_SD[]; extern const pm_char STR_NO_BITMAPS_ON_SD[]; -extern const pm_char STR_NO_SCRIPTS_ON_SD[]; +extern const pm_char STR_NO_SCRIPTS_ON_SD[]; extern const pm_char STR_PLAY_FILE[]; extern const pm_char STR_ASSIGN_BITMAP[]; -extern const pm_char STR_EXECUTE_FILE[]; +extern const pm_char STR_EXECUTE_FILE[]; extern const pm_char STR_DELETE_FILE[]; extern const pm_char STR_COPY_FILE[]; extern const pm_char STR_RENAME_FILE[]; @@ -630,27 +630,34 @@ extern const pm_char STR_OWN[]; extern const pm_char STR_ROTARY_ENCODER[]; extern const pm_char STR_DATE[]; extern const pm_char STR_CHANNELS_MONITOR[]; -extern const pm_char STR_PATH_TOO_LONG[]; -extern const pm_char STR_VIEW_TEXT[]; -extern const pm_char STR_FLASH_BOOTLOADER[]; -extern const pm_char STR_WRITING[]; +extern const pm_char STR_PATH_TOO_LONG[]; +extern const pm_char STR_VIEW_TEXT[]; +extern const pm_char STR_FLASH_BOOTLOADER[]; +extern const pm_char STR_WRITING[]; extern const pm_char STR_CONFIRM_FORMAT[]; extern const pm_char STR_EEBACKUP[]; -extern const pm_char STR_TOO_MANY_LUA_SCRIPTS[]; -extern const pm_char STR_BLCOLOR[]; +extern const pm_char STR_TOO_MANY_LUA_SCRIPTS[]; +extern const pm_char STR_BLCOLOR[]; #if defined(VOICE) && defined(CPUARM) + +#if defined(SIMU) + #define LP_CONST +#else + #define LP_CONST const +#endif + struct LanguagePack { const char *id; const char *name; void (*playNumber)(getvalue_t number, uint8_t unit, uint8_t flags, uint8_t id); void (*playDuration)(int seconds, uint8_t flags, uint8_t id); }; - extern LanguagePack * languagePacks[]; - extern LanguagePack * currentLanguagePack; + extern const LanguagePack * LP_CONST languagePacks[]; + extern const LanguagePack * currentLanguagePack; extern uint8_t currentLanguagePackIdx; - #define LANGUAGE_PACK_DECLARE(lng, name) LanguagePack lng ## LanguagePack = { #lng, name, lng ## _ ## playNumber, lng ## _ ## playDuration } - #define LANGUAGE_PACK_DECLARE_DEFAULT(lng, name) LANGUAGE_PACK_DECLARE(lng, name); LanguagePack * currentLanguagePack = & lng ## LanguagePack; uint8_t currentLanguagePackIdx + #define LANGUAGE_PACK_DECLARE(lng, name) LP_CONST LanguagePack lng ## LanguagePack = { #lng, name, lng ## _ ## playNumber, lng ## _ ## playDuration } + #define LANGUAGE_PACK_DECLARE_DEFAULT(lng, name) LANGUAGE_PACK_DECLARE(lng, name); const LanguagePack * currentLanguagePack = & lng ## LanguagePack; uint8_t currentLanguagePackIdx inline PLAY_FUNCTION(playNumber, getvalue_t number, uint8_t unit, uint8_t flags) { currentLanguagePack->playNumber(number, unit, flags, id); } inline PLAY_FUNCTION(playDuration, int seconds, uint8_t flags) { currentLanguagePack->playDuration(seconds, flags, id); } #elif defined(VOICE) @@ -677,9 +684,9 @@ extern const pm_char STR_BLCOLOR[]; #endif #if LCD_W >= 212 - extern const char * STR_PHASES_HEADERS[]; - extern const char * STR_LIMITS_HEADERS[]; - extern const char * STR_CSW_HEADERS[]; + extern const char * const STR_PHASES_HEADERS[]; + extern const char * const STR_LIMITS_HEADERS[]; + extern const char * const STR_CSW_HEADERS[]; #endif #if defined(CPUARM) @@ -699,24 +706,24 @@ extern const pm_char STR_BLCOLOR[]; #if defined(PCBTARANIS) extern const pm_char STR_BYTES[]; extern const pm_char STR_ANTENNAPROBLEM[]; - extern const pm_char STR_MODULE[]; - extern const pm_char STR_ENABLE_POPUP[]; - extern const pm_char STR_DISABLE_POPUP[]; - extern const pm_char STR_CURVE_PRESET[]; - extern const pm_char STR_PRESET[]; - extern const pm_char STR_MIRROR[]; - extern const pm_char STR_CLEAR[]; + extern const pm_char STR_MODULE[]; + extern const pm_char STR_ENABLE_POPUP[]; + extern const pm_char STR_DISABLE_POPUP[]; + extern const pm_char STR_CURVE_PRESET[]; + extern const pm_char STR_PRESET[]; + extern const pm_char STR_MIRROR[]; + extern const pm_char STR_CLEAR[]; extern const pm_char STR_RESET[]; - extern const pm_char STR_COUNT[]; - extern const pm_char STR_PT[]; - extern const pm_char STR_PTS[]; - extern const pm_char STR_SMOOTH[]; - extern const pm_char STR_COPY_STICKS_TO_OFS[]; -extern const pm_char STR_COPY_TRIMS_TO_OFS[]; + extern const pm_char STR_COUNT[]; + extern const pm_char STR_PT[]; + extern const pm_char STR_PTS[]; + extern const pm_char STR_SMOOTH[]; + extern const pm_char STR_COPY_STICKS_TO_OFS[]; +extern const pm_char STR_COPY_TRIMS_TO_OFS[]; extern const pm_char STR_TOP_BAR[]; extern const pm_char STR_ALTITUDE[]; - extern const pm_char STR_SCALE[]; - extern const pm_char STR_VIEW_CHANNELS[]; + extern const pm_char STR_SCALE[]; + extern const pm_char STR_VIEW_CHANNELS[]; extern const pm_char STR_POTWARNING[]; extern const pm_char STR_UART3MODE[]; extern const pm_char STR_THROTTLE_LABEL[];