diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2019-12-18 11:34:31 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2019-12-18 11:34:31 -0500 |
commit | 93329d7a663117d31f8d983b67b101b858008638 (patch) | |
tree | 92ea96ef309420a69fa984998224f128c74bc1ce /microwire.lua | |
parent | e4603ac02c463d86b88ccd4b1a02be5e678ea270 (diff) | |
download | nodeMCU_rf_source_lmx2487-93329d7a663117d31f8d983b67b101b858008638.tar.gz nodeMCU_rf_source_lmx2487-93329d7a663117d31f8d983b67b101b858008638.zip |
get rid of timers, pin toggling is slow enough
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() |