[mw_shl_code=c,true][/mw_shl_code]
[mw_shl_code=c,true]void delay_us(u32 nus)
{
u32 temp;
SysTick->LOAD=nus*fac_us; //
SysTick->VAL=0x00; //
SysTick->CTRL=0x01 ; //
do
{
temp=SysTick->CTRL;
}
while(temp&0x01&&!(temp&(1<<16)));//
SysTick->CTRL=0x00; //
SysTick->VAL =0X00; //
}//这是delay
[/mw_shl_code]
[mw_shl_code=c,true][/mw_shl_code]
[mw_shl_code=c,true][/mw_shl_code]
[mw_shl_code=c,true]while(1)
{
if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
static int k = 0;
uint16_t RxBuf1[2]={0x0000,0x0000},TxBuf1[2]={0x0000,0x0000};
for (k=0;k<2;k++)
{RxBuf1[k]=USART_ReceiveData(USART1);//USART1->DR;
// writ_shift_register1(RxBuf1[0]);//aa , ,
// writ_shift_register1(RxBuf1[1]);//ff
AD5320 = (RxBuf1[0]<<8) | RxBuf1[1];
writ_shift_register(AD5320);
writ_shift_register1(AD5320);
TxBuf1[k]=RxBuf1[k];
USART_SendData(USART1,TxBuf1[k]);
}
}
delay_us(9);
}
} [/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
|