diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-07-19 14:24:46 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-07-19 14:24:46 +0200 |
commit | 7b89bb8a846f7a22a908d6be237b6e6dd042e282 (patch) | |
tree | dc37e26a38091ff47ca6d15ed44ab1b1c51172d4 /src/target/firmware/rf | |
parent | 7ea81070fae0a75ed7aba006948437da42201e28 (diff) |
[firmware] TRF6151: fix VGA gain calculation bug
We've had two sets of TRF6151 GAIN related #defines which were used
in an incorrect manner, resulting in a vga_gain of 60, which is
outside of the allowed gain range.
Thanks to Dieter Spaar for spotting this bug
Diffstat (limited to 'src/target/firmware/rf')
-rw-r--r-- | src/target/firmware/rf/trf6151.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/target/firmware/rf/trf6151.c b/src/target/firmware/rf/trf6151.c index 4d0541d7..1d000fd7 100644 --- a/src/target/firmware/rf/trf6151.c +++ b/src/target/firmware/rf/trf6151.c @@ -471,7 +471,7 @@ void trf6151_compute_gain(int16_t exp_inp, int16_t target_bb) int16_t exp_bb_dbm8, delta_dbm8; int16_t exp_inp_dbm8 = to_dbm8(exp_inp); int16_t target_bb_dbm8 = to_dbm8(target_bb); - int16_t vga_gain = TRF6151_GAIN_MIN; + int16_t vga_gain = TRF6151_VGA_GAIN_MIN; int high = 0; /* calculate the dBm8 that we expect at the baseband */ @@ -483,17 +483,18 @@ void trf6151_compute_gain(int16_t exp_inp, int16_t target_bb) /* If this is negative or less than TRF6151_GAIN_MIN, we are pretty * much lost as we cannot reduce the system inherent gain. If it is * positive, it corresponds to the gain that we need to configure */ - if (delta_dbm8 < to_dbm8(TRF6151_GAIN_MIN)) { + if (delta_dbm8 < to_dbm8(TRF6151_FE_GAIN_LOW + TRF6151_VGA_GAIN_MIN)) { printd("AGC Input level overflow\n"); high = 0; - vga_gain = TRF6151_GAIN_MIN; - } else if (delta_dbm8 > to_dbm8(TRF6151_GAIN_FE + TRF6151_GAIN_MIN)) { + vga_gain = TRF6151_VGA_GAIN_MIN; + } else if (delta_dbm8 > to_dbm8(TRF6151_FE_GAIN_HIGH + + TRF6151_VGA_GAIN_MIN)) { high = 1; - delta_dbm8 -= to_dbm8(TRF6151_GAIN_FE); + delta_dbm8 -= to_dbm8(TRF6151_FE_GAIN_HIGH); } vga_gain = delta_dbm8/8; - if (vga_gain > TRF6151_GAIN_MAX) - vga_gain = TRF6151_GAIN_MAX; + if (vga_gain > TRF6151_VGA_GAIN_MAX) + vga_gain = TRF6151_VGA_GAIN_MAX; /* update the static global variables which are used when programming * the window */ |