Skip to content

Commit 6183bd4

Browse files
Merge pull request #530 from howard0su/usb
Make some USB structure as const to save some RAM
2 parents aced598 + 4e8f78c commit 6183bd4

7 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/target/common/devo/hid/hid_devo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ extern void (*pEpInt_IN[7])(void);
2828
extern void (*pEpInt_OUT[7])(void);
2929
extern void (* const HID_pEpInt_IN[7])(void);
3030
extern void (* const HID_pEpInt_OUT[7])(void);
31-
extern DEVICE_PROP HID_Device_Property;
32-
extern USER_STANDARD_REQUESTS HID_User_Standard_Requests;
31+
extern const DEVICE_PROP HID_Device_Property;
32+
extern const USER_STANDARD_REQUESTS HID_User_Standard_Requests;
3333
extern void USB_Enable(u8 type, u8 use_interrupt);
3434
extern void USB_Disable();
3535

src/target/common/devo/msc2/lib/usb_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ RESULT Standard_ClearFeature(void)
255255
}
256256
else if (Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
257257
{/*EndPoint Clear Feature*/
258-
DEVICE* pDev;
258+
const DEVICE* pDev;
259259
uint32_t Related_Endpoint;
260260
uint32_t wIndex0;
261261
uint32_t rEP;

src/target/common/devo/msc2/lib/usb_core.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ RESULT Standard_ClearFeature(void);
233233
void SetDeviceAddress(uint8_t);
234234
void NOP_Process(void);
235235

236-
extern DEVICE_PROP *Device_Property;
237-
extern USER_STANDARD_REQUESTS *User_Standard_Requests;
238-
extern DEVICE Device_Table;
236+
extern const DEVICE_PROP *Device_Property;
237+
extern const USER_STANDARD_REQUESTS *User_Standard_Requests;
238+
extern const DEVICE Device_Table;
239239
extern DEVICE_INFO Device_Info;
240240

241241
/* cells saving status during interrupt servicing */

src/target/common/devo/msc2/lib/usb_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
DEVICE_INFO *pInformation;
3030
/* Points to the DEVICE_PROP structure of current device */
3131
/* The purpose of this register is to speed up the execution */
32-
DEVICE_PROP *pProperty;
32+
const DEVICE_PROP *pProperty;
3333
/* Temporary save the state of Rx & Tx status. */
3434
/* Whenever the Rx or Tx state is changed, its value is saved */
3535
/* in this variable first and will be set to the EPRB or EPRA */
3636
/* at the end of interrupt process */
3737
uint16_t SaveState ;
3838
uint16_t wInterrupt_Mask;
3939
DEVICE_INFO Device_Info;
40-
USER_STANDARD_REQUESTS *pUser_Standard_Requests;
40+
const USER_STANDARD_REQUESTS *pUser_Standard_Requests;
4141

4242
/* Extern variables ----------------------------------------------------------*/
4343
/* Private function prototypes -----------------------------------------------*/

src/target/common/devo/msc2/lib/usb_init.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ extern uint8_t EPindex;
3434
extern DEVICE_INFO* pInformation;
3535
/* Points to the DEVICE_PROP structure of current device */
3636
/* The purpose of this register is to speed up the execution */
37-
extern DEVICE_PROP* pProperty;
37+
extern const DEVICE_PROP* pProperty;
3838
/* Temporary save the state of Rx & Tx status. */
3939
/* Whenever the Rx or Tx state is changed, its value is saved */
4040
/* in this variable first and will be set to the EPRB or EPRA */
4141
/* at the end of interrupt process */
42-
extern USER_STANDARD_REQUESTS *pUser_Standard_Requests;
42+
extern const USER_STANDARD_REQUESTS *pUser_Standard_Requests;
4343

4444
extern uint16_t SaveState ;
4545
extern uint16_t wInterrupt_Mask;

src/target/common/devo/msc2/usb_devo8.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ void usb_lp_can_rx0_isr()
4141
}
4242
void (*pEpInt_IN[7])(void) = {};
4343
void (*pEpInt_OUT[7])(void) = {};
44-
DEVICE_PROP *Device_Property;
45-
USER_STANDARD_REQUESTS *User_Standard_Requests;
44+
const DEVICE_PROP *Device_Property;
45+
const USER_STANDARD_REQUESTS *User_Standard_Requests;
4646

4747
extern void (*MSC_pEpInt_IN[7])(void);
4848
extern void (*MSC_pEpInt_OUT[7])(void);
49-
extern DEVICE_PROP MSC_Device_Property;
50-
extern USER_STANDARD_REQUESTS MSC_User_Standard_Requests;
49+
extern const DEVICE_PROP MSC_Device_Property;
50+
extern const USER_STANDARD_REQUESTS MSC_User_Standard_Requests;
5151

5252
extern void (*HID_pEpInt_IN[7])(void);
5353
extern void (*HID_pEpInt_OUT[7])(void);
54-
extern DEVICE_PROP HID_Device_Property;
55-
extern USER_STANDARD_REQUESTS HID_User_Standard_Requests;
54+
extern const DEVICE_PROP HID_Device_Property;
55+
extern const USER_STANDARD_REQUESTS HID_User_Standard_Requests;
5656

5757
void MSC_Init() {
5858
memcpy(pEpInt_IN, MSC_pEpInt_IN, sizeof(pEpInt_IN));

src/target/common/devo/msc2/usb_prop.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
/* Private variables ---------------------------------------------------------*/
3030
uint32_t Max_Lun = 0;
3131

32-
DEVICE Device_Table =
32+
const DEVICE Device_Table =
3333
{
3434
EP_NUM,
3535
1
3636
};
3737

38-
DEVICE_PROP MSC_Device_Property =
38+
const DEVICE_PROP MSC_Device_Property =
3939
{
4040
MASS_init,
4141
MASS_Reset,
@@ -51,7 +51,7 @@ DEVICE_PROP MSC_Device_Property =
5151
0x40 /*MAX PACKET SIZE*/
5252
};
5353

54-
USER_STANDARD_REQUESTS MSC_User_Standard_Requests =
54+
const USER_STANDARD_REQUESTS MSC_User_Standard_Requests =
5555
{
5656
Mass_Storage_GetConfiguration,
5757
Mass_Storage_SetConfiguration,
@@ -64,19 +64,19 @@ USER_STANDARD_REQUESTS MSC_User_Standard_Requests =
6464
Mass_Storage_SetDeviceAddress
6565
};
6666

67-
ONE_DESCRIPTOR MSC_Device_Descriptor =
67+
const ONE_DESCRIPTOR MSC_Device_Descriptor =
6868
{
6969
(uint8_t*)MASS_DeviceDescriptor,
7070
MASS_SIZ_DEVICE_DESC
7171
};
7272

73-
ONE_DESCRIPTOR MSC_Config_Descriptor =
73+
const ONE_DESCRIPTOR MSC_Config_Descriptor =
7474
{
7575
(uint8_t*)MASS_ConfigDescriptor,
7676
MASS_SIZ_CONFIG_DESC
7777
};
7878

79-
ONE_DESCRIPTOR MSC_String_Descriptor[5] =
79+
const ONE_DESCRIPTOR MSC_String_Descriptor[5] =
8080
{
8181
{(uint8_t*)MASS_StringLangID, MASS_SIZ_STRING_LANGID},
8282
{(uint8_t*)MASS_StringVendor, MASS_SIZ_STRING_VENDOR},

0 commit comments

Comments
 (0)