we have a Pyboard 1.1 plus an IC connected to it via SPI bus. We need to read some data from the IC at 10 Hz and store it so that my main loop (that run at 2Hz) is able to read such data, perform some calcs, free memory then send the results via serial to another module. We thought to read SPI data within an ISR like this:
Code: Select all
global myvar # any hint on a variable type suitable ?
def lux(r):
global myvar
# read SPI data and store it in myvar
mytimer = pyb.Timer(9, freq = 10)
mytimer.callback(lux)
while True: # main loop
# read myvar
# send read data to UART...
# pyb.delay(...)