新手上路
- 积分
- 45
- 金钱
- 45
- 注册时间
- 2015-8-3
- 在线时间
- 4 小时
|
1金钱
帮看一下这个函数打印出来,数组中是多少位?
(u8 *)&buf[0]与u8 *pBuf有什么关系?
fnRN7302_Read( 0x0007, (u8 *)&buf[0] ,4 ) ;
printf("SIM900 RECV1:[%x]\r\n",buf[0]);
void fnRN7302_Read(u16 wReg,u8 *pBuf,u8 ucLen)// wReg是寄存器地址 *pBuf是存的数组 ucLen是字节长度
{
u8 i,temp,chksum;
PinWrite_ADCS_HIGH;
__nop();
PinWrite_ADCS_LOW;//′ò¿aƬѡ
__nop();
temp=(u8)(wReg&0x00ff);
chksum = temp;//D£Ñéoí μØÖ·
fnSpi2_WriteByte(temp);//D′μØÖ·
temp = ((u8)(wReg >> 4))& 0xf0;//temp = (((u8)(wReg>>4))&0xf0);
printf("temp:%x",temp);
printf("\r\n");
chksum +=temp;
fnSpi2_WriteByte(temp);//D′Ãüáî
delay_us(4);
for(i=ucLen;i>0;i--)
{
pBuf[i-1] = fnSpi2_ReadByte();
//¶á3¤¶è±ØDëóë¼Ä′æÆ÷¶Ôó|×Ö½úò»ÖÂ
chksum+=pBuf[i-1];
}
// printf("\r\n");
chksum = chksum^0x0ff;
if(fnSpi2_ReadByte()!=chksum)//¶áè¡CSD£ÑéÂë2¢D£Ñé
PinWrite_ADCS_HIGH;
__nop();
PinWrite_ADCS_HIGH;//1رÕƬѡ
PinWrite_ADSDO_HIGH();
PinWrite_ADSCLK_HIGH();
}
|
|