Skip to content

Commit 4e4ecaf

Browse files
committed
Add definitions for PYB Nano and blackpill
1 parent 13d786b commit 4e4ecaf

File tree

12 files changed

+100
-94
lines changed

12 files changed

+100
-94
lines changed

ports/stm32f4/boards/pyb_nano_v2/mpconfigboard.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,21 @@
2727
//Micropython setup
2828

2929
#define MICROPY_HW_BOARD_NAME "PYB LR Nano V2"
30-
#define MICROPY_HW_MCU_NAME "STM32F405RG"
30+
#define MICROPY_HW_MCU_NAME "STM32F411CE"
3131

32-
#define FLASH_SIZE (0x100000)
32+
#define FLASH_SIZE (0x80000)
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

35-
#define AUTORESET_DELAY_MS 500
36-
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
35+
#define BOARD_OSC_DIV 8
3736

3837
// On-board flash
39-
#define SPI_FLASH_MOSI_PIN &pin_PB05
40-
#define SPI_FLASH_MISO_PIN &pin_PB04
41-
#define SPI_FLASH_SCK_PIN &pin_PB03
42-
#define SPI_FLASH_CS_PIN &pin_PA15
38+
#define SPI_FLASH_MOSI_PIN (&pin_PB15)
39+
#define SPI_FLASH_MISO_PIN (&pin_PB14)
40+
#define SPI_FLASH_SCK_PIN (&pin_PB13)
41+
#define SPI_FLASH_CS_PIN (&pin_PB12)
4342

44-
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
45-
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
43+
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
4644

47-
#define DEFAULT_SPI_BUS_SCK (&pin_PB13)
48-
#define DEFAULT_SPI_BUS_MOSI (&pin_PB15)
49-
#define DEFAULT_SPI_BUS_MISO (&pin_PB14)
45+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000)
5046

51-
#define DEFAULT_UART_BUS_RX (&pin_PB11)
52-
#define DEFAULT_UART_BUS_TX (&pin_PB10)
47+
#define AUTORESET_DELAY_MS 500
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
USB_VID = 0x239A
22
USB_PID = 0x805A
3-
USB_PRODUCT = "Feather STM32F405 Express"
4-
USB_MANUFACTURER = "Adafruit Industries LLC"
3+
USB_PRODUCT = "PYB LR Nano V2"
4+
USB_MANUFACTURER = "MicroPython Chinese Community"
55
USB_DEVICES = "CDC,MSC"
66

77
SPI_FLASH_FILESYSTEM = 1
88
EXTERNAL_FLASH_DEVICE_COUNT = 1
9-
EXTERNAL_FLASH_DEVICES = GD25Q16C
9+
EXTERNAL_FLASH_DEVICES = W25Q64JV_IQ
1010
LONGINT_IMPL = MPZ
1111

1212
MCU_SERIES = m4
1313
MCU_VARIANT = stm32f4
14-
MCU_SUB_VARIANT = stm32f405xx
15-
MCU_PACKAGE = 64
16-
CMSIS_MCU = STM32F405xx
17-
LD_FILE = boards/STM32F405.ld
14+
MCU_SUB_VARIANT = stm32f411xe
15+
MCU_PACKAGE = 48
16+
CMSIS_MCU = STM32F411xE
17+
LD_FILE = boards/STM32F411VETx_FLASH.ld
1818
TEXT0_ADDR = 0x08000000
19-
TEXT1_ADDR = 0x08010000
19+
TEXT1_ADDR = 0x08020000

ports/stm32f4/boards/pyb_nano_v2/pins.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,30 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
3030
{ MP_ROM_QSTR(MP_QSTR_X1), MP_ROM_PTR(&pin_PA01) },
3131
{ MP_ROM_QSTR(MP_QSTR_X0), MP_ROM_PTR(&pin_PA00) },
3232

33-
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) },
34-
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) },
33+
{ MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PB09) },
34+
{ MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PB08) },
35+
{ MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PB03) },
36+
{ MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_PB10) },
37+
{ MP_ROM_QSTR(MP_QSTR_SDA3), MP_ROM_PTR(&pin_PB04) },
38+
{ MP_ROM_QSTR(MP_QSTR_SCL3), MP_ROM_PTR(&pin_PA08) },
3539

