/
dtc.fm
96 lines (71 loc) · 2.58 KB
/
dtc.fm
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#lang staapl/pic18 \ -*- forth -*-
\ App: DTC Forth.
\ There is dtc support Staapl, both as a compiler (pic18-dtc.rkt and
\ #lang staapl/pic18/dtc) and as an interactive console
\ (live-pic18-dtc.rkt). This module produces a dictionary that uses
\ both.
\ Additionally, a stand-alone forth could be built on top of the core
\ DTC implementation, with outer interpreter and immediate words
\ running on the target. Some preliminary code is included for
\ console input.
\ Board:
\ PIC DIP40 MINI KIT - PIC Development Board kit for DIP40 PIC with 18F4550 + 4Mhz XTAL
\ http://100mhz.com/pic-dspic-pic32-pic24/development-boards/pic-18f4550-usb-demo-development-board-pic18f4550-microcontroller-1074.html
provide-all
\ config
#x300000 org-begin
\ no extended instruction set, no wdt, no code protect,
#x20 , #x0E , #x3A , #x1E , \ 4MHz XT drives PLL directly
#x00 , #x81 , #x85 , #x00 , \ extended instruction set disabled
#x0F , #xC0 , #x0F , #xE0 ,
#x0F , #x40 ,
org-end
staapl pic18/boot \ chip init code
load p18f4550.f \ chip macros
load monitor-usbserial.f \ boot block + interactive monitor over USB ACM serial port
load usb.f \ USB library
require-file dtc-desc.rkt \ scheme file with descriptor tables
: device-descriptor 'scheme device usb-descriptor
: configuration-descriptor 'scheme configs usb-descriptors
: string-descriptor 'scheme strings usb-descriptors
\ If staapl/live-pic18-dtc is used for interaction, the DTC
\ interpreter needs to be compiled manually.
staapl pic18/dtc
\ load dtc-test.f
\ serial console input line editor
load line-editor.f
\ stdin / stdout config
staapl pic18/vector
staapl pic18/serial-debug
staapl pic18/compose-macro
\ load debug.f
: usb>io
[ stdin -> console-EP OUT> ] i/c
[ stdout -> console-EP >IN ] i/c
[ stdout-flush -> console-EP IN-flush ] i/c ;
: serial>io
[ stdin -> async.rx> ] i/c
[ stdout -> async.>tx ] i/c
[ stdout-flush -> ] i/c ;
\ config macros
macro
: live-module ` staapl/pic18/live-dtc ;
: fosc 48000000 ;
: monitor-EP 1 ; \ ttyACM0 staapl monitor (binary)
: console-EP 3 ; \ ttyACM1 serial command interface
: total-EP 4 ;
: service-lo ;
: pause 0 begin 0 begin 1+ c? until drop 1+ c? until drop ;
: hello 0 LATB ! pause #xF LATB ! ;
: init-board \ FIXME
#xF0 TRISB ! \ low nibble is LED1-LED4
0 TRISA ! \ FIXME: check these
0 TRISC !
0 TRISD !
0 TRISE !
hello \ remove if doesn't fit in bootloader
;
\ dtc uses 8bit interpreter interface
: application
interpreter ;
forth