Skip to content

Commit 958fa74

Browse files
rolandvsdpgeorge
authored andcommitted
stm32/boards: Ensure USB OTG power is off for NUCLEO_F767ZI.
And update the GPIO init for NUCLEO_H743ZI to consistently use the mphal functions.
1 parent 50bc34d commit 958fa74

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "py/mphal.h"
2+
3+
void NUCLEO_F767ZI_board_early_init(void) {
4+
// Turn off the USB switch
5+
#define USB_PowerSwitchOn pin_G6
6+
mp_hal_pin_output(USB_PowerSwitchOn);
7+
mp_hal_pin_low(USB_PowerSwitchOn);
8+
}

ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#define MICROPY_HW_ENABLE_DAC (1)
1414
#define MICROPY_HW_ENABLE_USB (1)
1515

16+
#define MICROPY_BOARD_EARLY_INIT NUCLEO_F767ZI_board_early_init
17+
void NUCLEO_F767ZI_board_early_init(void);
18+
1619
// HSE is 25MHz
1720
// VCOClock = HSE * PLLN / PLLM = 25 MHz * 432 / 25 = 432 MHz
1821
// SYSCLK = VCOClock / PLLP = 432 MHz / 2 = 216 MHz

ports/stm32/boards/NUCLEO_F767ZI/pins.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ USB_VBUS,PA9
5858
USB_ID,PA10
5959
USB_DM,PA11
6060
USB_DP,PA12
61+
USB_POWER,PG6
6162
VCP_TX,PD8
6263
VCP_RX,PD9
6364
UART2_TX,PD5
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
#include STM32_HAL_H
1+
#include "py/mphal.h"
22

33
void NUCLEO_H743ZI_board_early_init(void) {
4-
GPIO_InitTypeDef GPIO_InitStructure;
5-
6-
__HAL_RCC_GPIOG_CLK_ENABLE();
7-
84
// Turn off the USB switch
9-
GPIO_InitStructure.Pin = GPIO_PIN_6;
10-
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
11-
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
12-
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
13-
HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
14-
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);
5+
#define USB_PowerSwitchOn pin_G6
6+
mp_hal_pin_output(USB_PowerSwitchOn);
7+
mp_hal_pin_low(USB_PowerSwitchOn);
158
}

0 commit comments

Comments
 (0)