6,7 → 6,29 |
|
void uart_init() { |
// Configure the hardware USART device |
#ifdef _BASE_STATION |
// UART1 TX RC6 |
// UART1 RX RC7 |
Open1USART(USART_TX_INT_OFF & // Interrupt on TX off |
USART_RX_INT_OFF & // Interrupt on RX on |
USART_ASYNCH_MODE & // Operate in async mode |
USART_EIGHT_BIT & // Operate in 8-bit mode |
USART_CONT_RX & // Continuously recieve messages |
USART_BRGH_HIGH, 51); // Set UART speed to 38400 baud (32MHz) |
|
// UART2 RX Pin RP5 |
RPINR16 = 5; // 5 is PPS RP5 |
// UART2 TX Pin RP6 |
RPOR6 = 5; // 5 is TX2/CK2 (EUSART2 Asynchronous Transmit/Asynchronous Clock Output) |
|
Open2USART(USART_TX_INT_OFF & // Interrupt on TX off |
USART_RX_INT_ON & // Interrupt on RX on |
USART_ASYNCH_MODE & // Operate in async mode |
USART_EIGHT_BIT & // Operate in 8-bit mode |
USART_CONT_RX & // Continuously recieve messages |
USART_BRGH_HIGH, 51); // Set UART speed to 38400 baud (32MHz) |
#endif |
#ifdef _REMOTE |
// UART1 TX RC6 |
// UART1 RX RC7 |
Open1USART(USART_TX_INT_OFF & // Interrupt on TX off |
26,7 → 48,8 |
USART_ASYNCH_MODE & // Operate in async mode |
USART_EIGHT_BIT & // Operate in 8-bit mode |
USART_CONT_RX & // Continuously recieve messages |
USART_BRGH_HIGH, 64); // Set UART speed to 115200 baud |
USART_BRGH_HIGH, 64); // Set UART speed to 38400 baud |
#endif |
} |
|
void uart_recv_interrupt_handler() { |