--[[ 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 a register needs update set to true, updater script will resend this register lmx2487_need_update = {true, true, true, true, true, true, true, true} 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 get_lmx2487register(register) -- register labeled 0, 1, 2, ..., 7 local value = (lmx2487_registers[register+1]) --print("register " .. register .. " is set to " .. value) return value end 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() 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) lmx2487_need_update = {true, true, true, true, true, true, true, true} 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