mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
Compare commits
5 Commits
22cff2f6f5
...
41acdd8083
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41acdd8083 | ||
|
|
63c94fe73e | ||
|
|
f43810b1cd | ||
|
|
14b5080515 | ||
|
|
9b73e344eb |
47
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/bdev.c
Normal file
47
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/bdev.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* This file is part of the MicroPython project, http://micropython.org/
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2019 Damien P. George
|
||||
*/
|
||||
|
||||
#include "storage.h"
|
||||
#include "spi.h"
|
||||
#include "qspi.h"
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
static const spi_proto_cfg_t spi_bus = {
|
||||
.spi = &spi_obj[0], // SPI1
|
||||
.baudrate = 25000000,
|
||||
.polarity = 0,
|
||||
.phase = 0,
|
||||
.bits = 8,
|
||||
.firstbit = SPI_FIRSTBIT_MSB,
|
||||
};
|
||||
|
||||
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
|
||||
static mp_spiflash_cache_t spi_bdev_cache;
|
||||
#endif
|
||||
|
||||
const mp_spiflash_config_t spiflash_config = {
|
||||
.bus_kind = MP_SPIFLASH_BUS_SPI,
|
||||
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS,
|
||||
|
||||
.bus.u_spi.data = (void *)&spi_bus,
|
||||
.bus.u_spi.proto = &spi_proto,
|
||||
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
|
||||
.cache = &spi_bdev_cache,
|
||||
#endif
|
||||
};
|
||||
|
||||
spi_bdev_t spi_bdev;
|
||||
|
||||
// Second external SPI flash uses hardware QSPI interface
|
||||
const mp_spiflash_config_t spiflash2_config = {
|
||||
.bus_kind = MP_SPIFLASH_BUS_QSPI,
|
||||
.bus.u_qspi.data = NULL,
|
||||
.bus.u_qspi.proto = &qspi_proto,
|
||||
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
|
||||
.cache = &spi_bdev_cache,
|
||||
#endif
|
||||
};
|
||||
|
||||
spi_bdev_t spi_bdev2;
|
||||
13
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board.json
Normal file
13
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"deploy": [
|
||||
"deploy.md"
|
||||
],
|
||||
"features": ["External Flash", "DAC", "Display","microSD", "USB", "USB-C"],
|
||||
"images": [
|
||||
"weact_stm32h743.jpg"
|
||||
],
|
||||
"mcu": "stm32h7",
|
||||
"product": "Mini STM32H743",
|
||||
"url": "https://github.com/WeActStudio/MiniSTM32H7xx",
|
||||
"vendor": "WeAct Studio"
|
||||
}
|
||||
16
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board_init.c
Normal file
16
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/board_init.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/* This file is part of the MicroPython project, http://micropython.org/
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2019 Damien P. George
|
||||
*/
|
||||
|
||||
#include "py/mphal.h"
|
||||
#include "storage.h"
|
||||
|
||||
void WeAct_Core_early_init(void) {
|
||||
// Turn off the USB switch.
|
||||
mp_hal_pin_output(pyb_pin_OTG_FS_POWER);
|
||||
mp_hal_pin_low(pyb_pin_OTG_FS_POWER);
|
||||
|
||||
// Explicitly init SPI2 because it's not enabled as a block device
|
||||
spi_bdev_ioctl(&spi_bdev2, BDEV_IOCTL_INIT, (uint32_t)&spiflash2_config);
|
||||
}
|
||||
19
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/deploy.md
Normal file
19
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/deploy.md
Normal file
@@ -0,0 +1,19 @@
|
||||
### WeAct Studio STM32H7xx
|
||||
|
||||
WeAct Studio make a number of STM32H7xx-based boards, they can all be updated
|
||||
using
|
||||
[DFU](https://en.wikipedia.org/wiki/USB?useskin=vector#Device_Firmware_Upgrade_mechanism).
|
||||
|
||||
### DFU update
|
||||
|
||||
Hold the Boot button - the middle of the cluster of three buttons - while the
|
||||
board is reset (either by connecting USB or by pressing reset). Release the Boot
|
||||
button shortly after the board has reset. The board ought to now be in DFU mode
|
||||
and detectable as such from a connected computer.
|
||||
|
||||
Use a tool like [`dfu-util`](https://dfu-util.sourceforge.net/) to update the
|
||||
firmware:
|
||||
|
||||
```bash
|
||||
dfu-util --alt 0 -D firmware.dfu
|
||||
```
|
||||
@@ -0,0 +1,4 @@
|
||||
include("$(PORT_DIR)/boards/manifest.py")
|
||||
|
||||
# Currently this file is a placeholder.
|
||||
# It would be good to extend to add an LCD driver.
|
||||
171
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.h
Normal file
171
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/mpconfigboard.h
Normal file
@@ -0,0 +1,171 @@
|
||||
#define MICROPY_HW_BOARD_NAME "WEACTSTUDIO_MINI_STM32H743"
|
||||
#define MICROPY_HW_MCU_NAME "STM32H743VIT6"
|
||||
|
||||
#define MICROPY_FATFS_EXFAT (1)
|
||||
#define MICROPY_HW_ENABLE_RTC (1)
|
||||
#define MICROPY_HW_ENABLE_RNG (1)
|
||||
#define MICROPY_HW_ENABLE_ADC (1)
|
||||
#define MICROPY_HW_ENABLE_DAC (1)
|
||||
#define MICROPY_HW_ENABLE_USB (1)
|
||||
#define MICROPY_HW_HAS_SWITCH (1)
|
||||
#define MICROPY_HW_HAS_FLASH (1)
|
||||
#define MICROPY_HW_ENABLE_SERVO (1)
|
||||
#define MICROPY_HW_ENABLE_TIMER (1)
|
||||
#define MICROPY_HW_ENABLE_SDCARD (1)
|
||||
#define MICROPY_HW_ENABLE_MMCARD (0)
|
||||
|
||||
// ROMFS config
|
||||
#define MICROPY_HW_ROMFS_ENABLE_EXTERNAL_QSPI (1)
|
||||
#define MICROPY_HW_ROMFS_QSPI_SPIFLASH_OBJ (&spi_bdev2.spiflash)
|
||||
#define MICROPY_HW_ROMFS_ENABLE_PART0 (1)
|
||||
|
||||
// Flash storage config
|
||||
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
|
||||
// Disable internal filesystem to use spiflash.
|
||||
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
|
||||
|
||||
// W25Q64 for storage
|
||||
#define MICROPY_HW_SPIFLASH_SIZE_BYTES (8 * 1024 * 1024)
|
||||
|
||||
// SPI flash #1, for R/W storage
|
||||
#define MICROPY_HW_SPIFLASH_CS (pin_D6)
|
||||
#define MICROPY_HW_SPIFLASH_SCK (pin_B3)
|
||||
#define MICROPY_HW_SPIFLASH_MOSI (pin_D7)
|
||||
#define MICROPY_HW_SPIFLASH_MISO (pin_B4)
|
||||
|
||||
// External SPI Flash configuration
|
||||
#define MICROPY_HW_SPI_IS_RESERVED(id) (id == 1)
|
||||
|
||||
// SPI flash #1, block device config
|
||||
extern const struct _mp_spiflash_config_t spiflash_config;
|
||||
extern struct _spi_bdev_t spi_bdev;
|
||||
|
||||
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
|
||||
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
|
||||
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
|
||||
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
|
||||
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
|
||||
|
||||
// SPI flash #2, to be memory mapped
|
||||
#define MICROPY_HW_QSPI_PRESCALER (2) // 120 MHz
|
||||
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (26)
|
||||
#define MICROPY_HW_QSPIFLASH_CS (pin_B6)
|
||||
#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
|
||||
#define MICROPY_HW_QSPIFLASH_IO0 (pin_D11)
|
||||
#define MICROPY_HW_QSPIFLASH_IO1 (pin_D12)
|
||||
#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
|
||||
#define MICROPY_HW_QSPIFLASH_IO3 (pin_D13)
|
||||
|
||||
// SPI flash #2, block device config
|
||||
extern const struct _mp_spiflash_config_t spiflash2_config;
|
||||
extern struct _spi_bdev_t spi_bdev2;
|
||||
|
||||
#define MICROPY_BOARD_EARLY_INIT WeAct_Core_early_init
|
||||
|
||||
// This board has 25MHz HSE.
|
||||
// The following gives a 480MHz CPU speed.
|
||||
#define MICROPY_HW_CLK_USE_HSE (1)
|
||||
#define MICROPY_HW_CLK_PLLM (5)
|
||||
#define MICROPY_HW_CLK_PLLN (192)
|
||||
#define MICROPY_HW_CLK_PLLP (2)
|
||||
#define MICROPY_HW_CLK_PLLQ (20)
|
||||
#define MICROPY_HW_CLK_PLLR (2)
|
||||
#define MICROPY_HW_CLK_PLLVCI (RCC_PLL1VCIRANGE_2)
|
||||
#define MICROPY_HW_CLK_PLLVCO (RCC_PLL1VCOWIDE)
|
||||
#define MICROPY_HW_CLK_PLLFRAC (0)
|
||||
|
||||
// The USB clock is set using PLL3
|
||||
#define MICROPY_HW_CLK_PLL3M (5)
|
||||
#define MICROPY_HW_CLK_PLL3N (192)
|
||||
#define MICROPY_HW_CLK_PLL3P (2)
|
||||
#define MICROPY_HW_CLK_PLL3Q (20)
|
||||
#define MICROPY_HW_CLK_PLL3R (2)
|
||||
#define MICROPY_HW_CLK_PLL3VCI (RCC_PLL3VCIRANGE_2)
|
||||
#define MICROPY_HW_CLK_PLL3VCO (RCC_PLL3VCOWIDE)
|
||||
#define MICROPY_HW_CLK_PLL3FRAC (0)
|
||||
|
||||
// 32kHz crystal for RTC
|
||||
#define MICROPY_HW_RTC_USE_LSE (1)
|
||||
#define MICROPY_HW_RTC_USE_US (0)
|
||||
|
||||
// 6 wait states
|
||||
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_6
|
||||
|
||||
// UART
|
||||
#define MICROPY_HW_UART1_TX (pin_A9)
|
||||
#define MICROPY_HW_UART1_RX (pin_A10)
|
||||
#define MICROPY_HW_UART2_TX (pin_A2)
|
||||
#define MICROPY_HW_UART2_RX (pin_A3)
|
||||
#define MICROPY_HW_UART3_TX (pin_B10)
|
||||
#define MICROPY_HW_UART3_RX (pin_B11)
|
||||
#define MICROPY_HW_UART4_TX (pin_C11)
|
||||
#define MICROPY_HW_UART4_RX (pin_C10)
|
||||
#define MICROPY_HW_UART5_TX (pin_B12) // or SPI2
|
||||
#define MICROPY_HW_UART5_RX (pin_B13) // or SPI2
|
||||
#define MICROPY_HW_UART6_TX (pin_C6)
|
||||
#define MICROPY_HW_UART6_RX (pin_C7)
|
||||
#define MICROPY_HW_UART7_TX (pin_E8)
|
||||
#define MICROPY_HW_UART7_RX (pin_E7)
|
||||
|
||||
// I2C buses
|
||||
#define MICROPY_HW_I2C1_SCL (pin_B8)
|
||||
#define MICROPY_HW_I2C1_SDA (pin_B9)
|
||||
|
||||
#define MICROPY_HW_I2C2_SCL (pin_B10)
|
||||
#define MICROPY_HW_I2C2_SDA (pin_B11)
|
||||
|
||||
// SPI buses
|
||||
// NOTE: SPI1 is used for the SPI flash.
|
||||
#define MICROPY_HW_SPI1_NSS (pin_D6)
|
||||
#define MICROPY_HW_SPI1_SCK (pin_B3)
|
||||
#define MICROPY_HW_SPI1_MISO (pin_B4)
|
||||
#define MICROPY_HW_SPI1_MOSI (pin_D7)
|
||||
|
||||
#define MICROPY_HW_SPI2_NSS (pin_B12)
|
||||
#define MICROPY_HW_SPI2_SCK (pin_B13)
|
||||
#define MICROPY_HW_SPI2_MISO (pin_B14)
|
||||
#define MICROPY_HW_SPI2_MOSI (pin_B15)
|
||||
// NOTE: SPI3 is used for the QSPI flash.
|
||||
#define MICROPY_HW_SPI3_NSS (pin_A4)
|
||||
#define MICROPY_HW_SPI3_SCK (pin_B3)
|
||||
#define MICROPY_HW_SPI3_MISO (pin_B4)
|
||||
#define MICROPY_HW_SPI3_MOSI (pin_B5)
|
||||
// NOTE: SPI4 is used for the ST7735 LCD.
|
||||
#define MICROPY_HW_SPI4_NSS (pin_E11)
|
||||
#define MICROPY_HW_SPI4_SCK (pin_E12)
|
||||
#define MICROPY_HW_SPI4_MISO (pin_E13)
|
||||
#define MICROPY_HW_SPI4_MOSI (pin_E14)
|
||||
|
||||
// CAN buses
|
||||
#define MICROPY_HW_CAN1_TX (pin_B9)
|
||||
#define MICROPY_HW_CAN1_RX (pin_B8)
|
||||
|
||||
// USRSW is pulled low. Pressing the button makes the input go high.
|
||||
#define MICROPY_HW_USRSW_PIN (pin_C13) // K1 on the board.
|
||||
#define MICROPY_HW_USRSW_PULL (GPIO_PULLDOWN)
|
||||
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
|
||||
#define MICROPY_HW_USRSW_PRESSED (1)
|
||||
|
||||
// LEDs
|
||||
#define MICROPY_HW_LED1 (pin_E3) // the only controllable LED on the board.
|
||||
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
|
||||
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
|
||||
|
||||
// SD Card SDMMC
|
||||
#define MICROPY_HW_SDCARD_SDMMC (1)
|
||||
#define MICROPY_HW_SDCARD_CK (pin_C12)
|
||||
#define MICROPY_HW_SDCARD_CMD (pin_D2)
|
||||
#define MICROPY_HW_SDCARD_D0 (pin_C8)
|
||||
#define MICROPY_HW_SDCARD_D1 (pin_C9)
|
||||
#define MICROPY_HW_SDCARD_D2 (pin_C10)
|
||||
#define MICROPY_HW_SDCARD_D3 (pin_C11)
|
||||
|
||||
// SD card detect switch
|
||||
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_D4)
|
||||
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
|
||||
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
|
||||
|
||||
// USB config
|
||||
#define MICROPY_HW_USB_FS (1)
|
||||
|
||||
void WeAct_Core_early_init(void);
|
||||
@@ -0,0 +1,22 @@
|
||||
USE_MBOOT ?= 0
|
||||
|
||||
# MCU settings
|
||||
MCU_SERIES = h7
|
||||
CMSIS_MCU = STM32H743xx
|
||||
MICROPY_FLOAT_IMPL = double
|
||||
AF_FILE = boards/stm32h743_af.csv
|
||||
|
||||
ifeq ($(USE_MBOOT),1)
|
||||
# When using Mboot everything goes after the bootloader
|
||||
LD_FILES = boards/stm32h723.ld boards/common_bl.ld
|
||||
TEXT0_ADDR = 0x08020000
|
||||
else
|
||||
# When not using Mboot everything goes at the start of flash
|
||||
LD_FILES = boards/WEACTSTUDIO_MINI_STM32H743/weact_stm32h743.ld boards/common_basic.ld
|
||||
TEXT0_ADDR = 0x08000000
|
||||
endif
|
||||
|
||||
# MicroPython settings
|
||||
MICROPY_VFS_LFS2 = 1
|
||||
|
||||
FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py
|
||||
100
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/pins.csv
Normal file
100
ports/stm32/boards/WEACTSTUDIO_MINI_STM32H743/pins.csv
Normal file
@@ -0,0 +1,100 @@
|
||||
A0,PA0
|
||||
A1,PA1
|
||||
A2,PA2
|
||||
A3,PA3
|
||||
A4,PA4
|
||||
A5,PA5
|
||||
A6,PA6
|
||||
A7,PA7
|
||||
A8,PA8
|
||||
A9,PA9
|
||||
A10,PA10
|
||||
A11,PA11
|
||||
A12,PA12
|
||||
A15,PA15
|
||||
B0,PB0
|
||||
B1,PB1
|
||||
B2,PB2
|
||||
B3,PB3
|
||||
B4,PB4
|
||||
B5,PB5
|
||||
B6,PB6
|
||||
B7,PB7
|
||||
B8,PB8
|
||||
B9,PB9
|
||||
B10,PB10
|
||||
B11,PB11
|
||||
B12,PB12
|
||||
B13,PB13
|
||||
B14,PB14
|
||||
B15,PB15
|
||||
C0,PC0
|
||||
C1,PC1
|
||||
C2,PC2
|
||||
C3,PC3
|
||||
C4,PC4
|
||||
C5,PC5
|
||||
C6,PC6
|
||||
C7,PC7
|
||||
C8,PC8
|
||||
C9,PC9
|
||||
C10,PC10
|
||||
C11,PC11
|
||||
C12,PC12
|
||||
C13,PC13
|
||||
D0,PD0
|
||||
D1,PD1
|
||||
D2,PD2
|
||||
D3,PD3
|
||||
D4,PD4
|
||||
D5,PD5
|
||||
D6,PD6
|
||||
D7,PD7
|
||||
D8,PD8
|
||||
D9,PD9
|
||||
D10,PD10
|
||||
D11,PD11
|
||||
D12,PD12
|
||||
D13,PD13
|
||||
D14,PD14
|
||||
D15,PD15
|
||||
E0,PE0
|
||||
E1,PE1
|
||||
E2,PE2
|
||||
E3,PE3
|
||||
E4,PE4
|
||||
E5,PE5
|
||||
E6,PE6
|
||||
E7,PE7
|
||||
E8,PE8
|
||||
E9,PE9
|
||||
E10,PE10
|
||||
E11,PE11
|
||||
E11,PE11
|
||||
E12,PE12
|
||||
E13,PE13
|
||||
E14,PE14
|
||||
E15,PE15
|
||||
LED_BLUE,PE3
|
||||
KEY_1,PC13
|
||||
QSPI_CS,PB6
|
||||
QSPI_CLK,PB2
|
||||
QSPI_D0,PD11
|
||||
QSPI_D1,PD12
|
||||
QSPI_D2,PE2
|
||||
QSPI_D3,PD13
|
||||
USB_DM,PA11
|
||||
USB_DP,PA12
|
||||
OSC32_IN,PC14
|
||||
OSC32_OUT,PC15
|
||||
SDIO_D0,PC8
|
||||
SDIO_D1,PC9
|
||||
SDIO_D2,PC10
|
||||
SDIO_D3,PC11
|
||||
SDIO_CMD,PD2
|
||||
SDIO_CK,PC12
|
||||
SD_SW,PD4
|
||||
OTG_FS_POWER,PD10
|
||||
OTG_FS_OVER_CURRENT,PG7
|
||||
USB_VBUS,PA9
|
||||
USB_ID,PA10
|
||||
|
@@ -0,0 +1,19 @@
|
||||
/* This file is part of the MicroPython project, http://micropython.org/
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2019 Damien P. George
|
||||
*/
|
||||
#ifndef MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
|
||||
#define MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
|
||||
|
||||
// Oscillator values in Hz
|
||||
#define HSE_VALUE (25000000)
|
||||
#define LSE_VALUE (32768)
|
||||
#define EXTERNAL_CLOCK_VALUE (12288000)
|
||||
|
||||
// Oscillator timeouts in ms
|
||||
#define HSE_STARTUP_TIMEOUT (5000)
|
||||
#define LSE_STARTUP_TIMEOUT (5000)
|
||||
|
||||
#include "boards/stm32h7xx_hal_conf_base.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32H7XX_HAL_CONF_H
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
GNU linker script for WeAct Studio STM32H743
|
||||
*/
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* sectors (0-15) */
|
||||
FLASH_APP (rx) : ORIGIN = 0x08020000, LENGTH = 1920K /* sectors (1-15) */
|
||||
FLASH_ROMFS (rx): ORIGIN = 0x90000000, LENGTH = 8192K /* external QSPI */
|
||||
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K /* Used for storage cache */
|
||||
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* AXI SRAM */
|
||||
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
|
||||
}
|
||||
|
||||
/* produce a link error if there is not this amount of RAM for these sections */
|
||||
_minimum_stack_size = 2K;
|
||||
_minimum_heap_size = 16K;
|
||||
|
||||
/* Define the stack. The stack is full descending so begins just above last byte
|
||||
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
|
||||
_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve;
|
||||
_sstack = _estack - 16K; /* tunable */
|
||||
|
||||
/* RAM extents for the garbage collector */
|
||||
_ram_start = ORIGIN(RAM);
|
||||
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
|
||||
_heap_start = _ebss; /* heap starts just after statically allocated memory */
|
||||
_heap_end = _sstack;
|
||||
|
||||
/* ROMFS location */
|
||||
_micropy_hw_romfs_part0_start = ORIGIN(FLASH_ROMFS);
|
||||
_micropy_hw_romfs_part0_size = LENGTH(FLASH_ROMFS);
|
||||
@@ -611,14 +611,9 @@ soft_reset:
|
||||
pyb_can_init0();
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_ENABLE_USB
|
||||
#if MICROPY_HW_TINYUSB_STACK
|
||||
pyb_usbd_init();
|
||||
mp_usbd_init();
|
||||
#else
|
||||
#if MICROPY_HW_STM_USB_STACK && MICROPY_HW_ENABLE_USB
|
||||
pyb_usb_init0();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_MACHINE_I2S
|
||||
machine_i2s_init0();
|
||||
@@ -690,6 +685,10 @@ soft_reset:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_TINYUSB_STACK && MICROPY_HW_ENABLE_USBDEV
|
||||
mp_usbd_init();
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_HAS_MMA7660
|
||||
// MMA accel: init and reset
|
||||
accel_init();
|
||||
|
||||
@@ -261,6 +261,7 @@
|
||||
#if MICROPY_HW_TINYUSB_STACK
|
||||
#ifndef MICROPY_HW_ENABLE_USBDEV
|
||||
#define MICROPY_HW_ENABLE_USBDEV (1)
|
||||
#define MICROPY_HW_TINYUSB_LL_INIT mp_usbd_ll_init
|
||||
#endif
|
||||
|
||||
#ifndef MICROPY_HW_USB_CDC
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// We use the ST Cube HAL library for most hardware peripherals
|
||||
#include STM32_HAL_H
|
||||
#include "pin.h"
|
||||
#include "usbd_conf.h"
|
||||
#include "py/ringbuf.h"
|
||||
#include "shared/runtime/interrupt_char.h"
|
||||
|
||||
|
||||
@@ -134,19 +134,27 @@ void rtc_init_start(bool force_init) {
|
||||
if (!force_init) {
|
||||
bool rtc_running = false;
|
||||
#if defined(STM32N6)
|
||||
// Note: the low-level boot on the N6 seems to always enable the RTC and the LSI, and
|
||||
// switch the RTC to LSI mode. So the logic below needs to account for that:
|
||||
// - if LSE is ready then switch back to the LSE
|
||||
// - even if LSI is ready, don't use it if the board is configured to use LSE
|
||||
uint32_t rtc_clock_source = LL_RCC_GetRTCClockSource();
|
||||
if (LL_RCC_IsEnabledRTC()
|
||||
&& LL_RCC_GetRTCClockSource() == LL_RCC_RTC_CLKSOURCE_LSE
|
||||
&& LL_RCC_LSE_IsReady()) {
|
||||
// LSE is enabled & ready --> no need to (re-)init RTC
|
||||
rtc_running = true;
|
||||
if (rtc_clock_source != LL_RCC_RTC_CLKSOURCE_LSE) {
|
||||
LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSE);
|
||||
}
|
||||
// remove Backup Domain write protection
|
||||
HAL_PWR_EnableBkUpAccess();
|
||||
// Clear source Reset Flag
|
||||
__HAL_RCC_CLEAR_RESET_FLAGS();
|
||||
// provide some status information
|
||||
rtc_info |= 0x40000;
|
||||
} else if (LL_RCC_IsEnabledRTC()
|
||||
&& LL_RCC_GetRTCClockSource() == LL_RCC_RTC_CLKSOURCE_LSI) {
|
||||
} else if (!rtc_use_lse
|
||||
&& LL_RCC_IsEnabledRTC()
|
||||
&& rtc_clock_source == LL_RCC_RTC_CLKSOURCE_LSI) {
|
||||
// LSI configured as the RTC clock source --> no need to (re-)init RTC
|
||||
rtc_running = true;
|
||||
// remove Backup Domain write protection
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "usbd_core.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/mphal.h"
|
||||
#include "shared/tinyusb/mp_usbd.h"
|
||||
#include "irq.h"
|
||||
#include "usb.h"
|
||||
|
||||
@@ -62,16 +63,8 @@ PCD_HandleTypeDef pcd_hs_handle;
|
||||
#define OTG_HS_IRQn USB1_OTG_HS_IRQn
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_TINYUSB_STACK
|
||||
void pyb_usbd_init(void)
|
||||
#else
|
||||
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
|
||||
#endif
|
||||
{
|
||||
#if MICROPY_HW_USB_FS
|
||||
#if MICROPY_HW_STM_USB_STACK
|
||||
if (hpcd->Instance == USB_OTG_FS)
|
||||
#endif
|
||||
#if MICROPY_HW_USB_FS
|
||||
static void mp_usbd_ll_init_fs(void) {
|
||||
{
|
||||
// Configure USB GPIO's.
|
||||
|
||||
@@ -192,17 +185,12 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_STM_USB_STACK
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // MICROPY_HW_USB_FS
|
||||
|
||||
#if MICROPY_HW_USB_HS
|
||||
#if MICROPY_HW_STM_USB_STACK
|
||||
if (hpcd->Instance == USB_OTG_HS)
|
||||
#endif
|
||||
#if MICROPY_HW_USB_HS
|
||||
static void mp_usbd_ll_init_hs(void) {
|
||||
{
|
||||
#if MICROPY_HW_USB_HS_IN_FS
|
||||
|
||||
@@ -342,10 +330,41 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
|
||||
NVIC_SetPriority(OTG_HS_IRQn, IRQ_PRI_OTG_HS);
|
||||
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
|
||||
}
|
||||
#endif // MICROPY_HW_USB_HS
|
||||
}
|
||||
#endif // MICROPY_HW_USB_HS
|
||||
|
||||
#if MICROPY_HW_TINYUSB_STACK
|
||||
|
||||
void mp_usbd_ll_init(void) {
|
||||
// Only initialize the USB hardware once.
|
||||
if (tusb_inited()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if MICROPY_HW_USB_FS
|
||||
mp_usbd_ll_init_fs();
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_USB_HS
|
||||
mp_usbd_ll_init_hs();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MICROPY_HW_STM_USB_STACK
|
||||
#elif MICROPY_HW_STM_USB_STACK
|
||||
|
||||
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
|
||||
#if MICROPY_HW_USB_FS
|
||||
if (hpcd->Instance == USB_OTG_FS) {
|
||||
mp_usbd_ll_init_fs();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_USB_HS
|
||||
if (hpcd->Instance == USB_OTG_HS) {
|
||||
mp_usbd_ll_init_hs();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the PCD MSP.
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
#define USBD_HS_NUM_FIFO (1 + USBD_HS_NUM_TX_FIFO)
|
||||
|
||||
#if MICROPY_HW_TINYUSB_STACK
|
||||
void pyb_usbd_init(void);
|
||||
void mp_usbd_ll_init(void);
|
||||
#endif
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_USBD_CONF_H
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
#define MICROPY_WRAP_TUD_EVENT_HOOK_CB(name) name
|
||||
#endif
|
||||
|
||||
#ifndef MICROPY_HW_TINYUSB_LL_INIT
|
||||
#define MICROPY_HW_TINYUSB_LL_INIT()
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_ENABLE_USBDEV
|
||||
|
||||
#include "py/obj.h"
|
||||
@@ -102,6 +106,7 @@ void mp_usbd_task_callback(mp_sched_node_t *node);
|
||||
static inline void mp_usbd_init(void) {
|
||||
// Without runtime USB support, this can be a thin wrapper wrapper around tusb_init()
|
||||
// which is called in the below helper function.
|
||||
MICROPY_HW_TINYUSB_LL_INIT();
|
||||
mp_usbd_init_tud();
|
||||
}
|
||||
|
||||
|
||||
@@ -430,6 +430,8 @@ void mp_usbd_init(void) {
|
||||
}
|
||||
|
||||
if (need_usb) {
|
||||
// Call any port-specific initialization code.
|
||||
MICROPY_HW_TINYUSB_LL_INIT();
|
||||
// The following will call tusb_init(), which is safe to call redundantly.
|
||||
mp_usbd_init_tud();
|
||||
// Reconnect if mp_usbd_deinit() has disconnected.
|
||||
|
||||
Reference in New Issue
Block a user