This repository has been archived by the owner on Mar 27, 2021. It is now read-only.
forked from Crest/swdcom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap_zepto.fs
72 lines (54 loc) · 1.67 KB
/
bootstrap_zepto.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
compile-to-flash
forth-wordlist 1 set-order
forth-wordlist set-current
wordlist constant swd-wordlist
wordlist constant swd-internal-wordlist
forth-wordlist int-io-internal-wordlist swd-internal-wordlist swd-wordlist
4 set-order
swd-internal-wordlist set-current
here 256 2* cell+ buffer: swd
swd 0 + constant swd-rx-w
swd 1 + constant swd-rx-r
swd 2 + constant swd-tx-w
swd 3 + constant swd-tx-r
swd cell+ dup constant swd-rx
256 + constant swd-tx
: b-inc ( c-addr -- ) 1 swap b+! [inlined] ;
: inc-rx-w ( -- ) swd-rx-w b-inc ;
: inc-rx-r ( -- ) swd-rx-r b-inc ;
: inc-tx-w ( -- ) swd-tx-w b-inc ;
: inc-tx-r ( -- ) swd-tx-r b-inc ;
variable use-sleep
: pause-until ( xt -- )
use-sleep @ if wait else begin dup execute not while pause repeat drop then
;
: swd-key? ( -- flag ) swd h@ dup 8 rshift swap $ff and <> ;
: swd-key ( -- char ) [: swd-key? ;] pause-until swd-rx swd-rx-r b@ + b@ inc-rx-r ;
: swd-emit? ( -- flag ) swd-tx-w h@ dup 8 rshift swap $ff and 1+ $ff and <> ;
: swd-emit ( char -- ) [: swd-emit? ;] pause-until swd-tx swd-tx-w b@ + b! inc-tx-w ;
: >r11 ( x -- ) [ $46b3 h, ] drop ; \ $46b3 = mov r11, r6
: swd-init ( -- ) true use-sleep ! 0 swd ! swd >r11 ;
swd-wordlist set-current
: swd-console ( -- )
['] swd-key? key?-hook !
['] swd-key key-hook !
['] swd-emit? emit?-hook !
['] swd-emit emit-hook !
;
: serial-console ( -- )
['] do-key? key?-hook !
['] do-key key-hook !
['] do-emit? emit?-hook !
['] do-emit emit-hook !
;
: enable-sleep ( -- ) true use-sleep ! ;
: disable-sleep ( -- ) false use-sleep ! ;
forth-wordlist set-current
: init ( -- )
init
swd-init
." The swd buffer address is: " swd h.8 cr
swd-console
;
compile-to-ram
\ warm