Skip to content

Commit

Permalink
Merge pull request #144 from TG9541/dual-uart
Browse files Browse the repository at this point in the history
Dual uart
  • Loading branch information
TG9541 authored Jan 7, 2018
2 parents c2f1146 + bf0d121 commit 93d8402
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 63 deletions.
4 changes: 2 additions & 2 deletions C0135/globconf.inc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
; STM8EF Global Configuration File
; Config for C0135 "Relay Board-4 STM8S"

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

EMIT_BG = DROP ; 7S-LED background EMIT vector
QKEY_BG = QKEYB ; ?KEYB for background ?KEY
Expand Down
4 changes: 2 additions & 2 deletions DCDC/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
; Config for W1209 Thermostat Module
; Clock: HSI (no crystal)

HALF_DUPLEX = 1 ; Use EMIT/?KEY in half duplex mode
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_TXSIM = 1 ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP
PSIM = PORTC ; Port for UART simulation
PNRX = 7 ; Port GPIO# for HAS_RXDSIM
Expand Down
4 changes: 2 additions & 2 deletions MINDEV/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
; Config for STM8S103F3P6 Minmal Development Board
; Clock: HSI (no crystal)

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

EMIT_BG = DROP ; 7S-LED background EMIT vector
QKEY_BG = ZERO ; Board keys background QKEY vector
Expand Down
4 changes: 2 additions & 2 deletions STM8L051F3/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
; Config for STM8L051F3P6
; Clock: HSI (no crystal)

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

EMIT_BG = DROP ; 7S-LED background EMIT vector
QKEY_BG = ZERO ; Board keys background QKEY vector
Expand Down
3 changes: 2 additions & 1 deletion STM8S001J3/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
; STM8S001J3M3 (or STM8S003F3P6) TX-Half-Duplex single wire communication
; Clock: HSI (no crystal)

HALF_DUPLEX = 1 ; Use EMIT/?KEY in half duplex mode

HALF_DUPLEX = 1 ; Use UART in half duplex mode
HAS_TXUART = 1 ; UART TXD, word TX!
HAS_RXUART = 1 ; UART RXD, word ?RX
HAS_TXSIM = 0 ; Enable TxD via GPIO/TIM4, word TXGP!
Expand Down
2 changes: 1 addition & 1 deletion STM8S105K4/globconf.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; STM8EF Global Configuration File
; Clock: HSI (no crystal)

HALF_DUPLEX = 0 ; Use EMIT/?KEY in half duplex mode
HALF_DUPLEX = 0 ; Use UART in half duplex mode
HAS_TXUART = 1 ; No UART TXD, word TX!
HAS_RXUART = 1 ; No UART RXD, word ?RX
HAS_TXSIM = 0 ; Enable TxD via GPIO/TIM4, word TXGP!
Expand Down
6 changes: 3 additions & 3 deletions SWIMCOM/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
; STM8S003F3P6 generic SWIM single pin communication
; Clock: HSI (no crystal)

HALF_DUPLEX = 1 ; Use EMIT/?KEY in half duplex mode
HAS_TXUART = 0 ; No UART TXD, word TX!
HALF_DUPLEX = 0 ; Use UART in half duplex mode
HAS_RXUART = 0 ; No UART RXD, word ?RX
HAS_TXSIM = 1 ; Enable TxD via GPIO/TIM4, word TXGP!
HAS_TXUART = 0 ; No UART TXD, word TX!
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP
HAS_TXSIM = 1 ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
PSIM = PORTD ; Port for UART simulation
PNRX = 1 ; Port GPIO# for HAS_RXDSIM
PNTX = 1 ; Port GPIO# for HAS_TXDSIM
Expand Down
6 changes: 3 additions & 3 deletions W1209-FD/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
; Config for W1209 Thermostat Module
; Clock: HSI (no crystal)

HALF_DUPLEX = 0 ; Use EMIT/?KEY in half duplex mode
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
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
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
Expand Down
8 changes: 4 additions & 4 deletions W1209/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
; Config for W1209 Thermostat Module
; Clock: HSI (no crystal)

