Skip to main content

image_calibration

Function image_calibration 

Source
pub const fn image_calibration(low_hz: u32, high_hz: u32) -> [u8; 2]
Expand description

Returns the two CalibrateImage codes that cover a band.

Section 9.2.1 calibrates image rejection between two codes in steps of 4 MHz, taking the floor of the lower edge and the ceiling of the upper one, so the calibrated range always covers the band.

Table 9-2 of the datasheet lists codes one step wider at the top for two bands, 0xD7 0xDB for 863 to 870 MHz and 0xE1 0xE9 for 902 to 928 MHz. Both cover the band; this is the rule Semtech’s own sx126x_driver computes in sx126x_cal_img_in_mhz.

§Arguments

  • low_hz - the lower edge of the band in hertz.
  • high_hz - the upper edge of the band in hertz.

§Returns

freq1 and freq2, the parameters of CalibrateImage.

§Examples

use pamoja_radios::sx126x::config::image_calibration;

// Each code counts 4 MHz, so EU868's 863 to 870 MHz calibrates from 860 to 872 MHz,
// and US915's 902 to 928 MHz from 900 to 928 MHz.
let megahertz = |[low, high]: [u8; 2]| (u32::from(low) * 4, u32::from(high) * 4);
assert_eq!(megahertz(image_calibration(863_000_000, 870_000_000)), (860, 872));
assert_eq!(megahertz(image_calibration(902_000_000, 928_000_000)), (900, 928));