|
22 | 22 |
|
23 | 23 | #include "sx126x_netdev.h"
|
24 | 24 |
|
| 25 | +#include "macros/units.h" |
25 | 26 | #include "net/lora.h"
|
26 | 27 | #include "periph/spi.h"
|
27 | 28 |
|
@@ -465,11 +466,46 @@ uint32_t sx126x_get_channel(const sx126x_t *dev)
|
465 | 466 | return dev->channel;
|
466 | 467 | }
|
467 | 468 |
|
| 469 | +/* 9.2.1 Image Calibration for Specific Frequency Bands */ |
| 470 | +static void _cal_img(sx126x_t *dev, uint32_t freq) |
| 471 | +{ |
| 472 | + sx126x_chip_modes_t state = sx126x_get_state(dev); |
| 473 | + /* don't know what to do with frequencies that don't fit in the intervals from the datasheet */ |
| 474 | + if (freq >= MHZ(902) && freq <= MHZ(928)) { |
| 475 | + /* 902 - 928 MHz band and anything upper */ |
| 476 | + sx126x_cal_img_in_mhz(dev, 902, 928); |
| 477 | + } |
| 478 | + else if (freq >= MHZ(863) && freq <= MHZ(870)) { |
| 479 | + /* 863 - 870 MHz band */ |
| 480 | + sx126x_cal_img_in_mhz(dev, 863, 870); |
| 481 | + } |
| 482 | + else if (freq >= MHZ(779) && freq <= MHZ(787)) { |
| 483 | + /* 779 - 787 MHz band */ |
| 484 | + sx126x_cal_img_in_mhz(dev, 779, 787); |
| 485 | + } |
| 486 | + else if (freq >= MHZ(470) && freq <= MHZ(510)) { |
| 487 | + /* 470 - 510 MHz band */ |
| 488 | + sx126x_cal_img_in_mhz(dev, 470, 510); |
| 489 | + } |
| 490 | + else if (freq >= MHZ(430) && freq <= MHZ(440)) { |
| 491 | + /* 430 - 440 MHz band and anything lower */ |
| 492 | + sx126x_cal_img_in_mhz(dev, 430, 440); |
| 493 | + } |
| 494 | + else { |
| 495 | + /* Contact your Semtech representative for the other optimal calibration settings |
| 496 | + outside of the given frequency bands. */ |
| 497 | + } |
| 498 | + /* Image calibration sets the chip mode back to STBY_RC */ |
| 499 | + /* When using DIO3, TCXO switches off. */ |
| 500 | + sx126x_set_state(dev, state); |
| 501 | +} |
| 502 | + |
468 | 503 | void sx126x_set_channel(sx126x_t *dev, uint32_t freq)
|
469 | 504 | {
|
470 | 505 | DEBUG("[sx126x]: sx126x_set_channel %" PRIu32 "Hz \n", freq);
|
471 | 506 | dev->channel = freq;
|
472 | 507 | sx126x_set_rf_freq(dev, dev->channel);
|
| 508 | + _cal_img(dev, freq); |
473 | 509 | }
|
474 | 510 |
|
475 | 511 | uint8_t sx126x_get_bandwidth(const sx126x_t *dev)
|
|
0 commit comments