mayeranalytics / pySX127x

This is a python interface to the Semtech SX127x, HopeRF RFM9x, Microchip RN2483 long range, low power transceiver families.
GNU Affero General Public License v3.0
171 stars 116 forks source link

Question on the code, use of the registers #29

Closed BMarvi closed 1 year ago

BMarvi commented 5 years ago

@mayeranalytics

return self.spi.xfer([register_address & 0x7F, 0])[1]
return self.spi.xfer([register_address | 0x80, val])[1]

can't understand the "& 0x7F" and "| 0x80" part.... why is necessary to modify the register address?

mayeranalytics commented 5 years ago

Have a look at section 4.3 of the datasheet:

The first byte is the address byte. It is comprises:

I.e. the intention to read or write is encoded in the highest bit of the address byte. The .. & 0x7F and .. | 0x80 set the highest bit to 0 or 1.