#define SI4463_SDI (P2IN & BIT3)
#define SI_SDI_LOW P2IN &=~BIT3
#define SI_SDI_HIGH P2IN |= BIT3
u8 SPI_ExchangeByte(u8 TxData)
{
u8 i,ret=0;
for(i=0;i<8;i++)
{
if(TxData&0x80)
SI_SDI_HIGH; //RF_SDI=1;expression must be a modifiable lvalue
else
SI_SDI_LOW; //RF_SDI=0;expression must be a modifiable lvalue
TxData<<=1;
ret<<=1;
//if(SI4463_SDI)
//ret|=1;
SI_SCK_HIGH; //RF_SCK_HIGH(); //上升沿,采样 ??数据手册时钟上升沿时输出,下降沿输出(前面写命令的时候就有下降沿所以有数据)
delay_us(10);
if(SI4463_SDI)
ret|=1;
SI_SCK_LOW; //RF_SCK_LOW(); //下降沿,锁存
delay_us(10);
}
return ret;
} |