Skip to content

Commit 1f857a8

Browse files
committed
add button pin and clock init for USB support
1 parent 66ddcc4 commit 1f857a8

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

ports/stm/boards/daisy_seed_with_sdram/mpconfigboard.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
#define MICROPY_HW_LED_STATUS (&pin_PC07)
3333

34-
// #define FLASH_PAGE_SIZE (0x4000) // 256B for this flash
35-
3634
// H7 and F7 MPU definitions
3735
#define CPY_FLASH_REGION_SIZE ARM_MPU_REGION_SIZE_8MB
3836
#define CPY_ITCM_REGION_SIZE ARM_MPU_REGION_SIZE_64KB
@@ -42,9 +40,14 @@
4240
#define CPY_SRAM_START_ADDR 0x24000000
4341

4442
#define HSE_VALUE ((uint32_t)16000000)
45-
#define LSE_VALUE ((uint32_t)32768)
4643
#define BOARD_HSE_SOURCE (RCC_HSE_ON) // use external oscillator
4744
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
4845

4946
#define CIRCUITPY_CONSOLE_UART_TX (&pin_PB09)
50-
#define CIRCUITPY_CONSOLE_UART_RX (&pin_PB08)
47+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_PB08)
48+
49+
// USB
50+
#define BOARD_NO_USB_OTG_ID_SENSE (1)
51+
52+
// for RNG not audio
53+
#define CPY_CLK_USB_USES_AUDIOPLL (1)

ports/stm/boards/daisy_seed_with_sdram/pins.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
static const mp_rom_map_elem_t board_module_globals_table[] = {
44
{MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PC07)},
5+
{MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_PG03)},
56
};
67
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/stm/peripherals/stm32h7/clocks.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,28 @@ void stm32_peripherals_clocks_init(void) {
9292
#else
9393
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
9494
#endif
95-
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
96-
95+
#ifdef STM32H750xx
96+
// USB
97+
PeriphClkInitStruct.PLL3.PLL3M = 1;
98+
PeriphClkInitStruct.PLL3.PLL3N = 12;
99+
PeriphClkInitStruct.PLL3.PLL3P = 2;
100+
PeriphClkInitStruct.PLL3.PLL3Q = 4;
101+
PeriphClkInitStruct.PLL3.PLL3R = 2;
102+
PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_3;
103+
PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
104+
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
105+
// RNG
106+
PeriphClkInitStruct.PeriphClockSelection = PeriphClkInitStruct.PeriphClockSelection | RCC_PERIPHCLK_RNG;
107+
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
108+
// RTC
109+
PeriphClkInitStruct.PeriphClockSelection = PeriphClkInitStruct.PeriphClockSelection | RCC_PERIPHCLK_RTC;
110+
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
111+
#endif
112+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
113+
while (1) {
114+
;
115+
}
116+
}
97117
// Enable USB Voltage detector
98118
HAL_PWREx_EnableUSBVoltageDetector();
99119
}

0 commit comments

Comments
 (0)