Koduino
|
This guide is a work in progress
The steps below are cumulative. For example, if you need to do a type 3 port, you would also need to do steps 1-2. Consequently, it is the easiest to do port to a different package for an existing chip.
The STM32 chip part numbers are of the form:
STM32|<CHIP_ID>|<PACKAGE>|<FLASH_SIZE>
For example, for STM32F405RG
: CHIP_ID = F405
, PACKAGE = R
, FLASH_SIZE = G
In the language of the Koduino libraries (and the Arduino 1.5+ hardware spec) there are only "variants". Some variants and (a non-exclusive list of) chips that fall under it are listed below:
Variant (in Koduino libraries) | Series | MCU | Chip IDs |
---|---|---|---|
f301 | STM32F30x | STM32F302x8 | F301, F302 |
f303v | STM32F30x | STM32F303xC | F303V |
f37x | STM32F37x | STM32F37x | F373, F378 |
f446 | STM32F4xx | STM32F446xx | F446V |
f40_41x | STM32F4xx | STM32F40_41xxx | F405, F407, F417 |
f10x (not working yet) | - | - | |
f411 (not working yet) | STM32F4xx | STM32F411xE | F411 |
f429_439 (not working yet) | STM32F4xx | STM32F429_439xx | F429, F439 |
Choose:
A variant corresponds to a subdirectory of koduino/variants
. You need a new variant in the following cases:
Unfortunately, which pins are able use analogRead
, which timers need to be activated for analogWrite
needs to be manually set up for a new chip.
I find that this process is made easier with spreadsheets, examples of which are in the table below:
Variant | Pin map | Timer map |
---|---|---|
f37x (done manually) | - | - |
f40_41x | f40_41x_PIN_MAP | f40_41x_TIMER_MAP |
f411 (needs to be checked) | f411_PIN_MAP | f411_TIMER_MAP |
f10x (in progress) | f10x_PIN_MAP | f10x_TIMER_MAP |
Follow these steps:
variant_codegen.py
in the variants
directory which prints out C code that can be pasted into variant.cpp
and variant.h
USART_MAP
TIMEBASE_MAP
configures timers used for attachTimerInterrupt. At least one of them must be configured for the system clock (millis()
, micros()
, delay()
will not work otherwise).SYSCLK_TIMEBASE
to the array index into TIMEBASE_MAP
that should be the system clock. The actual timer peripheral that should be used (can be a basic timer, per ST datasheet) is configured in the first section of variantInit()
.stm32fxxx_it.c
. At a minimum, make sure that the system clock ISR is pointing to the correct timer. For an example, please see an existing variant such as f37x
or f40_41x
.Need new startup .S file