Hi, I have questions about "read and write" a short address via Serial Protocol Interface.
I do not really understand this code:
<<code>>
uint8_t MRF24J40::ReadShort (uint8_t address)
{
uint8_t value;
mCs = 0;
wait_us(1);
mSpi.write((address<<1) & 0x7E);
wait_us(1);
value = mSpi.write(0xFF);
wait_us(1);
mCs = 1;
wait_us(1);
return value;
}
<<code: Copyright (c) 2011 Jeroen Hilgers >>
a unsigned char of 8 bit is selected
Write function SPI:
- value Data to be sent to the SPI slave
- returns Response from the SPI slave
the slave select (cs has to be set on 0), then we wait 1 micro second. First bit of a short address is 0 and last address is 0 for the command read (0x7E: 01111110)
Here is the deal, I do not understand theses sentences:
- mSpi.write((address<<1) & 0x7E)
- value = mSpi.write(0xFF);
The operator <<1 means a shift of 1 on the left and & return 1 if bit have the same value.
I do not really know what it means. I'm not sure to be clear. I'm a bit confuse.
Thanks a lot
Hi, I have questions about "read and write" a short address via Serial Protocol Interface. I do not really understand this code:
<<code>>
uint8_t MRF24J40::ReadShort (uint8_t address)
{
uint8_t value;
mCs = 0;
wait_us(1);
mSpi.write((address<<1) & 0x7E);
wait_us(1);
value = mSpi.write(0xFF);
wait_us(1);
mCs = 1;
wait_us(1);
return value;
}
<<code: Copyright (c) 2011 Jeroen Hilgers >>
a unsigned char of 8 bit is selected
Write function SPI:
- value Data to be sent to the SPI slave
- returns Response from the SPI slave
the slave select (cs has to be set on 0), then we wait 1 micro second. First bit of a short address is 0 and last address is 0 for the command read (0x7E: 01111110)
Here is the deal, I do not understand theses sentences:
- mSpi.write((address<<1) & 0x7E)
- value = mSpi.write(0xFF);
The operator <<1 means a shift of 1 on the left and & return 1 if bit have the same value.
I do not really know what it means. I'm not sure to be clear. I'm a bit confuse.
Thanks a lot