Browse Source

Bat board fixes and sleep-test.

across
flabbergast 3 years ago
parent
commit
abf8b5ffb7
  1. 6
      bat-board-l052/README.md
  2. 9
      bat-board-l052/board.fs
  3. 1
      bat-board-l052/core.fs
  4. 55
      bat-board-l052/ex/sleep-test.fs

6
bat-board-l052/README.md

@ -7,5 +7,11 @@ This code runs on the [bat board], with L052 MCU. @@ -7,5 +7,11 @@ This code runs on the [bat board], with L052 MCU.
* LED = PA15, active: set/high
* BTN = PA1, pressed: true
## Power consumption notes
Tried running `ex/sleep-test.fs` `lp-blips` powered through
the voltage regulator with 5V, and the consumption was about 4uA. This
is really good; the regulator seems to really take only about 1.5-2uA.
[bat board]: https://flabbergast.drak.xyz/bat-board

9
bat-board-l052/board.fs

@ -14,8 +14,15 @@ include ../flib/stm32l0/hal.fs @@ -14,8 +14,15 @@ 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
include ../flib/mecrisp/multi.fs
PB8 constant SCL
PB9 constant SDA
: i2c-pafs ( -- ) \ set alternate function for SDA/SCL pins
PB8 io-base $24 + \ register addr \ ($24:GPIO.AFRH)
dup @ $FFFFFF00 and $11 or ! ;
include ../flib/stm32l0/i2c.fs
PB8 variable ssel \ can be changed at run time
PB3 constant SCLK

1
bat-board-l052/core.fs

@ -10,7 +10,6 @@ include ../flib/i2c/ssd1306.fs @@ -10,7 +10,6 @@ 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>>>

55
bat-board-l052/ex/sleep-test.fs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
: lp-blink ( -- )
led-off 2.1MHz 1000 systick-hz
lptim-init
only-msi
begin stop10s led iox! again ;
: lp-blips ( -- )
led-off \ led off
2.1MHz 1000 systick-hz \ slow down the clock, adjust systick accordingly
lptim-init \ initialise the low-power timer
only-msi
begin
led-on sleep led-off \ a very short 1ms LED blip, but still visible
stop10s \ enter stop mode for approx 10 seconds
again ;
: highz-gpio
IMODE-ADC PA0 io-mode!
IMODE-ADC PA1 io-mode!
IMODE-ADC PA2 io-mode!
IMODE-ADC PA3 io-mode!
IMODE-ADC PA4 io-mode!
IMODE-ADC PA5 io-mode!
IMODE-ADC PA6 io-mode!
IMODE-ADC PA7 io-mode!
IMODE-ADC PA8 io-mode!
IMODE-ADC PA9 io-mode!
IMODE-ADC PA10 io-mode!
IMODE-ADC PA11 io-mode!
IMODE-ADC PA12 io-mode!
IMODE-ADC PA13 io-mode!
IMODE-ADC PA14 io-mode!
\ IMODE-ADC PA15 io-mode! \ LED
IMODE-ADC PB0 io-mode!
IMODE-ADC PB1 io-mode!
IMODE-ADC PB2 io-mode!
IMODE-ADC PB3 io-mode!
IMODE-ADC PB4 io-mode!
IMODE-ADC PB5 io-mode!
IMODE-ADC PB6 io-mode!
IMODE-ADC PB7 io-mode!
IMODE-ADC PB8 io-mode!
IMODE-ADC PB9 io-mode!
IMODE-ADC PB10 io-mode!
IMODE-ADC PB11 io-mode!
IMODE-ADC PB12 io-mode!
IMODE-ADC PB13 io-mode!
IMODE-ADC PB14 io-mode!
IMODE-ADC PB15 io-mode!
IMODE-ADC PD0 io-mode!
IMODE-ADC PD1 io-mode!
IMODE-ADC PC13 io-mode!
IMODE-ADC PC14 io-mode!
IMODE-ADC PC15 io-mode! ;
Loading…
Cancel
Save