void main(void)
{
u8 i;
u8 flag_eeprom;
u32 key_time_cnt;
unsigned long time_out;
INT8U j, length, error;
INT32U dly;
INT16U tx_conter = 0, itmp;
volatile unsigned char aa;
INT8U cmd = PART_INFO;
u8 cts;
//启用外部高速晶振且16分频500KHz
/*
CLK_SWR=0xb4;
CLK_CKDIVR=0x00;
CLK_SWCR|=0x02; //开启切换
while((CLK_SWCR & 0x01)==0x01);
CLK_SWCR&=(~0x02); //关闭切换
*/
// CLK_CKDIVR=0x00;//复位后的值为0x18,为8分频.2m,改成0x00后为16m
Init_UART1();
SI4463_InterFace();//SPI和接口IO初始化
/******4438上电始初化,使能.*************************/
SI_SDN_HIGH( );
delay_ms(10);
SI_SDN_LOW( );
delay_ms(10);
SI_CSN_HIGH( );
/******
通过发送0x44 =Used to read CTS and the command response
查询4438是否空闲
*************************/
do
{
SI_CSN_LOW( );
SPI_ExchangeByte( READ_CMD_BUFF ); //READ_CMD_BUFF = 0x44
cts = SPI_ExchangeByte( 0xFF ); //发送一个0xff提供spi clk以便返回数据
SI_CSN_HIGH( );
}while( cts != 0xFF );//如果空则返回0xFF,就退出查询
/***************发送读取部件信息的命令*********************************/
SI_CSN_LOW( );
SPI_ExchangeByte(PART_INFO); //PART_INFO = 0x01
SI_CSN_HIGH( );
/******
通过发送0x44 =Used to read CTS and the command response
查询4438是否空闲
*************************/
do
{
SI_CSN_LOW( );
SPI_ExchangeByte( READ_CMD_BUFF );
cts = SPI_ExchangeByte( 0xFF );
SI_CSN_HIGH( );
}while( cts != 0xFF );
/*****************************/
SI_CSN_LOW( );
SPI_ExchangeByte( READ_CMD_BUFF );
for(i=0;i<8;i++)
{
buffer1[i] = SPI_ExchangeByte( 0xFF );
}
SI_CSN_HIGH( );
for(i=0;i<8;i++)
{
UART1_sendchar(buffer1[i]);
}