HALF_DUPLEX = 1 ; Use EMIT/?KEY in half duplex mode
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
PSIM = PORTD ; Port for UART simulation
HAS_TXSIM = 1 ; Enable TxD via GPIO/TIM4, word TXGP!
PNTX = 6 ; Port GPIO# for HAS_TXDSIM
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP
HAS_TXSIM = 1 ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
PSIM = PORTD ; Port for UART simulation
PNRX = 6 ; Port GPIO# for HAS_RXDSIM
PNTX = 6 ; Port GPIO# for HAS_TXDSIM

EMIT_BG = EMIT7S ; 7S-LED background EMIT vector
QKEY_BG = QKEYB ; Board keys background QKEY vector
Expand Down
6 changes: 3 additions & 3 deletions W1219/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
; Config for W1219 Thermostat Module
; Clock: HSI (no crystal)

HALF_DUPLEX = 1 ; Use EMIT/?KEY in half duplex mode
HAS_TXUART = 0 ; No UART TXD, word TX!
HALF_DUPLEX = 0 ; Use UART in half duplex mode
HAS_RXUART = 0 ; No UART RXD, word ?RX
HAS_TXSIM = 1 ; Enable TxD via GPIO/TIM4, word TXGP!
HAS_TXUART = 0 ; No UART TXD, word TX!
HAS_RXSIM = 1 ; Enable RxD via GPIO/TIM4, word ?RXGP
HAS_TXSIM = 1 ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
PSIM = PORTD ; Port for UART simulation
PNTX = 1 ; Port GPIO# for HAS_TXDSIM
PNRX = 1 ; Port GPIO# for HAS_RXDSIM
Expand Down
4 changes: 2 additions & 2 deletions W1401/globconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
; Config for W1401 Thermostat Module
; Clock: HSI (no crystal)

HALF_DUPLEX = 1 ; Use EMIT/?KEY in half duplex mode
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
HAS_TXSIM = 1 ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
PSIM = PORTD ; Port for UART simulation
PNTX = 1 ; Port GPIO# for HAS_TXDSIM
PNRX = 1 ; Port GPIO# for HAS_RXDSIM
Expand Down
43 changes: 28 additions & 15 deletions docs/words.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
; The application startup vector and NVM USR setting array
```

```
; hi ( -- )
; Display sign-on message.
```

```
; ?RX ( -- c T | F ) ( TOS STM8: -- Y,Z,N )
; Return serial interface input char from and true, or false.
Expand Down Expand Up @@ -457,6 +452,13 @@
; Add 1 to tos.
```

```
; DOXCODE ( n -- n ) ( TOS STM8: - Y,Z,N )
; precede assembly code for a primitive word
; Caution: no other Forth word can be called from assembly!
; In the assembly code: X=(TOS), YTEMP=TOS. (TOS)=X after RET
```

```
; NOT ( w -- w ) ( TOS STM8: -- Y,Z,N )
; One's complement of TOS.
Expand Down Expand Up @@ -642,12 +644,6 @@
; Send n spaces to output device.
```

```
; CR ( -- )
; Output a carriage return
; and a line feed.
```

```
; do$ ( -- a )
; Return address of a compiled
Expand Down Expand Up @@ -827,19 +823,31 @@
; Start text interpreter.
```

```
; CR ( -- )
; Output a carriage return
; and a line feed.
```

```
; COMPILE? ( -- n )
; 0 if 'EVAL points to $INTERPRETER
; HEADER COMPIQ "COMPILE?"
```

```
; .OK ( -- )
; Display 'ok' while interpreting.
```

```
; ?STACK ( -- )
; Abort if stack underflows.
; hi ( -- )
; Display sign-on message.
```

```
; EVAL ( -- )
; Interpret input stream.
; ?STACK ( -- )
; Abort if stack underflows.
```

```
Expand All @@ -848,6 +856,11 @@
; and start text interpreter.
```

```
; EVAL ( -- )
; Interpret input stream.
```

```
; ' ( -- ca )
; Search vocabularies for
Expand Down
37 changes: 24 additions & 13 deletions forth.asm
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@

.include "linkopts.inc"

