\ Program Name: ms-loadmeter.fs \ Edit template.xml, commenting out unwanted register lines ( F9 ), then run 'make' \ Date: Tue 9 May 2017 05:29:17 AEST \ Copyright 2017 t.porter Released under the GPL \ For Mecrisp-Stellaris by Matthias Koch \ Chip: STM32F051 \ Board: STM32F0 Discovery Board \ Terminal: e4thcom Copyright (C) 2013-2017 Manfred Mahlow; https://wiki.forth-ev.de/doku.php/en:projects:e4thcom \ Clock: 8 Mhz using the internal STM32F051 RC clock, unless otherwise stated \ All register names must be CMSIS-SVD compliant \ \ This Program Does: Indicates MCU load using a external uA moving coil meter. \ \ Inputs: none \ Outputs: PF-1 \ \ ------------------ USER CODE HERE ------------------ \ compiletoflash \ seems that compiletoflash is reset to compiletoram after each upload ? #require f0-id.fs \ Optional development word compiletoflash #require memstat.fs \ Optional development word compiletoflash #require dict.fs \ Optional development word compiletoflash #require f0-legends.fs compiletoflash #require ms-loadmeter.memmap.fs compiletoflash #require multitask.fs compiletoflash \ Initialisations %01 2 lshift GPIOF_MODER bis! \ use PF-1 as meter driver o/p %01 18 lshift GPIOC_MODER bis! \ PC-9 as output %01 16 lshift GPIOC_MODER bis! \ PC-8 as outpu : .5s-delay 25000 0 do pause loop ; \ Used by Blinky : delay-1 50000 0 do pause loop ; \ 1 second delay : delay-2 50000 0 do pause loop ; : green-on %1 9 lshift GPIOC_BSRR bis! ; \ Activated by User pushbutton : green-off %1 9 lshift GPIOC_BRR bis! ; : blue-on %1 8 lshift GPIOC_BSRR bis! ; \ Activated by Blinky : blue-off %1 8 lshift GPIOC_BRR bis! ; : meter-high %1 1 lshift GPIOF_BSRR bis! ; \ PF-1 high : meter-low %1 17 lshift GPIOF_BSRR bis! ; \ PF-1 low : blink blue-on .5s-delay blue-off .5s-delay ; : pb? ( -- ? ) 1 0 lshift GPIOA_IDR bit@ \ test User pushbutton, lights green led if pressed if green-on else green-off then pause ; : loadmeter meter-high nop nop \ some small delays to extend the meter pulse as this mcu is so fast meter-low pause ; task: loadmeter-task : load& ( -- ) loadmeter-task activate begin loadmeter again ; task: blinktask : blinky& ( -- ) blinktask activate begin blink again ; task: delay1 : delay1& ( -- ) delay1 activate begin delay-1 again ; task: delay2 : delay2& ( -- ) delay2 activate begin delay-2 again ; task: user-pb-task : user-pb& ( -- ) user-pb-task activate begin pb? again ; \ multitask load& blinky& delay1& delay2& user-pb& id \ Optional development word mem \ Optional development word multitask