Getting started with Fomu
2019-08-20Getting started with Fomu MicroPython
- Order a fomu at Crowd Supply
- Checkout the Fomu workshop
Install micropython on Fomu
$ dfu-util.exe -D micropython-fomu.dfu
Boot current program
$ dfu-util.exe -e
Use miniterm to connect to the Fomu
- Install pyserial
pip install pyserial
- Start miniterm and connect to MicroPython shell running on the Fomu.
python -m serial.tools.miniterm
Readout the sensors and set the leds
Print out the button status
import machine
print(bin(machine.mem32[0xe0005808]))
Sleep function
import machine
def timer0_value_read():
r = machine.mem32[0xe0002828]
r = r << 8
r = r | machine.mem32[0xe000282c]
r = r << 8
r = r | machine.mem32[0xe0002830]
r = r << 8
r = r | machine.mem32[0xe0002834]
return r
def sleep(seconds):
# timer0_en_write
machine.mem32[0xe0002820]=0
# timer0_reload_write
machine.mem32[0xe0002810]=0
machine.mem32[0xe0002814]=0
machine.mem32[0xe0002818]=0
machine.mem32[0xe000281c]=0
# timer0_load_write
ms = 12000000 * seconds
machine.mem32[0xe0002800]=ms>>24
machine.mem32[0xe0002804]=ms>>16
machine.mem32[0xe0002808]=ms>>8
machine.mem32[0xe000280c]=ms
# timer0_en_write
machine.mem32[0xe0002820]=1
# timer0_update_value_write
machine.mem32[0xe0002824]=1
while timer0_value_read():
# timer0_update_value_write
machine.mem32[0xe0002824]=1
See time.c for more
RGB
For more addresses see: https://github.com/im-tomu/fomu-workshop/blob/master/riscv-blink/include/generated/csr.h
TODO