parent
bf3a457437
commit
06c9611f6a
@ -1,10 +0,0 @@ |
||||
This code runs on the bat board (rev2), by flabbergast. |
||||
|
||||
* default I2C: B7/SDA, B6/SCL (tricky to change, at one point |
||||
it's hardcoded into jcw's driver) |
||||
* default SPI: PB8/ssel, PB5/MOSI, PB4/MISO, PB3/SCLK (this is enough |
||||
for a RFM69) |
||||
* also defined: |
||||
* LED = PA15, active: set/high |
||||
* BTN = PA1, pressed: true |
||||
|
@ -1,22 +0,0 @@ |
||||
\ these definitions should always stay loaded |
||||
|
||||
$5000 eraseflashfrom \ need to start off with a clean Mecrisp image |
||||
compiletoflash |
||||
|
||||
: chipid ( -- u1 u2 u3 3 ) \ unique chip ID as N values on the stack |
||||
$1FFFF7AC @ $1FFFF7B0 @ $1FFFF7B4 @ 3 ; |
||||
: hwid ( -- u ) \ a "fairly unique" hardware ID as single 32-bit int |
||||
chipid 1 do xor loop ; |
||||
: flash-kb ( -- u ) \ return size of flash memory in KB |
||||
$1FFFF7CC h@ ; |
||||
: flash-pagesize ( addr - u ) \ return size of flash page at given address |
||||
2048 ; \ however for F07x and F09x it is always 2kb (and F0[3|4|5]x 1kb) |
||||
|
||||
: cornerstone ( "name" -- ) \ define a flash memory cornerstone |
||||
<builds begin here flash-pagesize 1- and while 0 h, repeat |
||||
does> begin dup flash-pagesize 1- and while 2+ repeat cr |
||||
eraseflashfrom ; |
||||
|
||||
( always end: ) here hex. |
||||
cornerstone eraseflash |
||||
compiletoram |
@ -1,68 +0,0 @@ |
||||
\ board definitions |
||||
\ needs always.fs |
||||
|
||||
eraseflash |
||||
compiletoflash |
||||
( board start: ) here dup hex. |
||||
|
||||
include ../flib/mecrisp/calltrace.fs |
||||
include ../flib/mecrisp/cond.fs |
||||
include ../flib/mecrisp/hexdump.fs |
||||
include ../flib/stm32l0/io.fs |
||||
include ../flib/pkg/pins48.fs |
||||
include ../flib/stm32l0/hal.fs |
||||
include ../flib/stm32l0/adc.fs |
||||
include ../flib/stm32l0/timer.fs |
||||
include ../flib/stm32l0/pwm.fs |
||||
include ../flib/stm32l0/i2c.fs |
||||
include ../flib/stm32l0/sleep.fs |
||||
|
||||
PB8 variable ssel \ can be changed at run time |
||||
PB3 constant SCLK |
||||
PB4 constant MISO |
||||
PB5 constant MOSI |
||||
include ../flib/stm32l0/spi.fs |
||||
|
||||
PA15 constant LED |
||||
PA1 constant BTN \ -1 pressed, 0 not |
||||
|
||||
: led-off LED ioc! ; |
||||
: led-on LED ios! ; |
||||
|
||||
: hello ( -- ) flash-kb . ." KB <tbb2> " hwid hex. |
||||
$10000 compiletoflash here - flashvar-here compiletoram here - |
||||
." ram/flash: " . . ." free " ; |
||||
|
||||
: init ( -- ) \ board initialisation |
||||
init \ uses new uart init convention |
||||
['] ct-irq irq-fault ! \ show call trace in unhandled exceptions |
||||
$00 hex.empty ! \ empty flash shows up as $00 iso $FF on these chips |
||||
OMODE-PP LED io-mode! |
||||
IMODE-FLOAT BTN io-mode! |
||||
\ 16MHz ( set by Mecrisp on startup to get an accurate USART baud rate ) |
||||
2 RCC-CCIPR ! \ set USART1 clock to HSI16, independent of sysclk |
||||
1000 systick-hz |
||||
led-on |
||||
hello ." ok." cr |
||||
; |
||||
|
||||
: rx-connected? ( -- f ) \ true if RX is connected (and idle) |
||||
IMODE-LOW PA10 io-mode! PA10 io@ 0<> OMODE-AF-PP PA10 io-mode! |
||||
dup if 1 ms serial-key? if serial-key drop then then \ flush any input noise |
||||
; |
||||
|
||||
: fake-key? ( -- f ) \ check for RX pin being pulled high |
||||
rx-connected? if reset then false ; |
||||
|
||||
\ unattended quits to the interpreter if the RX pin is connected, not floating |
||||
\ else it replaces the key? hook with a test to keep checking for RX reconnect |
||||
\ if so, it will reset to end up in the interpreter on the next startup |
||||
\ for use with a turnkey app in flash, i.e. ": init init unattended ... ;" |
||||
|
||||
: unattended |
||||
rx-connected? if quit then \ return to command prompt |
||||
['] fake-key? hook-key? ! ; |
||||
|
||||
( board end, size: ) here dup hex. swap - . |
||||
cornerstone <<<board>>> |
||||
compiletoram |
@ -1,17 +0,0 @@ |
||||
\ core libraries |
||||
|
||||
<<<board>>> |
||||
compiletoflash |
||||
( core start: ) here dup hex. |
||||
|
||||
\ include ../flib/spi/rf69.fs |
||||
\ include ../flib/any/varint.fs |
||||
include ../flib/i2c/ssd1306.fs |
||||
include ../flib/mecrisp/graphics.fs |
||||
include ../flib/any/digits.fs |
||||
include ../flib/mecrisp/quotation.fs |
||||
include ../flib/mecrisp/multi.fs |
||||
|
||||
( core end, size: ) here dup hex. swap - . |
||||
cornerstone <<<core>>> |
||||
compiletoram |
@ -1,4 +0,0 @@ |
||||
\ send out periodic weak pings on a non-standard frequency |
||||
|
||||
compiletoram? [if] forgetram [then] |
||||
|
@ -1,11 +0,0 @@ |
||||
\ frozen application, this runs tests and wipes to a clean slate if they pass |
||||
|
||||
include always.fs |
||||
include board.fs |
||||
include core.fs |
||||
|
||||
compiletoflash |
||||
include dev.fs |
||||
|
||||
\ run tests, even when connected (especially so, in fact!) |
||||
: init init ( unattended ) ; |
Binary file not shown.
@ -1,10 +1,11 @@ |
||||
This code runs on the bat board (rev2), by flabbergast. |
||||
This code runs on the [bat board], with L052 MCU. |
||||
|
||||
* default I2C: B7/SDA, B6/SCL (tricky to change, at one point |
||||
it's hardcoded into jcw's driver) |
||||
* default SPI: PB8/ssel, PB5/MOSI, PB4/MISO, PB3/SCLK (this is enough |
||||
for a RFM69) |
||||
* default SPI: PB8/ssel, PB5/MOSI, PB4/MISO, PB3/SCLK |
||||
* also defined: |
||||
* LED = PA15, active: set/high |
||||
* BTN = PA1, pressed: true |
||||
|
||||
|
||||
[bat board]: https://flabbergast.drak.xyz/bat-board |
||||
|
@ -1,4 +0,0 @@ |
||||
\ send out periodic weak pings on a non-standard frequency |
||||
|
||||
compiletoram? [if] forgetram [then] |
||||
|
@ -1,11 +0,0 @@ |
||||
\ frozen application, this runs tests and wipes to a clean slate if they pass |
||||
|
||||
include always.fs |
||||
include board.fs |
||||
include core.fs |
||||
|
||||
compiletoflash |
||||
include dev.fs |
||||
|
||||
\ run tests, even when connected (especially so, in fact!) |
||||
: init init ( unattended ) ; |
Binary file not shown.
@ -1,25 +0,0 @@ |
||||
: rtc@ ( -- c c c c c c c ) |
||||
$68 i2c-addr 0 >i2c 7 i2c-xfer |
||||
i2c> i2c> i2c> i2c> i2c> i2c> i2c> ; |
||||
|
||||
: rtc! ( c c c c c c c -- nak ) |
||||
$68 i2c-addr 0 |
||||
>i2c >i2c >i2c >i2c >i2c >i2c >i2c >i2c |
||||
0 i2c-xfer ; |
||||
|
||||
: bin>bcd ( c -- c ) |
||||
#10 u/mod #4 lshift or ; |
||||
|
||||
: set-time ( year month date day hour min sec -- ) |
||||
>r >r >r >r >r >r |
||||
$00 swap \ 11 = 4.096 KHz output 00 = no output |
||||
bin>bcd \ Year 0-99 |
||||
r> bin>bcd \ Month |
||||
r> bin>bcd \ Date |
||||
r> \ Day 1-7 |
||||
r> bin>bcd \ Hours |
||||
r> bin>bcd \ Minutes |
||||
r> bin>bcd \ Seconds |
||||
rtc! |
||||
; |
||||
|
@ -1,4 +0,0 @@ |
||||
|
||||
: testread $50 i2c-addr 0 >i2c 0 >i2c 0 i2c-xfer 3 i2c-xfer i2c> i2c> i2c> ; |
||||
: testwrite $50 i2c-addr 0 >i2c 0 >i2c 1 >i2c 2 >i2c 0 i2c-xfer ; |
||||
|
@ -1,4 +0,0 @@ |
||||
\ send out periodic weak pings on a non-standard frequency |
||||
|
||||
compiletoram? [if] forgetram [then] |
||||
|
@ -1,11 +0,0 @@ |
||||
\ frozen application, this runs tests and wipes to a clean slate if they pass |
||||
|
||||
include always.fs |
||||
include board.fs |
||||
include core.fs |
||||
|
||||
compiletoflash |
||||
include dev.fs |
||||
|
||||
\ run tests, even when connected (especially so, in fact!) |
||||
: init init ( unattended ) ; |
Loading…
Reference in new issue