|
| 1 | +# Compiling the ST Standard Peripheral Library SPL |
| 2 | + |
| 3 | + |
| 4 | +all of this might be moved to this location at a later stage of the project: |
| 5 | +hardware/tools/stm8/STM8S_StdPeriph_Driver |
| 6 | + |
| 7 | + |
| 8 | +## STM8S903 and STM8AF622x |
| 9 | + |
| 10 | +The definitions for these two (uncommon) CPUs are flawed in the original |
| 11 | +versions of the SPL. `inc/stm8s.h` needs |
| 12 | +[this patch](correct_stm8s908.patch) if you start from |
| 13 | +scratch with the stock SPL files from the ST website. |
| 14 | + |
| 15 | + |
| 16 | +## Supported CPUs |
| 17 | + |
| 18 | +The script in `tools/showdeps.sh` lists the known CPU names defined in |
| 19 | +inc/stm8s.h. Some CPUs use identical libraries: |
| 20 | + |
| 21 | +Product line | supported CPU types per library |
| 22 | +---------------------------------- | --------------------------- |
| 23 | +| Low density devices | STM8S003, STM8S103 |
| 24 | +| Medium density devices | STM8S005, STM8S105, STM8AF626x |
| 25 | +| High density devices without CAN | STM8S007, STM8S207, STM8AF62Ax |
| 26 | +| High density devices with CAN | STM8S208, STM8AF52Ax |
| 27 | +| App. specific low density devices | STM8S903 |
| 28 | +| | STM8AF622x |
| 29 | + |
| 30 | + |
| 31 | +Supported peripherie for the different CPUs: |
| 32 | + |
| 33 | +CPU |STM8S003|STM8S005 |STM8S007 |STM8S208 |STM8S903 | |
| 34 | + |STM8S103|STM8S105 |STM8S207 | | | |
| 35 | +Module | |STM8AF626x|STM8AF62Ax |STM8AF52Ax| |STM8AF622x |
| 36 | +------ |:-----:|:------: |:------: |:------: |:------: | |
| 37 | +stm8s_adc1.c|+ |+ | | |+ |+ |
| 38 | +stm8s_adc2.c| | |+ |+ | | |
| 39 | +stm8s_awu.c|+ |+ |+ |+ |+ |+ |
| 40 | +stm8s_beep.c|+ |+ |+ |+ |+ |+ |
| 41 | +stm8s_can.c| | | |+ | | |
| 42 | +stm8s_clk.c|+ |+ |+ |+ |+ |+ |
| 43 | +stm8s_exti.c|+ |+ |+ |+ |+ |+ |
| 44 | +stm8s_flash.c|+ |+ |+ |+ |+ |+ |
| 45 | +stm8s_gpio.c|+ |+ |+ |+ |+ |+ |
| 46 | +stm8s_i2c.c|+ |+ |+ |+ |+ |+ |
| 47 | +stm8s_itc.c|+ |+ |+ |+ |+ |+ |
| 48 | +stm8s_iwdg.c|+ |+ |+ |+ |+ |+ |
| 49 | +stm8s_rst.c|+ |+ |+ |+ |+ |+ |
| 50 | +stm8s_spi.c|+ |+ |+ |+ |+ |+ |
| 51 | +stm8s_tim1.c|+ |+ |+ |+ |+ |+ |
| 52 | +stm8s_tim2.c|+ |+ |+ |+ | | |
| 53 | +stm8s_tim3.c| |+ |+ |+ | | |
| 54 | +stm8s_tim4.c|+ |+ |+ |+ | | |
| 55 | +stm8s_tim5.c| | | | |+ |+ |
| 56 | +stm8s_tim6.c| | | | |+ |+ |
| 57 | +stm8s_uart1.c|+ | |+ |+ |+ | |
| 58 | +stm8s_uart2.c| |+ | | | | |
| 59 | +stm8s_uart3.c| | |+ |+ | | |
| 60 | +stm8s_uart4.c| | | | | |+ |
| 61 | +stm8s_wwdg.c|+ |+ |+ |+ |+ |+ |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +## Recycle bin |
| 67 | + |
| 68 | +Some (maybe) useful leftovers. These code snipplets might be useful again |
| 69 | +later. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +### Compare the contents of two libraries |
| 74 | + |
| 75 | +Unpack two libraries and compare the individual files: `cmplib.sh` |
| 76 | + |
| 77 | +```bash |
| 78 | +#!/bin/sh |
| 79 | + |
| 80 | +rm -rf a b |
| 81 | +mkdir a b |
| 82 | +(cd a; ar x ../$1) |
| 83 | +(cd b; ar x ../$2) |
| 84 | +diff -r a b |
| 85 | +``` |
| 86 | + |
| 87 | +### Determine the CPU dependencies within a Makefile |
| 88 | + |
| 89 | +```make |
| 90 | +DEPS=$(shell sdcc -mstm8 -Iinc -Isrc -D$(CPU) "-Wp-MM" -E inc/stm8s.h) |
| 91 | +HFILES = $(subst inc/,,$(filter inc/stm8s_%.h,$(DEPS))) |
| 92 | + |
| 93 | +$(info DEPS=$(DEPS)) |
| 94 | +$(info HFILES=$(HFILES)) |
| 95 | +``` |
| 96 | +(now use HFILES to generate list of C-files into LIBSOURCES) |
| 97 | + |
| 98 | +If all source files are already split into single-function source files |
| 99 | +this could be used to compile only the modules needed for the current CPU: |
| 100 | + |
| 101 | +```make |
| 102 | +# include all parts for every needed module in the LIBSOURCES list |
| 103 | +find_files = $(wildcard $(module)-*) |
| 104 | +SOURCES := $(foreach module,$(LIBSOURCES),$(find_files)) |
| 105 | +# if only the needed modules got split: This simple version is good enough |
| 106 | +#SOURCES := $(wildcard stm8s*.c) |
| 107 | + |
| 108 | +OBJECTS=$(SOURCES:.c=.o) |
| 109 | +OBJECTS_LINK=$(SOURCES:.c=.rel) |
| 110 | +EXECUTABLE=$(shell echo $(CPU)|tr '[:upper:]' '[:lower:]').lib |
| 111 | + |
| 112 | +# test output |
| 113 | +$(info LIBSCOMMON: $(LIBSCOMMON)) |
| 114 | +$(info LIBSOURCES: $(LIBSOURCES)) |
| 115 | +#$(info SOURCES: $(SOURCES)) |
| 116 | +$(info EXECUTABLE: $(EXECUTABLE)) |
| 117 | + |
| 118 | + |
| 119 | +# targets |
| 120 | +nothing: |
| 121 | + |
| 122 | +all: $(SOURCES) $(EXECUTABLE) |
| 123 | + echo $^ |
| 124 | + |
| 125 | +$(EXECUTABLE): $(OBJECTS) |
| 126 | + $(AR) $(LDFLAGS) $(EXECUTABLE) $(OBJECTS_LINK) |
| 127 | + |
| 128 | +.c.o: |
| 129 | + $(CC) $(CFLAGS) $< -o $@ |
| 130 | + |
| 131 | +clean: |
| 132 | + rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map |
| 133 | + rm -f $(EXECUTABLE) |
| 134 | +``` |
| 135 | + |
0 commit comments