//API read a byte from register unsigned char APIReadByte(void) { unsigned char data; data=Spi_Read_Byte(); return data; }
//API Read array bytes from register void APIReadArrayBytes(unsigned int length) { unsigned int i; for(i=0;i<length;i++) { *ptrRxBufWrite++=Spi_Read_Byte(); if(ptrRxBufWrite == ptrRxBufOver) { ptrRxBufWrite = &RxBuf[0]; } } }
unsigned char Spi_Read_Packet( u8 *receivebuf)//程序有问题,需要重新书写 { // unsigned char size = 0,addr = 0; unsigned char status[2]; u8 length; // memset(thiscomm->receivebuf,0,MAX_RECEIVE_LEN); Spi_Read_Byte(CC_SIDLE); if ((Spi_Read_Byte(CC_RXBYTES) & 0x7F)) { length= Spi_Read_Byte(CC_RXFIFO)-1; //数据长度 receivebuf[0]=Spi_Read_Byte(CC_RXFIFO); if(receivebuf[0]<10&&receivebuf[0]>0) { Spi_Read_Burst(CC_RXFIFO,&(receivebuf[0]),length); //接收数据 Spi_Read_Burst(CC_RXFIFO,status,2);//校验数据 } } Spi_Write_Strobe(CC_SIDLE); //进入空闲 L Spi_Write_Strobe(CC_SFRX); //清缓冲区 Spi_Write_Strobe(CC_SRX); //进入接收 L return (status[1]&CRC_OK); //校验标志 }