summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--microwire.lua11
1 files 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()