summaryrefslogtreecommitdiff
path: root/lmx2487lib.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lmx2487lib.lua')
-rw-r--r--[-rwxr-xr-x]lmx2487lib.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/lmx2487lib.lua b/lmx2487lib.lua
index 1034e0f..9250f72 100755..100644
--- a/lmx2487lib.lua
+++ b/lmx2487lib.lua
@@ -1,8 +1,13 @@
+ --[[
+Eugeniy Mikhailov
+1 June 2021
+ (copied over from past work)]]
+
-- there are 8 registers to track for lmx2487
-- labeled R0, R1, ..., R7 in the manual
lmx2487_registers = {0, 0, 0, 0, 0, 0, 0, 0}
-- if need update set to true updater script will resend this register
-lmx2487_need_update = {false, false, false, false, false, false, false, false}
+lmx2487_need_update = {false, false, false, false, false, false, false, false}
function set_lmx2487register(value, register)
-- register labeled 0, 1, 2, ..., 7
@@ -10,28 +15,30 @@ function set_lmx2487register(value, register)
-- this is new value and thus needs to be updated in hardware
lmx2487_registers[register+1] = value
lmx2487_need_update[register+1] = true
- print("updating register " .. register .. " with value " .. value)
+ --print("updating register " .. register .. " with value " .. value)
end
-- otherwise we do nothing
end
function get_lmx2487register(register)
-- register labeled 0, 1, 2, ..., 7
- local value = (lmx2487_registers[register+1])
- print("register " .. register .. " is set to " .. value)
+ local value = (lmx2487_registers[register+1])
+ --print("register " .. register .. " is set to " .. value)
return value
end
-function send_register_lmx2487(register)
+function send_register_lmx2487( register)
if ( lmx2487_need_update[register +1] ) then
+ --print(tmr.now())
print("sending register " .. register .. " with value " .. get_lmx2487register( register ) )
+ --print(tmr.now())
-- do hardware talking
microwire_send_data( get_lmx2487register( register ) )
lmx2487_need_update[register+1]=false
end
end
-function update_lmx2487state()
+function update_lmx2487state()
for register=7,0,-1 do
-- going over registers
-- manual suggest to send R0 as last one