Skip to content

Commit 1548929

Browse files
andrewleechpi-anl
authored andcommitted
stm32/WEACT_F411: Add WeAct F411 'blackpill' boards.
Builds for v3.1 with no SPI Flash by default. Includes variants for different board versions and spi flash sizes. Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent 1473ed4 commit 1548929

11 files changed

+262
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "storage.h"
2+
#include "spi.h"
3+
4+
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
5+
6+
#if WEACT_F411_V2
7+
// External SPI flash uses SPI interface, but not on HW spi pins.
8+
9+
static const mp_soft_spi_obj_t soft_spi_bus = {
10+
.delay_half = MICROPY_HW_SOFTSPI_MIN_DELAY,
11+
.polarity = 0,
12+
.phase = 0,
13+
.sck = MICROPY_HW_SPIFLASH_SCK,
14+
.mosi = MICROPY_HW_SPIFLASH_MOSI,
15+
.miso = MICROPY_HW_SPIFLASH_MISO,
16+
};
17+
#define
18+
19+
#else
20+
static const spi_proto_cfg_t spi_bus = {
21+
.spi = &spi_obj[0], // SPI1
22+
.baudrate = 25000000,
23+
.polarity = 0,
24+
.phase = 0,
25+
.bits = 8,
26+
.firstbit = SPI_FIRSTBIT_MSB,
27+
};
28+
#endif
29+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
30+
static mp_spiflash_cache_t spi_bdev_cache;
31+
#endif
32+
33+
const mp_spiflash_config_t spiflash_config = {
34+
.bus_kind = MP_SPIFLASH_BUS_SPI,
35+
.bus.u_spi.cs = MICROPY_HW_SPIFLASH_CS,
36+
.bus.u_spi.data = (void *)&spi_bus,
37+
.bus.u_spi.proto = &spi_proto,
38+
#if MICROPY_HW_SPIFLASH_ENABLE_CACHE
39+
.cache = &spi_bdev_cache,
40+
#endif
41+
};
42+
43+
spi_bdev_t spi_bdev;
44+
45+
#endif
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"deploy": [
3+
"../PYBV10/deploy.md"
4+
],
5+
"docs": "",
6+
"features": [],
7+
"images": [
8+
"WEACTV20_F411.jpg"
9+
],
10+
"mcu": "stm32f411",
11+
"product": "WeAct F411 'blackpill'. Default variant is v3.1 with no SPI Flash.",
12+
"thumbnail": "",
13+
"url": "https://github.com/WeActStudio/WeActStudio.MiniSTM32F4x1",
14+
"variants": {
15+
"V13": "v1.3 board with no SPI Flash",
16+
"V13_FLASH_4M": "v1.3 board with 4MB SPI Flash",
17+
"V20_FLASH_4M": "v2.0 board with 4MB SPI Flash",
18+
"V31_FLASH_8M": "v3.1 board with 8MB SPI Flash",
19+
"V31_XTAL_8M": "v3.1 board with 8MHz crystal"
20+
},
21+
"vendor": "WeAct Studio"
22+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// based off the following two repositories:
2+
// * https://github.com/mcauser/WEACT_F411CEU6
3+
// * https://github.com/YXZhu/micropython
4+
5+
#define MICROPY_HW_BOARD_NAME "WEACT_F411_BLACKPILL"
6+
#define MICROPY_HW_MCU_NAME "STM32F411CE"
7+
#define MICROPY_HW_FLASH_FS_LABEL "WEACT_F411_BLACKPILL"
8+
9+
// some users having issues with FLASH_LATENCY_2, so set to 3
10+
// from https://forum.micropython.org/viewtopic.php?t=7154
11+
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_3
12+
13+
#if WEACT_F411_V13
14+
#define MICROPY_HW_HAS_SWITCH (0)
15+
#else
16+
#define MICROPY_HW_HAS_SWITCH (1)
17+
#endif
18+
#define MICROPY_HW_HAS_FLASH (1)
19+
#define MICROPY_HW_ENABLE_RTC (1)
20+
#define MICROPY_HW_ENABLE_USB (1)
21+
22+
// HSE is 25MHz, CPU freq set to 96MHz
23+
#define MICROPY_HW_CLK_PLLM (25)
24+
#define MICROPY_HW_CLK_PLLN (192)
25+
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
26+
#define MICROPY_HW_CLK_PLLQ (4)
27+
28+
// UART config
29+
#define MICROPY_HW_UART1_TX (pin_A9)
30+
#define MICROPY_HW_UART1_RX (pin_A10)
31+
32+
#define MICROPY_HW_UART2_TX (pin_A2)
33+
#define MICROPY_HW_UART2_RX (pin_A3)
34+
35+
#define MICROPY_HW_UART_REPL PYB_UART_1
36+
#define MICROPY_HW_UART_REPL_BAUD 115200
37+
38+
// I2C bus
39+
#define MICROPY_HW_I2C1_SCL (pin_B6)
40+
#define MICROPY_HW_I2C1_SDA (pin_B7)
41+
#define MICROPY_HW_I2C2_SCL (pin_B10)
42+
#define MICROPY_HW_I2C2_SDA (pin_B9)
43+
#define MICROPY_HW_I2C3_SCL (pin_A8)
44+
#define MICROPY_HW_I2C3_SDA (pin_B8)
45+
46+
// SPI bus
47+
// SPI 1 is used for the SPI flash module if present
48+
#define MICROPY_HW_SPI1_NSS (pin_A4)
49+
#define MICROPY_HW_SPI1_SCK (pin_A5)
50+
#define MICROPY_HW_SPI1_MISO (pin_A6)
51+
#define MICROPY_HW_SPI1_MOSI (pin_A7)
52+
53+
#define MICROPY_HW_SPI2_NSS (pin_B12)
54+
#define MICROPY_HW_SPI2_SCK (pin_B13)
55+
#define MICROPY_HW_SPI2_MISO (pin_B14)
56+
#define MICROPY_HW_SPI2_MOSI (pin_B15)
57+
58+
// SPI 3 is not accessible if SPI flash module is used on V2.0 (PB4 conflict)
59+
#define MICROPY_HW_SPI3_NSS (pin_A15)
60+
#define MICROPY_HW_SPI3_SCK (pin_B3)
61+
#define MICROPY_HW_SPI3_MISO (pin_B4)
62+
#define MICROPY_HW_SPI3_MOSI (pin_B5)
63+
64+
// Switch
65+
#if !WEACT_F411_V13
66+
#define MICROPY_HW_USRSW_PIN (pyb_pin_SW)
67+
#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
68+
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
69+
#define MICROPY_HW_USRSW_PRESSED (0)
70+
#endif
71+
72+
// LEDs
73+
#define MICROPY_HW_LED1 (pyb_pin_LED_BLUE)
74+
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
75+
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
76+
77+
#define MICROPY_HW_RTC_USE_LSE (1)
78+
#define MICROPY_HW_RTC_USE_US (0)
79+
#define MICROPY_HW_RTC_USE_CALOUT (1)
80+
81+
// External SPI Flash configuration
82+
#if !MICROPY_HW_SPIFLASH_SIZE_BYTES
83+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
84+
#else
85+
86+
// Disable internal filesystem to use spiflash.
87+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
88+
89+
// SPI flash pins
90+
#define MICROPY_HW_SPIFLASH_CS (pyb_pin_FLASH_CS)
91+
#define MICROPY_HW_SPIFLASH_SCK (pyb_pin_FLASH_SCK)
92+
#define MICROPY_HW_SPIFLASH_MOSI (pyb_pin_FLASH_MOSI)
93+
#if WEACT_F411_V13
94+
#define MICROPY_HW_SPIFLASH_MISO (pyb_pin_FLASH_MISO_V13)
95+
#elif WEACT_F411_V2
96+
#define MICROPY_HW_SPIFLASH_MISO (pyb_pin_FLASH_MISO_V20)
97+
#else
98+
#define MICROPY_HW_SPIFLASH_MISO (pyb_pin_FLASH_MISO_V31)
99+
#endif
100+
101+
extern const struct _mp_spiflash_config_t spiflash_config;
102+
extern struct _spi_bdev_t spi_bdev;
103+
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
104+
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
105+
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
106+
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
107+
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
108+
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
109+
#endif
110+
111+
// USB config
112+
#define MICROPY_HW_USB_FS (1)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MCU_SERIES = f4
2+
CMSIS_MCU = STM32F411xE
3+
AF_FILE = boards/stm32f411_af.csv
4+
LD_FILES = boards/stm32f411.ld boards/common_ifs.ld
5+
TEXT0_ADDR = 0x08000000
6+
TEXT1_ADDR = 0x08020000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CFLAGS += -DWEACT_F411_V13=1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CFLAGS += \
2+
-DWEACT_F411_V13=1 \
3+
-DMICROPY_HW_SPIFLASH_SIZE_BYTES="(4 * 1024 * 1024)"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CFLAGS += \
2+
-DWEACT_F411_V20=1 \
3+
-DMICROPY_HW_SPIFLASH_SIZE_BYTES="(4 * 1024 * 1024)"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CFLAGS += -DMICROPY_HW_SPIFLASH_SIZE_BYTES="(8 * 1024 * 1024)"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CFLAGS += -DMICROPY_HW_HSE_VALUE="(8000000)"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
PA0,PA0
2+
PA1,PA1
3+
PA2,PA2
4+
PA3,PA3
5+
PA4,PA4
6+
PA5,PA5
7+
PA6,PA6
8+
PA7,PA7
9+
PA8,PA8
10+
PA9,PA9
11+
PA10,PA10
12+
PA11,PA11
13+
PA12,PA12
14+
PA15,PA15
15+
PB0,PB0
16+
PB1,PB1
17+
PB2,PB2
18+
PB3,PB3
19+
PB4,PB4
20+
PB5,PB5
21+
PB6,PB6
22+
PB7,PB7
23+
PB8,PB8
24+
PB9,PB9
25+
PB10,PB10
26+
PB12,PB12
27+
PB13,PB13
28+
PB14,PB14
29+
PB15,PB15
30+
PC14,PC14
31+
PC15,PC15
32+
LED_BLUE,PC13
33+
SW,PA0
34+
-SWDIO,PA13
35+
-SWCLK,PA14
36+
-OSC32_IN,PH0
37+
-OSC32_OUT,PH1
38+
-USB_DM,PA11
39+
-USB_DP,PA12
40+
-FLASH_CS,PA4
41+
-FLASH_SCK,PA5
42+
-FLASH_MOSI,PA7
43+
-FLASH_MISO_V13,PA6
44+
-FLASH_MISO_V20,PB4
45+
-FLASH_MISO_V31,PA6

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy