lpc23xx跟lpc21xx 很多不一样的
#include <LPC23xx.H> /* LPC24xx definitions */
/*----------------------------------------------------------------------------
* init_serial: Initialize Serial Interface
*---------------------------------------------------------------------------*/
void init_serial (void) {
/* Initialize the serial interface */
/* Configure UART0 for 115200 baud. */
PINSEL0 &= ~(3 << 4);
PINSEL0 |= 1 << 4; /* Enable TxD0 pin */
PINSEL0 &= ~(3 << 6);
PINSEL0 |= 1 << 6; /* Enable RxD0 pin */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit*/
U0DLL = 26; /* for 11.0592MHz PCLK Clock */
// U0FDR = 0x67; /* Fractional Divider */
U0LCR = 0x03; /* DLAB = 0 */
}
/*----------------------------------------------------------------------------
* sendchar: Write a character to Serial Port
*---------------------------------------------------------------------------*/
int sendchar (int ch) {
if (ch == '\n') {
while (!(U0LSR & 0x20));
U0THR = '\r';
}
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
/*----------------------------------------------------------------------------
* getkey: Read a character from Serial Port
*---------------------------------------------------------------------------*/
int getkey (void) {
while (!(U0LSR & 0x01));
return (U0RBR);
}
/*----------------------------------------------------------------------------
* RxDataReady: if U1RBR contains valid data reurn 1, otherwise 0
*---------------------------------------------------------------------------*/
int RxDataReady( void )
{
return ( U0LSR & 0x01 ); //Receive data ready
//return ( U0LSR & 0x01 ); //Receive data ready
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
哦. |