Курсовая работа: Система съема данных с оптопар
U0IIR; // clear interrupt ID
U0RBR; // clear receive register
U0LSR; // clear line status register
// set the baudrate
U0LCR = ULCR_DLAB_ENABLE; // select divisor latches
U0DLL = (uint8_t)baud; // set for baud low byte
U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
// set the number of characters and other
// user specified operating parameters
U0LCR = (mode & ~ULCR_DLAB_ENABLE);
U0FCR = fifomode;
}
int uart0SendByte(int data)
{
while(!(U0LSR & ULSR_THRE)) // wait for TX buffer to empty
continue; // also either WDOG() or swap()
U0THR = (uint8_t)data;
return (uint8_t)data;
}
int uart0GetByte(void)
{
if(U0LSR & ULSR_RDR) // check if character is available
return U0RBR; // return character
return -1;
}
void uart1Init(uint16_t baud, uint8_t mode, uint8_t fifomode)
{
// set port pins for UART1
PINSEL0 = (PINSEL0 & ~U1_PINMASK) | U1_PINSEL;