-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from TG9541/modular
fixes #27 upgrade to modular build and STM8 eForth 2.2.24.pre3
- Loading branch information
Showing
7 changed files
with
285 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,79 @@ | ||
STM8EF_BOARD=W1209-FD | ||
STM8EF_VER=2.2.23.pre2 | ||
STM8EF_VER=2.2.24.pre3 | ||
STM8EF_BIN=stm8ef-bin.zip | ||
STM8EF_URL=https://github.com/TG9541/stm8ef/releases/download/${STM8EF_VER}/${STM8EF_BIN} | ||
|
||
all: flash | ||
E4THCOM=e4thcom-0.6.3 | ||
TERM_PORT=ttyUSB0 | ||
TERM_BAUD=9600 | ||
TERM_FLAGS= | ||
|
||
zip: | ||
zip -r ${STM8EF_BOARD}-forth ${STM8EF_BOARD}-forth.ihx | ||
ifeq ($(BOARD),) | ||
|
||
defaults: | ||
stm8flash -c stlinkv2 -p stm8s103f3 -s opt -w tools/stm8s103FactoryDefaults.bin | ||
# e4thcom style Forth code can't have a file suffix (but filenames are uppercase) | ||
mmforth:=$(shell echo `ls|gawk '/^[A-Z0-9]*$$/ {print}'`) | ||
forth=$(wildcard *fs) $(mmforth) | ||
|
||
.PHONY: test clean | ||
|
||
# Usage:make term BOARD=<board dir> [TERM_PORT=ttyXXXX] [TERM_BAUD=nnnn] [TERM_FLAGS="--half-duplex --idm"] | ||
all: load | ||
|
||
release: zip tgz | ||
|
||
zip: simload | ||
find out/ -name "*.ihx" -print | zip -r out/stm8ef-bin docs/words.md inc/* mcu/* lib/* -@ | ||
find out/ -name "simbreak.txt" -print | zip -r out/stm8ef-bin tools/* -@ | ||
find out/ -name "target" -print | zip -r out/stm8ef-bin -@ | ||
|
||
tgz: simload | ||
( find out/ -path "*target/*" -print0 ; find out/ -name "*.ihx" -type f -print0 ; find out/ -name "simbreak.txt" -type f -print0 ) | tar -czvf out/stm8ef-bin.tgz LICENSE.md docs/words.md mcu lib tools --null -T - | ||
( find out/ -name "forth.rst" -type f -print0 ) | tar -czvf out/stm8ef-rst.tgz --null -T - | ||
|
||
build: words | ||
make BOARD=CORE | ||
|
||
flash: depend | ||
load: flash | ||
tools/codeload.py -b out/$(STM8EF_BOARD) -p /dev/$(TERM_PORT) serial $(STM8EF_BOARD)/board.fs | ||
|
||
flash: target defaults | ||
stm8flash -c stlinkv2 -p stm8s103f3 -w out/$(STM8EF_BOARD)/$(STM8EF_BOARD).ihx | ||
|
||
load: depend | ||
tools/codeload.py serial main.fs | ||
defaults: | ||
stm8flash -c stlinkv2 -p stm8s103f3 -s opt -w tools/stm8s103FactoryDefaults.bin | ||
|
||
test: simload | ||
test/mbtest.sh $(STM8EF_BOARD) | ||
|
||
simload: depend | ||
simload: $(forth) target | ||
tools/simload.sh $(STM8EF_BOARD) | ||
touch simload | ||
|
||
target: depend | ||
target: binary | ||
rm -f target | ||
ln -s out/${STM8EF_BOARD}/target target | ||
|
||
binary: depend | ||
make BOARD=W1209-FD | ||
|
||
depend: | ||
if [ ! -d "out" ]; then \ | ||
curl -# -L -O ${STM8EF_URL}; \ | ||
unzip -q -o ${STM8EF_BIN} -x out/*; \ | ||
unzip -q -o ${STM8EF_BIN} out/${STM8EF_BOARD}/*; \ | ||
rm ${STM8EF_BIN}; \ | ||
fi | ||
touch depend | ||
|
||
term: | ||
$(E4THCOM) -t stm8ef -p .:lib $(TERM_FLAGS) -d $(TERM_PORT) -b B$(TERM_BAUD) | ||
|
||
clean: | ||
rm -rf target STM8S103.efr STM8S105.efr docs lib mcu out tools | ||
rm -rf target docs lib mcu out inc tools | ||
rm -f forth.asm forth.h forth.mk main.c STM8S103.efr STM8S105.efr | ||
rm -f simload depend | ||
|
||
else | ||
# the STM8 eForth make is a dependency | ||
include forth.mk | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include main.fs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
; XH-W1209 STM8S device dependent HW routines | ||
|
||
|
||
; BOARDINIT ( -- ) | ||
; Init board GPIO (except COM ports) | ||
BOARDINIT: | ||
; Board I/O initialization | ||
|
||
; W1209 STM8S003F3 init GPIO | ||
MOV PA_DDR,#0b00001110 ; relay,B,F | ||
MOV PA_CR1,#0b00001110 | ||
MOV PB_DDR,#0b00110000 ; d2,d3 | ||
MOV PB_CR1,#0b00110000 | ||
MOV PC_DDR,#0b11000000 ; G,C | ||
MOV PC_CR1,#0b11111000 ; G,C-+S... Key pullups | ||
MOV PD_DDR,#0b00111110 ; A,DP,D,d1,A | ||
MOV PD_CR1,#0b00111110 | ||
|
||
.ifne HAS_OUTPUTS | ||
CLR A | ||
JRA AOUTSTOR | ||
.else | ||
RET | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
; Dummy labels for PSIM interrupts declared in main.c | ||
|
||
.ifne PSIM-PORTA | ||
; Dummy label for _EXTIA_IRQHandler | ||
_EXTI0_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTB | ||
; Dummy label for _EXTIB_IRQHandler | ||
_EXTI1_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTC | ||
; Dummy label for _EXTIC_IRQHandler | ||
_EXTI2_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTD | ||
; Dummy label for _EXTID_IRQHandler | ||
_EXTI3_IRQHandler: | ||
.endif | ||
|
||
.ifne PSIM-PORTE | ||
; Dummy label for _EXTIE_IRQHandler | ||
_EXTI4_IRQHandler: | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
.ifne HAS_LED7SEG | ||
; LED_MPX driver ( -- ) | ||
; Output bit pattern in A to 7S-LED digit hardware | ||
|
||
LED_MPX: | ||
BSET PD_ODR,#4 ; Digit .3.. | ||
BSET PB_ODR,#5 ; Digit ..2. | ||
BSET PB_ODR,#4 ; Digit ...1 | ||
|
||
LD A,TICKCNT+1 | ||
AND A,#0x03 ; 3 digits MPX | ||
|
||
JRNE 1$ | ||
BRES PD_ODR,#4 ; digit .3.. | ||
JRA 3$ | ||
|
||
1$: CP A,#1 | ||
JRNE 2$ | ||
BRES PB_ODR,#5 ; digit ..2. | ||
JRA 3$ | ||
|
||
2$: CP A,#2 | ||
JRNE 4$ | ||
BRES PB_ODR,#4 ; digit ...1 | ||
; fall through | ||
|
||
3$: CLRW X | ||
LD XL,A | ||
LD A,(LED7LAST-2,X) | ||
|
||
; W1209 7S LED display row | ||
; bit 76453210 input (parameter A) | ||
; PA .....FB. | ||
; PC CG...... | ||
; PD ..A.DPE. | ||
RRC A | ||
BCCM PD_ODR,#5 ; A | ||
RRC A | ||
BCCM PA_ODR,#2 ; B | ||
RRC A | ||
BCCM PC_ODR,#7 ; C | ||
RRC A | ||
BCCM PD_ODR,#3 ; D | ||
RRC A | ||
BCCM PD_ODR,#1 ; E | ||
RRC A | ||
BCCM PA_ODR,#1 ; F | ||
RRC A | ||
BCCM PC_ODR,#6 ; G | ||
RRC A | ||
BCCM PD_ODR,#2 ; P | ||
|
||
4$: RET | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
.ifne HAS_OUTPUTS | ||
RamWord OUTPUTS ; "OUT", e.g. relays, LEDs, etc. (16 bit) | ||
|
||
; OUT! ( c -- ) | ||
; Put c to board outputs, storing a copy in OUTPUTS | ||
.dw LINK | ||
|
||
LINK = . | ||
.db (4) | ||
.ascii "OUT!" | ||
OUTSTOR: | ||
INCW X | ||
LD A,(X) | ||
INCW X | ||
AOUTSTOR: | ||
LD OUTPUTS+1,A | ||
RRC A | ||
BCCM PA_ODR,#3 ; W1209 relay | ||
RET | ||
.endif | ||
|
||
;=============================================================== | ||
|
||
.ifne HAS_KEYS | ||
; BKEY ( -- c ) ( TOS STM8: -- A,Z,N ) | ||
; Read board key state as a bitfield | ||
.dw LINK | ||
|
||
LINK = . | ||
.db (4) | ||
.ascii "BKEY" | ||
BKEY: | ||
; Keys "set" (1), "+" (2), and "-" (4) on PC.3:5 | ||
LD A,PC_IDR | ||
SLA A | ||
SWAP A | ||
CPL A | ||
AND A,#0x07 | ||
JP ASTOR | ||
|
||
; BKEYC ( -- c ) ( TOS STM8: -- A,Z,N ) | ||
; Read and translate board dependent key bitmap into char | ||
|
||
BKEYCHAR: | ||
CALLR BKEY | ||
JREQ 1$ | ||
ADD A,#'@' | ||
LD (1,X),A | ||
1$: RET | ||
.endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; STM8EF Global Configuration File | ||
; Config for W1209 Thermostat Module | ||
; Clock: HSI (no crystal) | ||
|
||
HALF_DUPLEX = 0 ; Use UART in half duplex mode | ||
HAS_TXUART = 0 ; No UART TXD, word TX! | ||
HAS_RXUART = 0 ; No UART RXD, word ?RX | ||
HAS_TXSIM = 1 ; Enable TxD via GPIO/TIM4, word TXGP! | ||
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP | ||
PSIM = PORTC ; Port for UART simulation | ||
PNRX = 4 ; Port GPIO# for HAS_RXDSIM | ||
PNTX = 5 ; Port GPIO# for HAS_TXDSIM | ||
|
||
EMIT_BG = EMIT7S ; 7S-LED background EMIT vector | ||
QKEY_BG = QKEYB ; Board keys background QKEY vector | ||
|
||
HAS_LED7SEG = 1 ; yes, 1*3 dig. 7-seg LED on module | ||
|
||
HAS_KEYS = 3 ; yes, 3 keys on module | ||
HAS_OUTPUTS = 1 ; yes, one LED | ||
HAS_ADC = 1 ; Analog input words | ||
|
||
HAS_BACKGROUND = 1 ; Background Forth task (TIM2 ticker) | ||
HAS_CPNVM = 1 ; Can compile to Flash, always interpret to RAM | ||
HAS_DOES = 1 ; CREATE-DOES> extension | ||
HAS_DOLOOP = 1 ; DO .. LOOP extension: DO LEAVE LOOP +LOOP | ||
|
||
|
||
CASEINSENSITIVE = 1 ; Case insensitive dictionary search | ||
SPEEDOVERSIZE = 0 ; Speed-over-size in core words: ROT - = < | ||
BAREBONES = 0 ; Remove or unlink some more: hi HERE .R U.R SPACES @EXECUTE AHEAD CALL, EXIT COMPILE [COMPILE] | ||
|
||
WORDS_LINKINTER = 0 ; Link interpreter words: ACCEPT QUERY TAP kTAP hi 'BOOT tmp >IN 'TIB #TIB eval CONTEXT pars PARSE NUMBER? DIGIT? WORD TOKEN NAME> SAME? find ABORT aborq $INTERPRET INTER? .OK ?STACK EVAL PRESET QUIT $COMPILE | ||
WORDS_LINKCOMP = 0 ; Link compiler words: cp last OVERT $"| ."| $,n | ||
WORDS_LINKRUNTI = 0 ; Link runtime words: doLit do$ doVAR donxt dodoes ?branch branch | ||
WORDS_LINKCHAR = 1 ; Link char out words: DIGIT <# # #S SIGN #> str hld HOLD | ||
WORDS_LINKMISC = 0 ; Link composing words of SEE DUMP WORDS: >CHAR _TYPE dm+ .ID >NAME | ||
|
||
WORDS_EXTRASTACK = 0 ; Link/include stack core words: rp@ rp! sp! sp@ DEPTH | ||
WORDS_EXTRADEBUG = 0 ; Extra debug words: SEE | ||
WORDS_EXTRACORE = 1 ; Extra core words: =0 I | ||
WORDS_EXTRAMEM = 1 ; Extra memory words: B! 2C@ 2C! | ||
WORDS_EXTRAEEPR = 1 ; Extra EEPROM lock/unlock words: LOCK ULOCK ULOCKF LOCKF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; STM8S003F3 device and memory layout configuration | ||
|
||
TARGET = STM8S003F3 | ||
|
||
RAMEND = 0x03FF ; system (return) stack, growing down | ||
EEPROMEND = 0x407F ; STM8S003F3: 128 bytes EEPROM (maybe more, YMMV) | ||
FLASHEND = 0x9FFF ; 8K devices | ||
|
||
FORTHRAM = 0x0040 ; Start of RAM controlled by Forth | ||
UPPLOC = 0x0060 ; UPP (user/system area) location for 1K RAM | ||
CTOPLOC = 0x0080 ; CTOP (user dictionary) location for 1K RAM | ||
SPPLOC = 0x0350 ; SPP (data stack top), TIB start | ||
RPPLOC = RAMEND ; RPP (return stack top) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters