From 0ba63b54e0faecc7f0c0ccc0dbbaddfd92f90408 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 23 Jan 2020 17:36:26 -0500 Subject: draft of rf lib --- lmx2487lib.lua | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lmx2487lib.lua diff --git a/lmx2487lib.lua b/lmx2487lib.lua new file mode 100644 index 0000000..8cdb36f --- /dev/null +++ b/lmx2487lib.lua @@ -0,0 +1,49 @@ +-- 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} + +function set_lmx2487register(value, register) + -- register labeled 0, 1, 2, ..., 7 + if (lmx2487_registers[register+1] ~= value) then + -- 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) + end + -- otherwise we do nothing +end + +function send_register_lmx2487( register) + if ( lmx2487_need_update[register] ) then + print("sending register " .. register .. " with value " .. lmx2487_registers[register]) + -- do hardware talking + lmx2487_need_update[register]=false + end +end + +function update_lmx2487state() + for register=7,0,-1 do + -- going over registers + -- manual suggest to send R0 as last one + send_register_lmx2487( register ) + end +end + + +function set_lmx2487_board_to_default_state() + -- this defaults are historic and borrowed from lmx2487lib.tcl + -- defaults (set RF freq to 6.83468635e9 GHz and lock it to 10MHz oscillator) + set_lmx2487register(11197502 , 0) + set_lmx2487register(4352515 , 1) + set_lmx2487register(8560613 , 2) + set_lmx2487register(15925287 , 3) + set_lmx2487register(10618633 , 4) + set_lmx2487register(393579 , 5) + set_lmx2487register(8126541 , 6) + set_lmx2487register(10639 , 7) + + update_lmx2487state() +end + -- cgit v1.2.3