Browse Source

Adjust comments.

master
flabbergast 2 years ago
parent
commit
0d8bc62180
  1. 8
      msp430/g2553/basis-sensor.fs
  2. 38
      msp430/g2553/sensor-bmp.fs
  3. 2
      suf072/README.md
  4. 8
      suf072/hal-stm32f07.fs
  5. 2
      suf072/usb.fs
  6. 5
      suf072/usbbase-f042.fs
  7. 7
      suf072/usbbase-f072.fs

8
msp430/g2553/basis-sensor.fs

@ -37,13 +37,13 @@ include ../flib/g2553/i2c-bb-base.fs
include ../flib/drivers/i2c-bb.fs
: unfree-pins ( -- )
%00011001 dup $22 cbis! $21 cbic! \ for uart add %110 ($22:P1DIR) ($21:P1OUT)
%00001110 dup $2A cbis! $29 cbic! \ for i2c add %110000 ($2A:P2DIR) ($29:P2OUT)
%00011001 dup $22 ( P1DIR ) cbis! $21 ( P1OUT ) cbic! \ for uart add %110
%00001110 dup $2A ( P2DIR ) cbis! $29 ( P2OUT ) cbic! \ for i2c add %110000
;
: analog-off ( -- )
%10 $1b0 bic! \ dis ENC \ ($1b0:ADC10CTL0)
%110000 $1b0 bic! \ dis REFON|ADC10ON \ ($1b0:ADC10CTL0)
%10 $1b0 ( ADC10CTL0 ) bic! \ dis ENC
%110000 $1b0 ( ADC10CTL0 ) bic! \ dis REFON|ADC10ON
;
compiletoram

38
msp430/g2553/sensor-bmp.fs

