Skip to content

Commit f584c73

Browse files
committed
Add function to get PCD handle and use it in dfu loop
1 parent ca42da6 commit f584c73

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
@@ -39,6 +39,8 @@
3939
#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default)
4040
#define USE_PLL_HSI 0x2 // Use HSI internal clock
4141

42+
extern "C" uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed);
43+
4244
volatile const uint8_t bootloader_data[] __attribute__ ((section (".bootloader_version"), used)) = {
4345
BOOTLOADER_CONFIG_MAGIC,
4446
BOOTLOADER_VERSION,
@@ -55,6 +57,10 @@ volatile const uint8_t bootloader_data[] __attribute__ ((section (".bootloader_v
5557

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

60+
#if MCUBOOT_APPLICATION_DFU
61+
USBD_HandleTypeDef USBD_Device;
62+
#endif
63+
5864
DigitalOut red(BOARD_RED_LED, 1);
5965
DigitalOut green(BOARD_GREEN_LED, 1);
6066
DigitalOut blue(BOARD_BLUE_LED, 1);
@@ -118,15 +124,6 @@ static int debug_init(void) {
118124
return 0;
119125
}
120126

121-
#if MCUBOOT_APPLICATION_DFU
122-
USBD_HandleTypeDef USBD_Device;
123-
extern PCD_HandleTypeDef hpcd;
124-
#endif
125-
126-
extern "C" {
127-
uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed);
128-
}
129-
130127
static int start_dfu(void) {
131128
RTCSetBKPRegister(RTC_BKP_DR0, 0);
132129

@@ -168,7 +165,7 @@ static int start_dfu(void) {
168165
#else // USE_USB_FS
169166
if (USB_OTG_FS->GINTSTS & USB_OTG_FS->GINTMSK) {
170167
#endif
171-
HAL_PCD_IRQHandler(&hpcd);
168+
HAL_PCD_IRQHandler(HAL_PCD_GetHandle());
172169
}
173170
#endif
174171
led_pulse(&green);

0 commit comments

Comments
 (0)