36-
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) },
37-
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) },
38-
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) },
40+
{ MP_ROM_QSTR(MP_QSTR_SCK1), MP_ROM_PTR(&pin_PA05) },
41+
{ MP_ROM_QSTR(MP_QSTR_MISO1), MP_ROM_PTR(&pin_PA06) },
42+
{ MP_ROM_QSTR(MP_QSTR_MOSI1), MP_ROM_PTR(&pin_PA07) },
43+
{ MP_ROM_QSTR(MP_QSTR_SCK2), MP_ROM_PTR(&pin_PB13) },
44+
{ MP_ROM_QSTR(MP_QSTR_MISO2), MP_ROM_PTR(&pin_PB14) },
45+
{ MP_ROM_QSTR(MP_QSTR_MOSI2), MP_ROM_PTR(&pin_PB15) },
3946

40-
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) },
41-
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) },
47+
{ MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB07) },
48+
{ MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB06) },
49+
{ MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA02) },
50+
{ MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA03) },
4251

43-
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
44-
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
45-
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
52+
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PA00) },
53+
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PA01) },
54+
{ MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_PA02) },
55+
{ MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_PA03) },
56+
57+
{ MP_ROM_QSTR(MP_QSTR_SW), MP_ROM_PTR(&pin_PC13) },
4658
};
4759
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/stm32f4/boards/pyb_nano_v2/stm32f4xx_hal_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
* (when HSE is used as system clock source, directly or through the PLL).
9494
*/
9595
#if !defined (HSE_VALUE)
96-
#define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */
96+
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
9797
#endif /* HSE_VALUE */
9898

9999
#if !defined (HSE_STARTUP_TIMEOUT)

ports/stm32f4/boards/stm32f411ce_blackpill/mpconfigboard.h

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,16 @@
2626

2727
//Micropython setup
2828

29-
#define MICROPY_HW_BOARD_NAME "Feather STM32F405 Express"
30-
#define MICROPY_HW_MCU_NAME "STM32F405RG"
29+
#define MICROPY_HW_BOARD_NAME "stm32f411ce-blackpill"
30+
#define MICROPY_HW_MCU_NAME "STM32F411CE"
3131

32-
#define FLASH_SIZE (0x100000)
32+
#define FLASH_SIZE (0x80000)
3333
#define FLASH_PAGE_SIZE (0x4000)
3434

35-
#define AUTORESET_DELAY_MS 500
36-
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
37-
38-
// On-board flash
39-
#define SPI_FLASH_MOSI_PIN &pin_PB05
40-
#define SPI_FLASH_MISO_PIN &pin_PB04
41-
#define SPI_FLASH_SCK_PIN &pin_PB03
42-
#define SPI_FLASH_CS_PIN &pin_PA15
35+
#define BOARD_OSC_DIV 25
4336

44-
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
45-
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
37+
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
4638

47-
#define DEFAULT_SPI_BUS_SCK (&pin_PB13)
48-
#define DEFAULT_SPI_BUS_MOSI (&pin_PB15)
49-
#define DEFAULT_SPI_BUS_MISO (&pin_PB14)
39+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000)
5040

51-
#define DEFAULT_UART_BUS_RX (&pin_PB11)
52-
#define DEFAULT_UART_BUS_TX (&pin_PB10)
41+
#define AUTORESET_DELAY_MS 500
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
USB_VID = 0x239A
22
USB_PID = 0x805A
3-
USB_PRODUCT = "Feather STM32F405 Express"
4-
USB_MANUFACTURER = "Adafruit Industries LLC"
3+
USB_PRODUCT = "stm32f411ce-blackpill"
4+
USB_MANUFACTURER = "Unknown"
55
USB_DEVICES = "CDC,MSC"
66

7-
SPI_FLASH_FILESYSTEM = 1
8-
EXTERNAL_FLASH_DEVICE_COUNT = 1
9-
EXTERNAL_FLASH_DEVICES = GD25Q16C
10-
LONGINT_IMPL = MPZ
7+
INTERNAL_FLASH_FILESYSTEM = 1
8+
LONGINT_IMPL = NONE
119

1210
MCU_SERIES = m4
1311
MCU_VARIANT = stm32f4
14-
MCU_SUB_VARIANT = stm32f405xx
15-
MCU_PACKAGE = 64
16-
CMSIS_MCU = STM32F405xx
17-
LD_FILE = boards/STM32F405.ld
12+
MCU_SUB_VARIANT = stm32f411xe
13+
MCU_PACKAGE = 48
14+
CMSIS_MCU = STM32F411xE
15+
LD_FILE = boards/STM32F411VETx_FLASH.ld
1816
TEXT0_ADDR = 0x08000000
19-
TEXT1_ADDR = 0x08010000
17+
TEXT1_ADDR = 0x08020000
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
#include "shared-bindings/board/__init__.h"
22

