Skip to content
2 changes: 1 addition & 1 deletion ports/esp32s2/esp-idf
29 changes: 19 additions & 10 deletions ports/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ CFLAGS += -Wno-undef -Wno-shadow -Wno-cast-align $(ADD_CFLAGS)
CFLAGS += -mthumb -mabi=aapcs-linux

# Arm core selection
MCU_FLAGS_F1 = -mcpu=cortex-m3
MCU_FLAGS_F4 = -mcpu=cortex-m4
MCU_FLAGS_F7 = -mcpu=cortex-m7
MCU_FLAGS_H7 = -mcpu=cortex-m7
Expand All @@ -119,11 +120,12 @@ CFLAGS += -DSTM32_HAL_H='<stm32$(MCU_SERIES_LOWER)xx_hal.h>'
CFLAGS += -DSTM32_SERIES_LOWER='"stm32$(MCU_SERIES_LOWER)"'

# Floating point settings
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx))
CFLAGS += -mfpu=fpv5-d16 -mfloat-abi=hard
else
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
endif
# ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx))
# CFLAGS += -mfpu=fpv5-d16 -mfloat-abi=hard
# else
# CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
# endif
CFLAGS += $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# Need both command and valid file to use uf2 bootloader
ifndef LD_FILE
Expand Down Expand Up @@ -166,19 +168,14 @@ SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\
hal_dac.c \
hal_dac_ex.c \
hal_dma.c \
hal_dma_ex.c \
hal_exti.c \
hal_flash.c \
hal_flash_ex.c \
hal_gpio.c \
hal_i2c.c \
hal_i2c_ex.c \
hal_pwr.c \
hal_pwr_ex.c \
hal_qspi.c \
hal_rcc.c \
hal_rcc_ex.c \
hal_rng.c \
hal_rtc.c \
hal_rtc_ex.c \
hal_sd.c \
Expand All @@ -198,6 +195,17 @@ SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\
ll_utils.c \
)

# The F103 lacks some modules we normally make use of
ifeq ($(MCU_SERIES_LOWER),$(filter $(MCU_SERIES_LOWER),f4 f7 h7))
SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\
hal_dma_ex.c \
hal_i2c_ex.c \
hal_pwr_ex.c \
hal_qspi.c \
hal_rng.c \
)
endif

ifeq ($(CIRCUITPY_CANIO),1)
SRC_STM32 += $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_hal_can.c
endif
Expand Down Expand Up @@ -237,6 +245,7 @@ SRC_C += \

ifneq ($(USB),FALSE)
SRC_C += lib/tinyusb/src/portable/st/synopsys/dcd_synopsys.c
SRC_C += lib/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
endif

SRC_S = \
Expand Down
26 changes: 26 additions & 0 deletions ports/stm/boards/STM32F103xe_fs.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
GNU linker script for STM32F103 with filesystem
*/

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* bigger than it needs to be, but matches other SoCs */
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 112K
FLASH_FIRMWARE (rx) : ORIGIN = 0x08020000, LENGTH = 384K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 24K;
_minimum_heap_size = 16K;

