/*---------------------------------------------------------------------------------------------------------*/
/* MAIN function */
/*---------------------------------------------------------------------------------------------------------*/
int main(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Init System, peripheral clock and multi-function I/O */
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
/* Init UART0 for printf */
UART0_Init();
/* Configure PB.2 as Output mode and PE.1 as Input mode */
GPIO_SetMode(PA, BIT0, GPIO_PMD_OUTPUT);
PA0=1;
while(1)
{
// if(sign)
// {
// sign=0;
// PA0= ~PA0;
// if(Re_buf[0]==0x55) //检查帧头
// {
// switch(Re_buf [1])
// {
// case 0x51:
//// a[0] = ((short)(Re_buf[3]<<8| Re_buf[2]))/32768.0*16;
//// a[1] = ((short)(Re_buf[5]<<8| Re_buf[4]))/32768.0*16;
//// a[2] = ((short)(Re_buf[7]<<8| Re_buf[6]))/32768.0*16;
// UART_WRITE(UART0,0x55);
// UART_WRITE(UART0,0x51);
// UART_WRITE(UART0,Re_buf[2]);
// UART_WRITE(UART0,Re_buf[3]);
// UART_WRITE(UART0,Re_buf[4]);
// UART_WRITE(UART0,Re_buf[5]);
// UART_WRITE(UART0,Re_buf[6]);
// UART_WRITE(UART0,Re_buf[7]);
// UART_WRITE(UART0,0);
// UART_WRITE(UART0,0);
// break;
// case 0x52:
//// w[0] = ((short)(Re_buf[3]<<8| Re_buf[2]))/32768.0*2000;
//// w[1] = ((short)(Re_buf[5]<<8| Re_buf[4]))/32768.0*2000;
//// w[2] = ((short)(Re_buf[7]<<8| Re_buf[6]))/32768.0*2000;
// UART_WRITE(UART0,0x55);
// UART_WRITE(UART0,0x52);
// UART_WRITE(UART0,Re_buf[2]);
// UART_WRITE(UART0,Re_buf[3]);
// UART_WRITE(UART0,Re_buf[4]);
// UART_WRITE(UART0,Re_buf[5]);
// UART_WRITE(UART0,Re_buf[6]);
// UART_WRITE(UART0,Re_buf[7]);
// UART_WRITE(UART0,0);
// UART_WRITE(UART0,0);
// break;
// case 0x53:
//// angle[0] = ((short)(Re_buf[3]<<8| Re_buf[2]))/32768.0*180;
//// angle[1] = ((short)(Re_buf[5]<<8| Re_buf[4]))/32768.0*180;
//// angle[2] = ((short)(Re_buf[7]<<8| Re_buf[6]))/32768.0*180;
// UART_WRITE(UART0,0x55);
// UART_WRITE(UART0,0x53);
// UART_WRITE(UART0,Re_buf[2]);
// UART_WRITE(UART0,Re_buf[3]);
// UART_WRITE(UART0,Re_buf[4]);
// UART_WRITE(UART0,Re_buf[5]);
// UART_WRITE(UART0,Re_buf[6]);
// UART_WRITE(UART0,Re_buf[7]);
// UART_WRITE(UART0,0);
// UART_WRITE(UART0,0);
// break;
// }
// }
// }
}
} |