Skip to content

Commit a45c316

Browse files
committed
lora/sx126x: Clean up some struct formatting.
Changes are cosmetic - and maybe very minor code size - but not functional. _reg_read() was calling struct.packinto() with an incorrect number of arguments but it seems like Micropython didn't mind, as result is correct for both versions. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
1 parent 01f9375 commit a45c316

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

micropython/lora/lora-sx126x/lora/sx126x.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def calibrate(self):
469469
# See DS 13.1.12 Calibrate Function
470470

471471
# calibParam 0xFE means to calibrate all blocks.
472-
self._cmd("<BB", _CMD_CALIBRATE, 0xFE)
472+
self._cmd("BB", _CMD_CALIBRATE, 0xFE)
473473

474474
time.sleep_us(_CALIBRATE_TYPICAL_TIME_US)
475475

@@ -545,7 +545,7 @@ def start_recv(self, timeout_ms=None, continuous=False, rx_length=0xFF):
545545
else:
546546
timeout = 0 # Single receive mode, no timeout
547547

548-
self._cmd(">BBH", _CMD_SET_RX, timeout >> 16, timeout)
548+
self._cmd(">BBH", _CMD_SET_RX, timeout >> 16, timeout) # 24 bits
549549

550550
return self._dio1
551551

@@ -729,10 +729,10 @@ def _cmd(self, fmt, *write_args, n_read=0, write_buf=None, read_buf=None):
729729
return res
730730

731731
def _reg_read(self, addr):
732-
return self._cmd("BBBB", _CMD_READ_REGISTER, addr >> 8, addr & 0xFF, n_read=1)[0]
732+
return self._cmd(">BHB", _CMD_READ_REGISTER, addr, 0, n_read=1)[0]
733733

734734
def _reg_write(self, addr, val):
735-
return self._cmd("BBBB", _CMD_WRITE_REGISTER, addr >> 8, addr & 0xFF, val & 0xFF)
735+
return self._cmd(">BHB", _CMD_WRITE_REGISTER, addr, val & 0xFF)
736736

737737

738738
class _SX1262(_SX126x):

0 commit comments

Comments
 (0)