@ -1,6 +1,19 @@
\ sensor board deployed with BMP280
\ when reset with UART connected, it should drop into prompt
\ otherwise init devices, sleep and periodically send readings
\ G2553 sensor board deployed with BMP280
\ 2019 flabbergast (public domain: https://unlicense.org/)
\ expects this hardware: https://flabbergast.drak.xyz/posts/msp430-2/#links
\ summary:
\ - 32768Hz crystal between P2.6 and P2.7
\ - RFM69CW radio on P1.5:SCK, P1.6:MISO, P1.7:MOSI (USCI_B0 spi), P2.0 CS
\ - BMP280 sensor on P2.4:SCL, P2.5:SDA (bit-banged I2C)
\ - nothing else (pins are outputs/down)
\ - runs on clean *lowpower* mecrisp on MSP430G2553
\ when reset with UART connected, it should drop into prompt
\ otherwise init devices, sleep and periodically send readings
\ for radio settings see 'radio setup' (group,id,encryption,packet structure)
\ "jeenode-style" packets
include basis-sensor.fs
@ -9,6 +22,7 @@ compiletoflash
\ sensor driver
include ../flib/drivers/bmp280.fs
\ ------------------------------
\ radio setup (change settings!)
: enckey s" beleampanchineto" drop ;
@ -21,7 +35,6 @@ include ../flib/drivers/bmp280.fs
rf-sleep
;
\ packet setup (adjust!)
\ 63 constant GW_ID
\ 9 constant PKTLEN
@ -41,15 +54,15 @@ include ../flib/drivers/bmp280.fs
;
: deinit-uart ( -- )
%110000 $1 cbic! \ disable USART interrupts ($1:IE2)
%110 dup $26 cbic! \ ($26:P1SEL)
dup $41 cbic! \ ($41:P1SEL2)
dup $22 cbis! \ ($22:P1DIR)
$21 cbic! \ ($21:P1OUT)
%110000 $1 ( IE2 ) cbic! \ disable USART interrupts
%110 dup $26 ( P1SEL ) cbic!
dup $41 ( P1SEL2 ) cbic!
dup $22 ( P1DIR ) cbis!
$21 ( P1OUT ) cbic!
;
: packet-prepare ( -- ) \ get all measurements (separated for testing)
vcc \ get 1000*vdd
vcc ( mV )
analog-off
pbatt !
@ -59,18 +72,19 @@ include ../flib/drivers/bmp280.fs
;
: packet-send ( -- ) \ send over radio
ptype 9 63 rf-send \ PKTLEN GW_ID
ptype 9 ( PKTLEN ) 63 ( GW_ID ) rf-send
rf-sleep
;
\ this runs as the main program
: main ( -- )
1000 ms \ give battery a break after boot
begin
packet-prepare
packet-send
420 0 do 1000 ms loop
420 0 do 1000 ms loop \ sleep 7 minutes
again ;
: init unattended init-once deinit-uart main ;

2
suf072/README.md

@ -16,7 +16,7 @@ So, getting this on the board requires:
1. Get a clean Mecrisp Stellaris on the board (using F072's built-in
bootloader, either USART or DFU).
2. Connect to the default USART console Mecrisp, and send over
`usbbase-bat-f072.fs` (with [folie], otherwise you'll need to manually
`usbbase-f072.fs` (with [folie], otherwise you'll need to manually
resolve the `include`s).
3. At this point, when you `reset` the board, no USART console shows up, and
the device should enumerate as an USB ACM device, over which you should be

8
suf072/hal-stm32f07.fs

@ -2,6 +2,8 @@
\ adapted from jcw's embello for STM32F103
\ adapted from mecrisp-stellaris 2.2.1a (GPL3)
\ for F042 version swap lines marked "|F072|" for the ones with "|F042|"
: 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
@ -9,7 +11,8 @@
: flash-kb ( -- u ) \ return size of flash memory in KB
$1FFFF7CC h@ ;
: flash-pagesize ( addr - u ) \ return size of flash page at given address
drop 2048 ; \ f07x f09x ; f03x f04x have 1024
drop 2048 ; \ |F072| (also f09x)
\ drop 1024 ; \ |F042| (also f03x)
: bit ( u -- u ) \ turn a bit position into a single-bit mask
1 swap lshift 1-foldable ;
@ -55,7 +58,8 @@ $40006C00 constant CRS
24 bit rcc-cr bis!
begin 25 bit rcc-cr bit@ until
%10 rcc-cfgr bis!
%11 rcc-cfgr3 bis! \ USART1 clocked from HSI
%11 rcc-cfgr3 bis! \ |F072| USART1 clocked from HSI
\ $1a1 $4000440C ! \ |F042| change USART2_BRR to match 48MHz
;
: usb-clk ( -- ) \ enable HSI48, autotrim and set USB clock source

2
suf072/usb.fs

@ -216,7 +216,7 @@ $40006000 constant USBMEM
$42 usb-pma@ case
$0100 of usb:dev 18 endof
$0200 of usb:conf $46 usb-pma@ endof
\ js: was 67 (issue is: first 9 bytes gets requested also separately)
\ js: was 67 (issue is: first 9 bytes get requested also separately)
$0300 of usb:langid 4 endof
$0301 of usb:vendor 40 endof
$0302 of usb:product 36 endof

5
suf072/usbbase-f042.fs

@ -1,4 +1,7 @@
\ USB console for the bat board with F072
\ USB console for F042
\ 2019 flabbergast (public domain: https://unlicense.org/)
\ https://git.drak.xyz/flabbergast/forth-mecrisp
\ modelled after Jean-Claude Wippler's USB console for F103 boards
\ in embello: https://git.jeelabs.org/jcw/embello

7
suf072/usbbase-bat-f072.fs → suf072/usbbase-f072.fs

@ -1,8 +1,11 @@
\ USB console for the bat board with F072
\ USB console for F072
\ 2019 flabbergast (public domain: https://unlicense.org/)
\ https://git.drak.xyz/flabbergast/forth-mecrisp
\ modelled after Jean-Claude Wippler's USB console for F103 boards
\ in embello: https://git.jeelabs.org/jcw/embello
$5000 eraseflashfrom \ this must be loaded on top of a *clean* Mecrisp image!
$5000 eraseflashfrom \ this must be loaded on top of a *clean* Mecrisp RA image!
cr
compiletoflash
Loading…
Cancel
Save