|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2010-6-12 16:25:09
|
显示全部楼层
用惯了M3,看M0确实有些不习惯。
/***************************初始化串口*********************************/
/* Set UART Pin */
DrvGPIO_InitFunction(FUNC_UART0);
/* UART Setting */
sParam.u32BaudRate = 115200;
sParam.u8cDataBits = DRVUART_DATABITS_8;
sParam.u8cStopBits = DRVUART_STOPBITS_1;
sParam.u8cParity = DRVUART_PARITY_NONE;
sParam.u8cRxTriggerLevel= DRVUART_FIFO_1BYTES;
/* Set UART Configuration */
DrvUART_Open(UART_PORT0,&sParam)
DrvUART_EnableInt(UART_PORT0, DRVUART_RDAINT,UART_INT_HANDLE);
/*****************************回调函数**********************************/
void UART_INT_HANDLE(uint32_t u32IntStatus)
{
uint8_t bInChar[1]={0xFF};
if(u32IntStatus & RDAIE)
{
/* Get all the input characters */
if(UART0->ISR.RDA_IF==1)
{
/* Get the character from UART Buffer */
DrvUART_Read(UART_PORT0,bInChar,1);
DrvUART_Write(UART_PORT0,bInChar,1);
}
}
}
弄个中断服务函数多好,偏偏要用回调函数,迷糊啊
上面代码都是实验过的。 |
|