summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrolandvs <roland@van-straten.org>2018-05-29 14:28:09 +0200
committerDamien George <damien.p.george@gmail.com>2018-05-30 09:51:19 +1000
commit958fa745213d3bef8a70f8993363098f07fc21fe (patch)
tree4384e77f02b4c46eb96610dada1583dbebc40cf9
parent50bc34d4a454019fc792b4f5034b75dad5b98168 (diff)
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.
-rw-r--r--ports/stm32/boards/NUCLEO_F767ZI/board_init.c8
-rw-r--r--ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h3
-rw-r--r--ports/stm32/boards/NUCLEO_F767ZI/pins.csv1
-rw-r--r--ports/stm32/boards/NUCLEO_H743ZI/board_init.c15
4 files changed, 16 insertions, 11 deletions
diff --git a/ports/stm32/boards/NUCLEO_F767ZI/board_init.c b/ports/stm32/boards/NUCLEO_F767ZI/board_init.c
new file mode 100644
index 000000000..7d25a445d
--- /dev/null
+++ b/ports/stm32/boards/NUCLEO_F767ZI/board_init.c
@@ -0,0 +1,8 @@
+#include "py/mphal.h"
+
+void NUCLEO_F767ZI_board_early_init(void) {
+ // Turn off the USB switch
+ #define USB_PowerSwitchOn pin_G6
+ mp_hal_pin_output(USB_PowerSwitchOn);
+ mp_hal_pin_low(USB_PowerSwitchOn);
+}
diff --git a/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h b/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h
index 7de4c3363..3f23d77d4 100644
--- a/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h
+++ b/ports/stm32/boards/NUCLEO_F767ZI/mpconfigboard.h
@@ -13,6 +13,9 @@
#define MICROPY_HW_ENABLE_DAC (1)
#define MICROPY_HW_ENABLE_USB (1)
+#define MICROPY_BOARD_EARLY_INIT NUCLEO_F767ZI_board_early_init
+void NUCLEO_F767ZI_board_early_init(void);
+
// HSE is 25MHz
// VCOClock = HSE * PLLN / PLLM = 25 MHz * 432 / 25 = 432 MHz
// SYSCLK = VCOClock / PLLP = 432 MHz / 2 = 216 MHz
diff --git a/ports/stm32/boards/NUCLEO_F767ZI/pins.csv b/ports/stm32/boards/NUCLEO_F767ZI/pins.csv
index 9df4fc7ef..3cae615da 100644
--- a/ports/stm32/boards/NUCLEO_F767ZI/pins.csv
+++ b/ports/stm32/boards/NUCLEO_F767ZI/pins.csv
@@ -58,6 +58,7 @@ USB_VBUS,PA9
USB_ID,PA10
USB_DM,PA11
USB_DP,PA12
+USB_POWER,PG6
VCP_TX,PD8
VCP_RX,PD9
UART2_TX,PD5
diff --git a/ports/stm32/boards/NUCLEO_H743ZI/board_init.c b/ports/stm32/boards/NUCLEO_H743ZI/board_init.c
index 1a6006c28..04149c37b 100644
--- a/ports/stm32/boards/NUCLEO_H743ZI/board_init.c
+++ b/ports/stm32/boards/NUCLEO_H743ZI/board_init.c
@@ -1,15 +1,8 @@
-#include STM32_HAL_H
+#include "py/mphal.h"
void NUCLEO_H743ZI_board_early_init(void) {
- GPIO_InitTypeDef GPIO_InitStructure;
-
- __HAL_RCC_GPIOG_CLK_ENABLE();
-
// Turn off the USB switch
- GPIO_InitStructure.Pin = GPIO_PIN_6;
- GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStructure.Pull = GPIO_PULLDOWN;
- GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
- HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);
+ #define USB_PowerSwitchOn pin_G6
+ mp_hal_pin_output(USB_PowerSwitchOn);
+ mp_hal_pin_low(USB_PowerSwitchOn);
}