forked from WeActStudio/WeAct_F411CE-MicroPython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpconfigboard.h
135 lines (106 loc) · 5.23 KB
/
mpconfigboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#define MICROPY_HW_BOARD_NAME "WeAct Studio Core"
#define MICROPY_HW_MCU_NAME "STM32F411CE"
/* 启用 THREAD */
#define MICROPY_PY_THREAD (1)
#define MICROPY_BOARD_EARLY_INIT WeAct_Core_board_early_init
void WeAct_Core_board_early_init(void);
/* BOARD Ver 2.0 set 1 ,other set 0 ex.V1.3,V2.1 */
#define VERSION_V20 (0)
/* 使用内置flash改1 使用外置flash改0 */
/* Use the built-in flash to change to 1
use the external flash to change to 0 */
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
#define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_FLASH (1)
#define MICROPY_HW_ENABLE_RTC (1)
#define MICROPY_HW_ENABLE_USB (1)
#define MICROPY_HW_ENABLE_ADC (1)
#define MICROPY_HW_ENABLE_SERVO (1)
#define MICROPY_HW_ENABLE_SDCARD (0)
#define MICROPY_HW_ENABLE_RNG (0)
#define MICROPY_HW_ENABLE_DAC (0)
// HSE is 25MHz, CPU freq set to 96MHz
#define MICROPY_HW_CLK_PLLM (25)
#define MICROPY_HW_CLK_PLLN (192)
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
#define MICROPY_HW_CLK_PLLQ (4)
// UART config
#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_UART6_TX (pin_A11)
#define MICROPY_HW_UART6_RX (pin_A12)
// #define MICROPY_HW_UART_REPL PYB_UART_1
// #define MICROPY_HW_UART_REPL_BAUD 115200
// I2C busses
#define MICROPY_HW_I2C1_SCL (pin_B6) // Arduino D15, pin 3 on CN10
#define MICROPY_HW_I2C1_SDA (pin_B7) // D14, pin 5 on CN10
#define MICROPY_HW_I2C2_SCL (pin_B10) // Arduino D6, pin 25 on CN10
#define MICROPY_HW_I2C2_SDA (pin_B9) // Arduino D3, pin 31 on CN10
#define MICROPY_HW_I2C3_SCL (pin_A8) // Arduino D7, pin 23 on CN10
#define MICROPY_HW_I2C3_SDA (pin_B8) // pin 1 on CN10
// SPI busses
#define MICROPY_HW_SPI1_NSS (pin_A4) // pin 17 on CN7
#define MICROPY_HW_SPI1_SCK (pin_A5) // Arduino D13, pin 11 on CN10
#define MICROPY_HW_SPI1_MISO (pin_A6) // Arduino D12, pin 13 on CN10
#define MICROPY_HW_SPI1_MOSI (pin_A7) // Arduino D11, pin 15 on CN10
#define MICROPY_HW_SPI2_NSS (pin_B12) // pin 16 on CN10
#define MICROPY_HW_SPI2_SCK (pin_B13) // pin 30 on CN10
#define MICROPY_HW_SPI2_MISO (pin_B14) // pin 28 on CN10
#define MICROPY_HW_SPI2_MOSI (pin_B15) // pin 26 on CN10
#define MICROPY_HW_SPI3_NSS (pin_A15) // Arduino A2, pin 32 on CN7
#define MICROPY_HW_SPI3_SCK (pin_B3) // Arduino D3, pin 31 on CN10
#define MICROPY_HW_SPI3_MISO (pin_B4) // Arduino D5, pin 27 on CN10
#define MICROPY_HW_SPI3_MOSI (pin_B5) // Arduino D4, pin 29 on CN10
#define MICROPY_HW_SPI4_NSS (pin_B12) // pin 16 on CN10
#define MICROPY_HW_SPI4_SCK (pin_B13) // pin 30 on CN10
#define MICROPY_HW_SPI4_MISO (pin_A1) // pin 30 on CN7
#define MICROPY_HW_SPI4_MOSI (pin_A11) // pin 14 on CN10
#define MICROPY_HW_SPI5_NSS (pin_B1) // pin 24 on CN10
#define MICROPY_HW_SPI5_SCK (pin_A10) // pin 33 on CN10
#define MICROPY_HW_SPI5_MISO (pin_A12) // pin 12 on CN10
#define MICROPY_HW_SPI5_MOSI (pin_B0) // pin 34 on CN7
// USRSW is pulled low. Pressing the button makes the input go high.
#define MICROPY_HW_USRSW_PIN (pin_A0)
#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
#define MICROPY_HW_USRSW_PRESSED (0)
// LEDs
#define MICROPY_HW_LED1 (pin_C13) // Blue C13 LED on board
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_low(pin))
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_high(pin))
// The pyboard has a 32.768kHz crystal for the RTC
#define MICROPY_HW_RTC_USE_LSE (1)
#define MICROPY_HW_RTC_USE_US (0)
#define MICROPY_HW_RTC_USE_CALOUT (1)
// use external SPI flash for storage
// 4MB Flash 32Mbit
// 8MB Flash 64Mbit
// 16MB Flash 128Mbit
#define MICROPY_HW_SPIFLASH_SIZE_BITS (32 * 1024 * 1024)
#define MICROPY_HW_SPIFLASH_CS (pin_A4)
#define MICROPY_HW_SPIFLASH_SCK (pin_A5)
#if VERSION_V20
#define MICROPY_HW_SPIFLASH_MISO (pin_B4)
#else
#define MICROPY_HW_SPIFLASH_MISO (pin_A6)
#endif
#define MICROPY_HW_SPIFLASH_MOSI (pin_A7)
// 使用外置spi flash
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
extern const struct _mp_spiflash_config_t spiflash_config;
extern struct _spi_bdev_t spi_bdev;
#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_SPIFLASH_SIZE_BITS / 8 / FLASH_BLOCK_SIZE) : \
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \
spi_bdev_ioctl(&spi_bdev, (op), (arg)) \
)
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n))
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n))
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
#endif
// USB config
#define MICROPY_HW_USB_FS (1)
#define MICROPY_HW_FLASH_FS_LABEL "WeActF411CE"