-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
215 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
NVM | ||
#include math/inter.fs | ||
#include math/double.fs | ||
RAM | ||
|
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,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 | ||
|
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,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 | ||
|
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) | ||
|