summaryrefslogtreecommitdiff
path: root/lmx2487lib.lua
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-06-11 12:08:36 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-06-11 12:08:36 -0400
commit4d58139b58c7eddc67f3838ac602c0d5b59e286f (patch)
treede3268e4933baa878b98aabcc9de5c9e13e5c765 /lmx2487lib.lua
parent48435e643bee9b85451e1a4199e8c45ad379693f (diff)
downloadnodeMCU_rf_source_lmx2487-4d58139b58c7eddc67f3838ac602c0d5b59e286f.tar.gz
nodeMCU_rf_source_lmx2487-4d58139b58c7eddc67f3838ac602c0d5b59e286f.zip
use local variables in function FreqToSettings
Diffstat (limited to 'lmx2487lib.lua')
-rw-r--r--lmx2487lib.lua20
1 files changed, 10 insertions, 10 deletions
diff --git a/lmx2487lib.lua b/lmx2487lib.lua
index ff4841f..42f94be 100644
--- a/lmx2487lib.lua
+++ b/lmx2487lib.lua
@@ -101,9 +101,9 @@ mask_bits13andAbove = bit.bnot(mask_low12bits)
function FreqToSettings(freq)
local freq, RF_N, RF_FN, RF_FD = freq2regestersValues(freq)
- R0_new=get_lmx2487register(0)
- R1_new=get_lmx2487register(1)
- R5_new=get_lmx2487register(5)
+ local R0_new=get_lmx2487register(0)
+ local R1_new=get_lmx2487register(1)
+ local R5_new=get_lmx2487register(5)
-- This code is extremely convoluted, refer to the lmx2487 manual
-- to see what bits are used in what place in a register.
@@ -111,27 +111,27 @@ function FreqToSettings(freq)
-- tableReplace( Rn, bitSlice(..), stPos, endPos)
-- settings["R0"]=tableReplace(settings["R0"], bRF_N, 14, 24)
- bitsRF_N = bit.lshift(RF_N, 13)
+ local bitsRF_N = bit.lshift(RF_N, 13)
R0_new = bit.band(R0_new, bit.bnot(mask_bits14to24))
R0_new = bit.bor(R0_new, bitsRF_N)
-- settings["R0"]=tableReplace(settings["R0"], bitSlice(bRF_FN, 1, 12), 2, 13)
- bitsRF_FN_low = bit.band( RF_FN, mask_low12bits)
+ local bitsRF_FN_low = bit.band( RF_FN, mask_low12bits)
R0_new = bit.band(R0_new, bit.bnot(mask_bits2to13))
R0_new = bit.bor(R0_new, bit.lshift(bitsRF_FN_low,1))
-- settings["R1"]=tableReplace(settings["R1"], bitSlice(bRF_FD, 1, 12), 5, 16)
- bitsRF_FD_low = bit.band( RF_FD, mask_low12bits)
+ local bitsRF_FD_low = bit.band( RF_FD, mask_low12bits)
R1_new = bit.band(R1_new, bit.bnot(mask_bits5to16))
R1_new = bit.bor(R1_new, bit.lshift(bitsRF_FD_low,4))
-- settings["R5"]=tableReplace(settings["R5"], bitSlice(bRF_FN, 13, 22), 5, 14)
-- settings["R5"]=tableReplace(settings["R5"], bitSlice(bRF_FD, 13, 22), 15, 24)
- RF_FN_above_12 = bit.band( RF_FN, mask_bits13andAbove)
- RF_FN_part = bit.rshift(RF_FN_above_12, 12)
+ local RF_FN_above_12 = bit.band( RF_FN, mask_bits13andAbove)
+ local RF_FN_part = bit.rshift(RF_FN_above_12, 12)
RF_FD_above_12 = bit.band( RF_FD, mask_bits13andAbove)
- RF_FD_above_12 = bit.rshift( RF_FD_above_12, 2)
- new_bits = bit.bor(RF_FN_part, RF_FD_above_12)
+ local RF_FD_above_12 = bit.rshift( RF_FD_above_12, 2)
+ local new_bits = bit.bor(RF_FN_part, RF_FD_above_12)
R5_new = bit.band(R5_new, bit.bnot(mask_bits5to24))
R5_new = bit.bor(R5_new, bit.lshift(new_bits,4))