diff options
Diffstat (limited to 'microwire.lua')
-rw-r--r-- | microwire.lua | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/microwire.lua b/microwire.lua index d50b395..c6d97e8 100644 --- a/microwire.lua +++ b/microwire.lua @@ -41,24 +41,18 @@ function microwire_send_data( data ) -- essentially send data via spi interface -- and raise Load Enable pin for a bit (at least for 25 nS) at the end of transmission - -- first low LE pin + -- first low LE pin, it should be low but just to be sure gpio.write(microwire_LE_pin, gpio.LOW) -- second send the data local nBytes = spi.send(spiID, data) + -- finally raise LE pin for at least 25 ns, + -- note that it takes about 300 uS on ESP8266 before LE will be HIGH after spi.send gpio.write(microwire_LE_pin, gpio.HIGH) - -- but since optocoupler is limiting us we will do it for longer - local microwireLEonTime = 100; -- time is in uS - - -- the easiest to use tmr.delay( timeIn_uS ) but this halts everything - -- tmr.delay( microwireLEonTime ) - -- so we use timer but unfortunately the smallest time is 1ms - microwireLEonTime = 1; -- time is in mS for timers - microwire_tmr = tmr.create() - microwire_tmr:register(microwireLEonTime, tmr.ALARM_SINGLE, function() gpio.write(microwire_LE_pin, gpio.LOW) end) - microwire_tmr:start() + -- we immediately drop LE pin to low, Scope shows that the pin will be on for 80 uS + gpio.write(microwire_LE_pin, gpio.LOW) end microwire_setup_interface() |