33
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4-
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) },
5-
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
6-
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) },
7-
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) },
8-
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) },
9-
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) },
4+
{ MP_ROM_QSTR(MP_QSTR_B12), MP_ROM_PTR(&pin_PB12) },
5+
{ MP_ROM_QSTR(MP_QSTR_B13), MP_ROM_PTR(&pin_PB13) },
6+
{ MP_ROM_QSTR(MP_QSTR_B14), MP_ROM_PTR(&pin_PB14) },
7+
{ MP_ROM_QSTR(MP_QSTR_B15), MP_ROM_PTR(&pin_PB15) },
8+
{ MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA08) },
9+
{ MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) },
10+
{ MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) },
11+
{ MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PA11) },
12+
{ MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_PA12) },
13+
{ MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_PA15) },
14+
{ MP_ROM_QSTR(MP_QSTR_B3), MP_ROM_PTR(&pin_PB03) },
15+
{ MP_ROM_QSTR(MP_QSTR_B4), MP_ROM_PTR(&pin_PB04) },
16+
{ MP_ROM_QSTR(MP_QSTR_B5), MP_ROM_PTR(&pin_PB05) },
17+
{ MP_ROM_QSTR(MP_QSTR_B6), MP_ROM_PTR(&pin_PB06) },
18+
{ MP_ROM_QSTR(MP_QSTR_B7), MP_ROM_PTR(&pin_PB07) },
19+
{ MP_ROM_QSTR(MP_QSTR_B8), MP_ROM_PTR(&pin_PB08) },
20+
{ MP_ROM_QSTR(MP_QSTR_B9), MP_ROM_PTR(&pin_PB09) },
1021

11-
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) },
12-
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) },
13-
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) },
14-
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) },
15-
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) },
16-
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) },
17-
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) },
18-
19-
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) },
20-
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) },
21-
22-
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) },
23-
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) },
24-
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) },
25-
26-
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) },
27-
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) },
28-
29-
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
30-
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
31-
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
22+
{ MP_ROM_QSTR(MP_QSTR_B10), MP_ROM_PTR(&pin_PB10) },
23+
{ MP_ROM_QSTR(MP_QSTR_B2), MP_ROM_PTR(&pin_PB02) },
24+
{ MP_ROM_QSTR(MP_QSTR_B1), MP_ROM_PTR(&pin_PB01) },
25+
{ MP_ROM_QSTR(MP_QSTR_B0), MP_ROM_PTR(&pin_PB00) },
26+
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) },
27+
{ MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) },
28+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA05) },
29+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) },
30+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA03) },
31+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA02) },
32+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) },
33+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00) },
34+
{ MP_ROM_QSTR(MP_QSTR_C15), MP_ROM_PTR(&pin_PC15) },
35+
{ MP_ROM_QSTR(MP_QSTR_C14), MP_ROM_PTR(&pin_PC14) },
36+
{ MP_ROM_QSTR(MP_QSTR_C13), MP_ROM_PTR(&pin_PC13) },
3237
};
3338
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/stm32f4/boards/stm32f411ce_blackpill/stm32f4xx_hal_conf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
/* #define HAL_IRDA_MODULE_ENABLED */
6868
/* #define HAL_SMARTCARD_MODULE_ENABLED */
6969
/* #define HAL_WWDG_MODULE_ENABLED */
70-
#define HAL_PCD_MODULE_ENABLED
70+
/* #define HAL_PCD_MODULE_ENABLED */
7171
/* #define HAL_HCD_MODULE_ENABLED */
7272
/* #define HAL_DSI_MODULE_ENABLED */
7373
/* #define HAL_QSPI_MODULE_ENABLED */
@@ -93,7 +93,7 @@
9393
* (when HSE is used as system clock source, directly or through the PLL).
9494
*/
9595
#if !defined (HSE_VALUE)
96-
#define HSE_VALUE ((uint32_t)12000000) /*!< Value of the External oscillator in Hz */
96+
#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
9797
#endif /* HSE_VALUE */
9898

9999
#if !defined (HSE_STARTUP_TIMEOUT)

ports/stm32f4/boards/stm32f411ve_discovery/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define FLASH_SIZE (0x80000) //512K
3333
#define FLASH_PAGE_SIZE (0x4000) //16K
3434

35+
#define BOARD_OSC_DIV 8
36+
3537
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
3638

3739
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000)

ports/stm32f4/common-hal/microcontroller/Pin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ bool neopixel_in_use;
4646
#elif MCU_PACKAGE == 64
4747
#define GPIO_PORT_COUNT 3
4848
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC};
49+
#elif MCU_PACKAGE == 48
50+
#define GPIO_PORT_COUNT 3
51+
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC};
4952
#endif
5053

54+
5155
STATIC uint16_t claimed_pins[GPIO_PORT_COUNT];
5256
STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT];
5357

0 commit comments

Comments
 (0)