From 0f4f3b02cf4cf0596cb41b1bb14fac13a904635d Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Wed, 18 Dec 2019 10:45:49 -0500 Subject: better comments --- microwire.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/microwire.lua b/microwire.lua index 993a8b5..e2b5654 100644 --- a/microwire.lua +++ b/microwire.lua @@ -34,21 +34,24 @@ function microwire_setup_interface () end function microwire_send_data( data ) - -- essentially send data via spi interface and raise Load Enable + -- essentially send data via spi interface + -- and raise Load Enable pin for a bit (at least for25 nS) at the end of transmission + -- first low LE pin gpio.write(microwire_sle, gpio.LOW) + -- second send the data local nBytes = spi.send(spiID, data) + -- finally raise LE pin for at least 25 ns, - gpio.write(microwire_sle, gpio.HIGH) -- but since optocoupler is limiting us we will do it for longer - local microwireLEonTime = 100; -- in uS + 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; -- now time is in mS + microwireLEonTime = 1; -- time is in mS for timers microwire_tmr = tmr.create() microwire_tmr:register(microwireLEonTime, tmr.ALARM_SINGLE, function() gpio.write(microwire_sle, gpio.LOW) end) microwire_tmr:start() -- cgit v1.2.3