Skip to content

Commit 6fd58c4

Browse files
dlechdpgeorge
authored andcommitted
G4_HAL/usb: Pass USB_OTG_CfgTypeDef by reference.
USB_OTG_CfgTypeDef is a large struct, so passing by reference should be more efficient in terms of stack usage and code size. Signed-off-by: David Lechner <[email protected]>
1 parent 46cdeaf commit 6fd58c4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_usb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ typedef struct
182182
*/
183183

184184

185-
HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
186-
HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
185+
HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, const USB_CfgTypeDef *cfg);
186+
HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, const USB_CfgTypeDef *cfg);
187187
HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
188188
HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
189189
HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode);

STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd)
196196
}
197197

198198
/* Init Device */
199-
(void)USB_DevInit(hpcd->Instance, hpcd->Init);
199+
(void)USB_DevInit(hpcd->Instance, &hpcd->Init);
200200

201201
hpcd->USB_Address = 0U;
202202
hpcd->State = HAL_PCD_STATE_READY;

STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* the configuration information for the specified USBx peripheral.
6262
* @retval HAL status
6363
*/
64-
HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg)
64+
HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, const USB_CfgTypeDef *cfg)
6565
{
6666
/* Prevent unused argument(s) compilation warning */
6767
UNUSED(USBx);
@@ -151,7 +151,7 @@ HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode)
151151
* the configuration information for the specified USBx peripheral.
152152
* @retval HAL status
153153
*/
154-
HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg)
154+
HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, const USB_CfgTypeDef *cfg)
155155
{
156156
/* Prevent unused argument(s) compilation warning */
157157
UNUSED(cfg);

0 commit comments

Comments
 (0)