Skip to content

Commit 7716c37

Browse files
committed
Add function to get PCD handle and use it in dfu loop
1 parent 2ff2ed6 commit 7716c37

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

app/dfu/usbd_conf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ PCD_HandleTypeDef hpcd;
3737
/*******************************************************************************
3838
PCD BSP Routines
3939
*******************************************************************************/
40+
PCD_HandleTypeDef * HAL_PCD_GetHandle(void)
41+
{
42+
return &hpcd;
43+
}
4044

4145
/**
4246
* @brief Initializes the PCD MSP.

app/dfu/usbd_conf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#endif
8282

8383
/* Exported functions ------------------------------------------------------- */
84+
extern PCD_HandleTypeDef * HAL_PCD_GetHandle(void);
8485

8586
#endif /* __USBD_CONF_H */
8687

app/main.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default)
3939
#define USE_PLL_HSI 0x2 // Use HSI internal clock
4040

41+
extern "C" uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed);
42+
4143
volatile const uint8_t bootloader_data[] __attribute__ ((section (".bootloader_version"), used)) = {
4244
BOOTLOADER_CONFIG_MAGIC,
4345
BOOTLOADER_VERSION,
@@ -54,6 +56,10 @@ volatile const uint8_t bootloader_data[] __attribute__ ((section (".bootloader_v
5456

5557
volatile const uint8_t bootloader_identifier[] __attribute__ ((section (".bootloader_identification"), used)) = "MCUboot Arduino";
5658

59+
#if MCUBOOT_APPLICATION_DFU
60+
USBD_HandleTypeDef USBD_Device;
61+
#endif
62+
5763
DigitalOut red(BOARD_RED_LED, 1);
5864
DigitalOut green(BOARD_GREEN_LED, 1);
5965
DigitalOut blue(BOARD_BLUE_LED, 1);
@@ -135,15 +141,6 @@ static int debug_init(void) {
135141
return 0;
136142
}
137143

138-
#if MCUBOOT_APPLICATION_DFU
139-
USBD_HandleTypeDef USBD_Device;
140-
extern PCD_HandleTypeDef hpcd;
141-
#endif
142-
143-
extern "C" {
144-
uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed);
145-
}
146-
147144
static int start_dfu(void) {
148145
RTCSetBKPRegister(RTC_BKP_DR0, 0);
149146

@@ -185,7 +182,7 @@ static int start_dfu(void) {
185182
#else // USE_USB_FS
186183
if (USB_OTG_FS->GINTSTS & USB_OTG_FS->GINTMSK) {
187184
#endif
188-
HAL_PCD_IRQHandler(&hpcd);
185+
HAL_PCD_IRQHandler(HAL_PCD_GetHandle());
189186
}
190187
#endif
191188
led_pulse(&green);

0 commit comments

Comments
 (0)