关于RFM69H的RSSI读取功能
时间:10-02
整理:3721RD
点击:
RFM69H读取RSSI的时候始终为固定值且是错误值,应该是在什么时候读取?
供应商示例代码如下,为什么是0x24?
u8 RFM69H_ReadRSSI(void)
{
u16 temp=0xff;
if((SPIRead(0x24)&0x02)==0x02)
{
temp=SPIRead(0x24);
temp=0xff-temp;
temp>>=1;
temp&=0xff;
}
return (u8)temp;
}
u8 SPIRead(u8 adr)
{
u8 tmp;
SPICmd8bit(adr); //Send address first
tmp = SPIRead8bit();
nCS=1;
return(tmp);
}
u8 SPIRead8bit(void)
{
u8 RdPara = 0;
u8 bitcnt;
nCS=0;
MOSI=1; //Read one byte data from FIFO, MOSI hold to High
for(bitcnt=8; bitcnt!=0; bitcnt--)
{
SCK=0;
RdPara <<= 1;
SCK=1;
if(MISO)
RdPara |= 0x01;
else
RdPara |= 0x00;
}
SCK=0;
return(RdPara);
}
供应商示例代码如下,为什么是0x24?
u8 RFM69H_ReadRSSI(void)
{
u16 temp=0xff;
if((SPIRead(0x24)&0x02)==0x02)
{
temp=SPIRead(0x24);
temp=0xff-temp;
temp>>=1;
temp&=0xff;
}
return (u8)temp;
}
u8 SPIRead(u8 adr)
{
u8 tmp;
SPICmd8bit(adr); //Send address first
tmp = SPIRead8bit();
nCS=1;
return(tmp);
}
u8 SPIRead8bit(void)
{
u8 RdPara = 0;
u8 bitcnt;
nCS=0;
MOSI=1; //Read one byte data from FIFO, MOSI hold to High
for(bitcnt=8; bitcnt!=0; bitcnt--)
{
SCK=0;
RdPara <<= 1;
SCK=1;
if(MISO)
RdPara |= 0x01;
else
RdPara |= 0x00;
}
SCK=0;
return(RdPara);
}
已退回1积分