Skip to content

Commit 7fea970

Browse files
authored
Merge pull request #5597 from NathanY3G/add-board-sparkfun-thing-plus-stm32
Add board definition for SparkFun Thing Plus - STM32
2 parents 9166e55 + ffd41cf commit 7fea970

File tree

4 files changed

+177
-0
lines changed

4 files changed

+177
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
30+
void board_init(void) {
31+
}
32+
33+
bool board_requests_safe_mode(void) {
34+
return false;
35+
}
36+
37+
void reset_board(void) {
38+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "SparkFun Thing Plus - STM32"
30+
#define MICROPY_HW_MCU_NAME "STM32F405RG"
31+
32+
#define FLASH_SIZE (0x100000)
33+
#define FLASH_PAGE_SIZE (0x4000)
34+
35+
#define HSE_VALUE ((uint32_t)12000000U)
36+
#define LSE_VALUE ((uint32_t)32768)
37+
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
38+
39+
// On-board flash
40+
#define SPI_FLASH_MOSI_PIN (&pin_PB05)
41+
#define SPI_FLASH_MISO_PIN (&pin_PB04)
42+
#define SPI_FLASH_SCK_PIN (&pin_PB03)
43+
#define SPI_FLASH_CS_PIN (&pin_PA15)
44+
45+
// Bootloader only
46+
#ifdef UF2_BOOTLOADER_ENABLED
47+
#define BOARD_VTOR_DEFER (1) // Leave VTOR relocation to bootloader
48+
#endif
49+
50+
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
51+
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
52+
53+
#define DEFAULT_SPI_BUS_SCK (&pin_PB13)
54+
#define DEFAULT_SPI_BUS_MOSI (&pin_PB15)
55+
#define DEFAULT_SPI_BUS_MISO (&pin_PB14)
56+
57+
#define DEFAULT_UART_BUS_RX (&pin_PB11)
58+
#define DEFAULT_UART_BUS_TX (&pin_PB10)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
USB_VID = 0X1B4F
2+
USB_PID = 0x0028
3+
4+
USB_PRODUCT = "Thing Plus - STM32"
5+
USB_MANUFACTURER = "SparkFun Electronics"
6+
7+
SPI_FLASH_FILESYSTEM = 1
8+
EXTERNAL_FLASH_DEVICES = W25Q128JVxM
9+
10+
MCU_SERIES = F4
11+
MCU_VARIANT = STM32F405xx
12+
MCU_PACKAGE = LQFP64
13+
14+
LD_COMMON = boards/common_default.ld
15+
LD_DEFAULT = boards/STM32F405_default.ld
16+
17+
# UF2 boot option
18+
LD_BOOT = boards/STM32F405_boot.ld
19+
UF2_OFFSET = 0x8010000
20+
21+
CIRCUITPY_RGBMATRIX ?= 1
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include "py/objtuple.h"
2+
#include "shared-bindings/board/__init__.h"
3+
4+
STATIC const mp_rom_obj_tuple_t sdio_data_tuple = {
5+
{&mp_type_tuple},
6+
4,
7+
{
8+
MP_ROM_PTR(&pin_PC08),
9+
MP_ROM_PTR(&pin_PC09),
10+
MP_ROM_PTR(&pin_PC10),
11+
MP_ROM_PTR(&pin_PC11),
12+
}
13+
};
14+
15+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
16+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
17+
18+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) },
19+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
20+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) },
21+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) },
22+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) },
23+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) },
24+
25+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) },
26+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) },
27+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) },
28+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) },
29+
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) },
30+
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) },
31+
32+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PC01) },
33+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) },
34+
35+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) },
36+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) },
37+
38+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) },
39+
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PB14) },
40+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) },
41+
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PB15) },
42+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) },
43+
44+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) },
45+
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB10) },
46+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) },
47+
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB11) },
48+
49+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
50+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
51+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
52+
53+
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_PC12) },
54+
{ MP_ROM_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_PD02) },
55+
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA), MP_ROM_PTR(&sdio_data_tuple) },
56+
57+
{ MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_PB08) },
58+
{ MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR(&pin_PB09) },
59+
};
60+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)