下面是APP和部分程序E_DRVGPIO_PIN sPinNumber; //枚举引脚
STR_UART_T config;
uint32_t start[10];
/*---------------------------------------------------------------------------------------------------------*/
/* MAIN function */
/*---------------------------------------------------------------------------------------------------------*/
int main (void)
{
uint8_t tab[12]={6,5,6,7,8,9};
uint8_t tab1[10];
while(DrvSYS_SetOscCtrl(E_SYS_XTL12M, 1)!=0);//使能外部12MHZ晶振
while( DrvSYS_SelectHCLKSource(0) !=0);//HCLK选择外部12MHZ晶振
while(DrvSYS_SelectSysTickSource(0)!=0);//选择系统嘀嗒时钟源为外部12MHZ晶振
DrvSYS_SetIPClock(E_SYS_UART0_CLK,1);//使能UART0时钟
while(DrvSYS_SetClockDivider(E_SYS_HCLK_DIV, 0)!=0); //1分频UART&HCLK
while(DrvSYS_SetClockDivider(E_SYS_UART_DIV, 0)!=0); //1分频UART&HCLK
DrvSYS_SelectIPClockSource(E_SYS_UART_CLKSRC, 0);//UART选择外部12Mhz的时钟源
DrvGPIO_InitFunction(E_FUNC_UART0);//复用IO编程UART模式
/*关闭所有串口中断*/
DrvUART_DisableInt(UART_PORT0,DRVUART_WAKEUPINT|DRVUART_RLSINT|DRVUART_BUFERRINT|DRVUART_MOSINT|DRVUART_THREINT|DRVUART_RDAINT|DRVUART_TOUTINT);
/*设置串口参数*/
config.u32BaudRate=9600; //波特率9600
config.u8cDataBits=DRVUART_DATABITS_8 ;//数据位8位
config.u8cStopBits=DRVUART_STOPBITS_1; //停止位1位
config.u8cParity=DRVUART_PARITY_NONE ; //NONE校验
config.u8cRxTriggerLevel=DRVUART_FIFO_8BYTES;//接受FIFO 8字节
DrvUART_Open(UART_PORT0, &config);//开启UART端口
/*端口模式*/
DrvGPIO_Open(E_PORT3,E_PIN6, E_IO_OUTPUT);
DrvGPIO_Open(E_PORT0,E_PIN0, E_IO_INPUT);//input
sPinNumber=E_PIN6;
|