1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
--[[
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
|