; console configuration: check if TX simulation has priority over UART
.ifge HAS_TXSIM - HAS_TXUART
CONSOLE_HALF_DUPLEX = 1 ; RX/TX simulation always behaves like half duplex
.else
CONSOLE_HALF_DUPLEX = HALF_DUPLEX ; use hardware UART settings
.endif


;**************************************
;****** 5) Board Driver Memory ******
;**************************************
Expand Down Expand Up @@ -628,7 +636,7 @@ TXSTOR:
LD A,(X)
INCW X

.ifne HALF_DUPLEX * (1-HAS_TXSIM)
.ifne HALF_DUPLEX
; HALF_DUPLEX with normal UART (e.g. wired-or Rx and Tx)
1$: BTJF UART_SR,#7,1$ ; loop until tdre
BRES UART_CR2,#2 ; disable rx
Expand All @@ -650,11 +658,11 @@ _TIM4_IRQHandler:
; dummy for linker - can be overwritten by Forth application
.else
; include required serial I/O code
.ifne PNRX^PNTX
.include "sser_fdx.inc" ; Full Duplex serial
.else
.include "sser_hdx.inc" ; Half Duplex serial
.endif
.ifne PNRX^PNTX
.include "sser_fdx.inc" ; Full Duplex serial
.else
.include "sser_hdx.inc" ; Half Duplex serial
.endif
.endif

; ==============================================
Expand Down Expand Up @@ -1911,10 +1919,13 @@ ONEP:
INCW X
RET

; DOXCODE ( n - n ) ( TOS STM8: - Y,Z,N )
; DOXCODE precedes assembly code for a primitive word

; DOXCODE ( n -- n ) ( TOS STM8: - Y,Z,N )
; precede assembly code for a primitive word
; Caution: no other Forth word can be called from assembly!
; In the assembly code: X=(TOS), YTEMP=TOS. (TOS)=X after RET
; Caution: no other Forth word may be called from assembly!

; HEADER DOXCODE "DOXCODE"
DOXCODE:
POPW Y
LDW YTEMP,X
Expand Down Expand Up @@ -2447,9 +2458,9 @@ KEY1: CALL [USRQKEY]

HEADER NUFQ "NUF?"
NUFQ:
.ifne HALF_DUPLEX
.ifne CONSOLE_HALF_DUPLEX
; slow EMIT down to free the line for RX
.ifne HAS_BACKGROUND * HALF_DUPLEX
.ifne HAS_BACKGROUND
LD A,TICKCNT+1
ADD A,#3
1$: CP A,TICKCNT+1
Expand Down Expand Up @@ -2958,7 +2969,7 @@ BKSP:
CP A,(1,X)
JREQ BACK1
BACK0:
.ifeq HALF_DUPLEX
.ifeq CONSOLE_HALF_DUPLEX
CALLR BACKSP
.endif
CALL ONEM
Expand All @@ -2974,7 +2985,7 @@ BACK1: RET

HEADER TAP "TAP"
TAP:
.ifeq HALF_DUPLEX
.ifeq CONSOLE_HALF_DUPLEX
CALL DUPP
CALL [USREMIT]
.endif
Expand Down
7 changes: 4 additions & 3 deletions inc/defconf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
RELVER0 = 1 ; Revision digit 0

TERM_LINUX = 1 ; LF terminates line
HALF_DUPLEX = 0 ; Use EMIT/?KEY in half duplex mode
HAS_TXUART = 1 ; Enable UART TXD, word TX!

HALF_DUPLEX = 0 ; Use UART in half duplex mode
HAS_RXUART = 1 ; Enable UART RXD, word ?RX
HAS_TXSIM = 0 ; Enable TxD via GPIO/TIM4, word TXGP!
HAS_TXUART = 1 ; Enable UART TXD, word TX!
HAS_RXSIM = 0 ; Enable RxD via GPIO/TIM4, word ?RXGP
HAS_TXSIM = 0 ; like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
PSIM = PORTX ; Port for UART simulation
PNRX = 1 ; Port GPIO# for HAS_RXDSIM
PNTX = 1 ; Port GPIO# for HAS_TXDSIM
Expand Down
Loading

0 comments on commit 93d8402

Please sign in to comment.