/*---------------------------------------------------------------------------*/ void uart0_init() { #if UART0_CONF_HIGH_SPEED UART_SET_SPEED(0, UART_115_M, UART_115_E); #else UART_SET_SPEED(0, UART_9_M, UART_9_E); #endif #ifdef UART0_ALTERNATIVE_2 PERCFG |= PERCFG_U0CFG; / *alternative port 2 = P1.5-2 */
void uart1_init (void) { #if (UART_STDOUT_PORT == 1 || UART_ONE_WIRE_PORT == 1) UART_SET_SPEED(1, UART_115200_M, UART_115200_E); PERCFG |= PERCFG_U1CFG; /* alternative 2 = P1.7-4 */ #if (UART_ONE_WIRE_PORT == 1) P1SEL |= 0x00; /* TX and RX as inputs for one serial bus communication */ P1DIR &= ~0x40; /* TX in, always disabled, as hi-z */ P1DIR &= ~0x80; /* RX in, always listening, as input */ #else P1SEL |= 0xC0; /* peripheral select for TX and RX */ P1DIR |= 0x40; /* TX out */ P1DIR &= ~0x80; /* RX in */ #endif U1UCR = 0x02; /* defaults: 8N1, no flow, high stop bit */ U1CSR = UCSR_MODE | UCSR_RE; /* UART mode, RX enabled */ U1UCR |= 0x80; /* flush it */ URX1IE = 1; /* enable RX interrupt */ //UTX1IF = 1; #endif }
void uart0_init (void) { #if (UART_STDOUT_PORT == 0 || UART_ONE_WIRE_PORT == 0) UART_SET_SPEED(0, UART_115200_M, UART_115200_E); PERCFG &= ~PERCFG_U0CFG; /* alternative 1 = P0.2-5 */ #if (UART_ONE_WIRE_PORT == 0) P0SEL |= 0x00; /* TX and RX as inputs for one serial bus communication */ P0DIR &= ~0x08; /* TX in, always disabled, as hi-z */ P0DIR &= ~0x04; /* RX in, always listening, as input */ #else P0SEL |= 0x0C; /* peripheral select for TX and RX */ P0DIR |= 0x08; /* TX out */ P0DIR &= ~0x04; /* RX in */ #endif U0UCR = 0x02; /* defaults: 8N1, no flow, high stop bit */ U0CSR = UCSR_MODE | UCSR_RE; /* UART mode, RX enabled */ U0UCR |= 0x80; /* flush it */ URX0IE = 1; /* enable RX interrupt */ //UTX0IF = 1; #endif }