forked from juju2013/touchled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.fs
64 lines (54 loc) · 1.14 KB
/
test.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
\ touch sensor experiments with bluepill
\ inlcudes
\ compiletoflash
\ include hexdump.fs
\ include io.fs
\ include pins64.fs
\ include disassembler-m3.fs
\ include svd.fs
compiletoram
\ include misc.fs
\ include nvic.fs
\ : cornerstone ( "name" -- ) \ define a flash memory cornerstone
\ <builds begin here dup flash-pagesize 1- and while 0 h, repeat
\ does> begin dup dup flash-pagesize 1- and while 2+ repeat cr
\ eraseflashfrom
\ ;
0 variable tickbegin
0 variable tickend
: tickduration ( -- u )
tickend @ tickbegin @ -
;
: -sensor
PB12 -exti.irq
40 irq.den
;
\ touch sensor isr
: isr-sensor
micros tickend !
-sensor
;
\ enable sensor irq
: +sensor
PB12 +exti \ map PB12 to exti12
PB12
dup +exti.irq
dup +exti.raise
-exti.fall
['] isr-sensor irq-exti10 ! \ set ISR routing to irq#40
40 irq.en \ IRQ #
;
: wait 50 ms ;
: test
." Start samplig, any key to exit" cr
begin
+sensor
PB12 ioc! IMODE-PULL PB12 io-mode! wait
micros tickbegin !
IMODE-FLOAT PB12 io-mode!
wait
tickduration . ." us" cr
key? until
;
IMODE-FLOAT PB12 io-mode!
8mhz 115200 baud USART1-BRR ! 1000 systick-hz