Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (25 commits)
  reference to Wiki updated
  library additions
  library mcu according to e4thcom convention
  Update README.md
  some bytes saved
  some editing
  Fixes TG9541#44: XH-M188 lockup after power cycle
  fixes TG9541#43 Provide a Forth library infrastructure
  fixes TG9541#42 Improve W1209 ease of use
  fixes TG9541#42 Improve W1209 ease of use
  fixes TG9541#41: improved full duplex simulated serial
  edit
  Fix for UART simulation with 2 GPIOs
  HAS_ALIAS default on (IMMEDIATE words in RAM possible)
  SWIMCOM fix for HEADER macro, option WORDS_HWREG off
  issue TG9541#32 Build framework feature #include
  fixes TG9541#39 : underflow error message doesn't match normal pattern
  fixes TG9541#39 : underflow error message doesn't match normal pattern
  issue TG9541#32 Build framework feature: Forth application binary with uCsim
  issue TG9541#32: use telnet library
  ...
  • Loading branch information
Elliot Williams committed Aug 8, 2017
2 parents 7f720ed + 1c88979 commit bf6657a
Show file tree
Hide file tree
Showing 37 changed files with 1,727 additions and 1,554 deletions.
19 changes: 11 additions & 8 deletions CORE/boardcore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
; Note: for supporting a new board create a new board configuration
; folder with a "globconfig.inc" and a copy of this file.

; BOARDINIT ( -- )
; Init board GPIO (except COM ports)

BOARDINIT:
; Board I/O initialization

RET

;===============================================================

; Dummy labels for PSIM interrupts declared in main.c
Expand Down Expand Up @@ -82,3 +74,14 @@ BKEYCHAR:
JRA BKEY ; Dummy: get "no key" and leave it as it is
.endif

;===============================================================

; BOARDINIT ( -- )
; Init board GPIO (except COM ports)

BOARDINIT:
; Board I/O initialization

RET


2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is derived work from STM8eForth by Dr. C.H. Ting, which was kindly granted into the public domain in 2010 with contribution from TG9541 Copyright (c) 2016.
This work is partially derived from STM8eForth by Dr. C.H. Ting, which was kindly granted into the public domain in 2010. Other parts Copyright (c) TG9541 (c) 2016.

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:

Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ ifeq ($(BOARD),)
all: zip

zip: build
find out/ -name "*.ihx" -print | zip out/stm8ef-bin docs/words.md -@
find out/ -name "*.ihx" -print | zip -r out/stm8ef-bin docs/words.md mcu/* lib/* -@

build: words
make BOARD=CORE
make BOARD=XH-M188
make BOARD=W1209
make BOARD=W1209-FD
make BOARD=W1219
make BOARD=W1401
make BOARD=C0135
Expand Down Expand Up @@ -49,8 +50,8 @@ forth.rel: forth.asm $(FDEPS)
flash: main.ihx
stm8flash -c stlinkv2 -p $(TARGET) -w out/$(BOARD)/$(BOARD).ihx

forth: flash
tools/loadserial.py $(BOARD)/board.fs
forth: main.ihx
tools/simload.sh $(BOARD)

directories: out

Expand Down
301 changes: 137 additions & 164 deletions README.md

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions SWIMCOM/boardcore.inc
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
; STM8S003F3P6 generic SWIM single pin communication


; BOARDINIT ( -- )
; Init board GPIO (except COM ports)

BOARDINIT:
; Board I/O initialization
RET

;===============================================================

; Dummy labels for PSIM interrupts declared in main.c

Expand Down Expand Up @@ -39,23 +30,23 @@ _EXTI3_IRQHandler:
; LED_MPX driver ( -- )
; Code called from ISR for LED MPX

LED_MPX:
LED_MPX:
RET
.endif


;===============================================================

.ifne HAS_OUTPUTS
; OUT! ( c -- )
; Put c to board outputs, storing a copy in OUTPUTS
; Put c to board outputs, storing a copy in OUTPUTS
.dw LINK

LINK = .
.db (4)
.ascii "OUT!"
OUTSTOR:
RET
RET
.endif

;===============================================================
Expand All @@ -64,19 +55,29 @@ OUTSTOR:
; BKEY ( -- f ) ( TOS STM8: -- A,Z,N )
; Read board key state as a bitfield
.dw LINK

LINK = .
.db (4)
.ascii "BKEY"
BKEY:
BKEY:
CLR A
JP ASTOR


; BKEYC ( -- c ) ( TOS STM8: -- A,Z,N )
; Read and translate board dependent key bitmap into char
; Read and translate board dependent key bitmap into char

BKEYCHAR:
JRA BKEY ; Dummy: get "no key" and leave it as it is
JRA BKEY ; Dummy: get "no key" and leave it as it is
.endif

;===============================================================

; BOARDINIT ( -- )
; Init board GPIO (except COM ports)

BOARDINIT:
; Board I/O initialization

RET

2 changes: 1 addition & 1 deletion SWIMCOM/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
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
WORDS_HWREG = 1 ; Peripheral Register words
WORDS_HWREG = 0 ; Peripheral Register words

5 changes: 5 additions & 0 deletions W1209-FD/board.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NVM
#include math/inter.fs
#include math/double.fs
RAM

151 changes: 151 additions & 0 deletions W1209-FD/boardcore.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
; 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
RET

;===============================================================

; 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 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
; 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)
LD OUTPUTS+1,A
INCW X
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

45 changes: 45 additions & 0 deletions W1209-FD/globconf.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
; STM8EF Global Configuration File
; Config for W1209 Thermostat Module
; Clock: HSI (no crystal)

HALF_DUPLEX = 0 ; Use EMIT/?KEY in half duplex mode
HAS_TXUART = 0 ; No UART TXD, word TX!
HAS_RXUART = 0 ; No UART RXD, word ?RX
PSIM = PORTC ; Port for UART simulation
HAS_TXSIM = 1 ; Enable TxD via GPIO/TIM4, word TXGP!
PNTX = 5 ; Port GPIO# for HAS_TXDSIM
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP
PNRX = 4 ; Port GPIO# for HAS_RXDSIM

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
WORDS_HWREG = 0 ; Peripheral Register words

14 changes: 14 additions & 0 deletions W1209-FD/target.inc
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)

14 changes: 0 additions & 14 deletions XH-M188/board.f

This file was deleted.

3 changes: 3 additions & 0 deletions XH-M188/board.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NVM
#include math/inter.fs
RAM
Loading

0 comments on commit bf6657a

Please sign in to comment.