/* Define tho top end of 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);

/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
38 changes: 38 additions & 0 deletions ports/stm/boards/stm103re_apm/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "boards/board.h"

void board_init(void) {
}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {

}
35 changes: 35 additions & 0 deletions ports/stm/boards/stm103re_apm/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

//Micropython setup

#define MICROPY_HW_BOARD_NAME "stm103re_apm"
#define MICROPY_HW_MCU_NAME "STM32F103ZE"

#define HSE_VALUE ((uint32_t)12000000)
#define LSE_VALUE ((uint32_t)32768)
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
#define BOARD_NO_VBUS_SENSE (1)
13 changes: 13 additions & 0 deletions ports/stm/boards/stm103re_apm/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
USB_VID = 0x239A
USB_PID = 0x805C
USB_PRODUCT = "APM32F103ze"
USB_MANUFACTURER = "ApexMIC"

INTERNAL_FLASH_FILESYSTEM = 1

MCU_SERIES = F1
MCU_VARIANT = STM32F103xE
MCU_PACKAGE = LQFP144

LD_COMMON = boards/common_default.ld
LD_FILE = boards/STM32F103xe_fs.ld
52 changes: 52 additions & 0 deletions ports/stm/boards/stm103re_apm/pins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "shared-bindings/board/__init__.h"

STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_Y1), MP_ROM_PTR(&pin_PC06) },
{ MP_ROM_QSTR(MP_QSTR_Y2), MP_ROM_PTR(&pin_PC07) },
{ MP_ROM_QSTR(MP_QSTR_Y3), MP_ROM_PTR(&pin_PB08) },
{ MP_ROM_QSTR(MP_QSTR_Y4), MP_ROM_PTR(&pin_PB09) },
{ MP_ROM_QSTR(MP_QSTR_Y5), MP_ROM_PTR(&pin_PB12) },
{ MP_ROM_QSTR(MP_QSTR_Y6), MP_ROM_PTR(&pin_PB13) },
{ MP_ROM_QSTR(MP_QSTR_Y7), MP_ROM_PTR(&pin_PB14) },
{ MP_ROM_QSTR(MP_QSTR_Y8), MP_ROM_PTR(&pin_PB15) },
{ MP_ROM_QSTR(MP_QSTR_Y9), MP_ROM_PTR(&pin_PB10) },
{ MP_ROM_QSTR(MP_QSTR_Y10), MP_ROM_PTR(&pin_PB11) },
{ MP_ROM_QSTR(MP_QSTR_Y11), MP_ROM_PTR(&pin_PB00) },
{ MP_ROM_QSTR(MP_QSTR_Y12), MP_ROM_PTR(&pin_PB01) },

{ MP_ROM_QSTR(MP_QSTR_X1), MP_ROM_PTR(&pin_PA00) },
{ MP_ROM_QSTR(MP_QSTR_X2), MP_ROM_PTR(&pin_PA01) },
{ MP_ROM_QSTR(MP_QSTR_X3), MP_ROM_PTR(&pin_PA02) },
{ MP_ROM_QSTR(MP_QSTR_X4), MP_ROM_PTR(&pin_PA03) },
{ MP_ROM_QSTR(MP_QSTR_X5), MP_ROM_PTR(&pin_PA04) },
{ MP_ROM_QSTR(MP_QSTR_X6), MP_ROM_PTR(&pin_PA05) },
{ MP_ROM_QSTR(MP_QSTR_X7), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_X8), MP_ROM_PTR(&pin_PA07) },
{ MP_ROM_QSTR(MP_QSTR_X9), MP_ROM_PTR(&pin_PB06) },
{ MP_ROM_QSTR(MP_QSTR_X10), MP_ROM_PTR(&pin_PB07) },
{ MP_ROM_QSTR(MP_QSTR_X11), MP_ROM_PTR(&pin_PC04) },
{ MP_ROM_QSTR(MP_QSTR_X12), MP_ROM_PTR(&pin_PC05) },

{ MP_ROM_QSTR(MP_QSTR_X17), MP_ROM_PTR(&pin_PB03) },
{ MP_ROM_QSTR(MP_QSTR_X18), MP_ROM_PTR(&pin_PC13) },
{ MP_ROM_QSTR(MP_QSTR_X19), MP_ROM_PTR(&pin_PC00) },
{ MP_ROM_QSTR(MP_QSTR_X20), MP_ROM_PTR(&pin_PC01) },
{ MP_ROM_QSTR(MP_QSTR_X21), MP_ROM_PTR(&pin_PC02) },
{ MP_ROM_QSTR(MP_QSTR_X22), MP_ROM_PTR(&pin_PC03) },

{ MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_PB04) },
{ MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PA15) },
{ MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PA14) },
{ MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PA13) },

{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PB04) },
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PA15) },
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PA14) },
{ MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PA13) },

{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) },

{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Loading