Update READMEs and clean up.

across
flabbergast 4 years ago
parent bf3a457437
commit 06c9611f6a
  1. 56
      README.md
  2. 10
      bat-board-f072/README.md
  3. 22
      bat-board-f072/always.fs
  4. 68
      bat-board-f072/board.fs
  5. 17
      bat-board-f072/core.fs
  6. 4
      bat-board-f072/dev.fs
  7. 11
      bat-board-f072/freeze.fs
  8. BIN
      bat-board-l052/L052-Mecrisp
  9. 7
      bat-board-l052/README.md
  10. 4
      bat-board-l052/dev.fs
  11. 11
      bat-board-l052/freeze.fs
  12. BIN
      bat-board-l052/l053-mecrisp-2.3.9.bin
  13. 0
      deploy/ina219-board/README.md
  14. 0
      deploy/ina219-board/freeze.fs
  15. 0
      deploy/ina219-board/g6s-base/always.fs
  16. 28
      deploy/ina219-board/g6s-base/board.fs
  17. 3
      deploy/ina219-board/g6s-base/core.fs
  18. 0
      deploy/ina219-board/ina219.fs
  19. 0
      deploy/ina219-board/suf-maplemini.bin
  20. 25
      ina219-board/ds1307.fs
  21. 4
      ina219-board/eep.fs
  22. 4
      sbo-l041/dev.fs
  23. 11
      sbo-l041/freeze.fs

@ -1,21 +1,29 @@
Forth code for Mecrisp (Stellaris)
==================================
Forth code for Mecrisp (+Stellaris)
===================================
It is intended for my home environmental sensor collection, and miscellaneous hobbyist devices.
Primarily for [jeenode zero], but for a few of my own boards/variations as well.
It is intended for my home environmental sensor collection, and miscellaneous
hobbyist devices. Primarily for [jeenode zero], but for a few of my own
boards/variations as well.
Most of the code actually comes from Jean-Claude Wippler's [embello] collection. I've kept the
structure from that repo, so to go back over embello, it is possible to just copy the files into
`explore/1608-forth` directory. There are naturally some changes to some of jcw's code, so
your mileage may vary. I decided not to fork the [embello] repo, because it contains too
much more than just the forth code, and I find it overwhelming.
Most of the code is actually sliced out from Jean-Claude Wippler's [embello]
collection. I've kept the structure from that repo, so to go back over embello,
it is possible to just copy the files into `explore/1608-forth` directory.
There are naturally some changes to some of jcw's code, so your mileage may
vary. I decided not to fork the [embello] repo, because it contains too much
more than just the forth code, and I find it overwhelming.
Since my goal is to have some long-running sensors reporting over RFM69 radios, the focus
is on the `rf69` driver, sensor code (usually over I2C, but sometimes over SPI), and
sleep code.
Since my goal is to have some long-running sensors reporting over RFM69 radios,
the focus is on the `rf69` driver, sensor code (usually over I2C, but sometimes
over SPI), and sleep code.
Also, I bought some STM32L041 chips (TSSOP-20 package), and these buggers only have 32k flash.
So, I found myself minimizing code dependencies (maybe having min/extra sources).
Also, I bought some STM32L041 chips (TSSOP-20 package), and these buggers only
have 32k flash. So, I found myself minimizing code dependencies (having
min/extra split in the sources).
Finally, there is some code for MSP430, mainly MSP430G2553. These have amazingly
low power consumption and a convenient sleep mode, although small flash and RAM.
So the code for these is more-less very stripped down version of the Stellaris
code.
Motivation
@ -37,11 +45,31 @@ That code is [here][my-jee-sensors]; in particular my gateway is an atmega328p
on pocket beagle - described [here][pb-cape].
Layout
------
- `flib` is the main library of code (mostly jcw's and from mecrisp stellaris):
L0 and F1 drivers, communication drivers with some external devices (e.g. some
sensors).
- `deploy` contains "turnkey" code for some hardware devices that I have.
- `cores` has some mecrisp stellaris binaries.
- `jz4` has the sources for the embello/"release" firmware for [jeenode zero],
plus a few extra "development" files: I use jz4 for development because it
has plenty of flash, so various "convenience" bits (hexdumps, prettyprint,
disasm,...) fit into flash without any compromises.
- `bat-board-l052` and `sbo-l041` are two of my homebrew boards: [bat board]
and a try-out board for TSSOP-20 packaged STM32L041.
- `msp430`: this code is for [mecrisp], 16bit forth running on TI's
MSP430G2553 and MSP430FR2433 MCUs. The space is very tight on these
(the G2553 with mecrisp has 5kB flash and 160 bytes RAM available).
[jeenode zero]: https://www.digitalsmarties.net/products/jeenode-zero
[embello]: https://git.jeelabs.org/jcw/embello
[folie]: https://git.jeelabs.org/jcw/folie
[Mecrisp Stellaris]: https://mecrisp.sourceforge.net
[mecrisp]: https://mecrisp.sourceforge.net
[my-jee-sensors]: https://git.drak.xyz/flabbergast/jee-sensors
[pb-cape]: https://flabbergast.drak.xyz/posts/pb-rfmcape
[bat board]: https://flabbergast.drak.xyz/bat-board

@ -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 ) ;

@ -9,20 +9,20 @@ compiletoflash
4 constant io-ports \ A..D
50 constant I2C.DELAY
include ../../flib/mecrisp/calltrace.fs
include ../../flib/mecrisp/cond.fs
include ../../flib/mecrisp/hexdump.fs
include ../../flib/stm32f1/io.fs
include ../../flib/pkg/pins64.fs
include ../../flib/stm32f1/hal.fs
include ../../flib/stm32f1/spi.fs
include ../../flib/any/ring.fs
include ../../flib/stm32f1/i2c.fs
\ include ../../flib/any/i2c-bb.fs
include ../../flib/stm32f1/timer.fs
include ../../flib/stm32f1/pwm.fs
include ../../flib/stm32f1/adc.fs
include ../../flib/stm32f1/rtc.fs
include ../../../flib/mecrisp/calltrace.fs
include ../../../flib/mecrisp/cond.fs
include ../../../flib/mecrisp/hexdump.fs
include ../../../flib/stm32f1/io.fs
include ../../../flib/pkg/pins64.fs
include ../../../flib/stm32f1/hal.fs
include ../../../flib/stm32f1/spi.fs
include ../../../flib/any/ring.fs
include ../../../flib/stm32f1/i2c.fs
\ include ../../../flib/any/i2c-bb.fs
include ../../../flib/stm32f1/timer.fs
include ../../../flib/stm32f1/pwm.fs
include ../../../flib/stm32f1/adc.fs
include ../../../flib/stm32f1/rtc.fs
PB1 constant LED
PB8 constant BTN

@ -4,8 +4,5 @@
compiletoflash
( core start: ) here hex.
include ../../flib/mecrisp/multi.fs
include ../../flib/any/timed.fs
cornerstone <<<core>>>
hello

@ -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…
Cancel
Save