UINT8 UART2_read(void) { UINT8 data; #if(defined __18F8722_H) ||(defined __18F46K22_H) DISABLE_UART2_RX_INTERRUPT(); data = uart[1].rxBuff[uart[1].rxDataIndex++]; if( uart[1].rxDataIndex >= RX_PACKET_SIZE) { uart[1].rxDataIndex = 0; } if( uart[1].rxDataCount > 0 ) --uart[1].rxDataCount; ENABLE_UART1_RX_INTERRUPT(); #else DISABLE_UART_RX_INTERRUPT(); data = uart.rxBuff[uart.rxDataIndex++]; if( uart.rxDataIndex >= RX_PACKET_SIZE) { uart.rxDataIndex = 0; } if( uart.rxDataCount > 0 ) --uart.rxDataCount; ENABLE_UART_RX_INTERRUPT(); #endif return data; }
/* *------------------------------------------------------------------------------ BOOL UART_hasData(void) * * Summary : indicates whether data has been received from the uart * Input : None * * Output : the data from the rxBuff at index = rxDataIndex * *------------------------------------------------------------------------------ */ BOOL UART_hasData(void) { BOOL result = FALSE; DISABLE_UART_RX_INTERRUPT(); if(uart.rxDataCount > 0) result = TRUE; ENABLE_UART_RX_INTERRUPT(); return result; }
/* *------------------------------------------------------------------------------ UINT8 UART_read(void) * * Summary : return the data from the rxBuff * Input : None * * Output : the data from the rxBuff at index = rxDataIndex * *------------------------------------------------------------------------------ */ UINT8 UART_read(void) { UINT8 data; DISABLE_UART_RX_INTERRUPT(); data = uart.rxBuff[uart.rxDataIndex++]; if( uart.rxDataIndex >= RX_PACKET_SIZE) { uart.rxDataIndex = 0; } if( uart.rxDataCount > 0 ) --uart.rxDataCount; ENABLE_UART_RX_INTERRUPT(); return data; }
/* *------------------------------------------------------------------------------ BOOL UART_hasData(void) * * Summary : indicates whether data has been received from the uart * Input : None * * Output : the data from the rxBuff at index = rxDataIndex * *------------------------------------------------------------------------------ */ BOOL UART2_hasData(void) { BOOL result = FALSE; #if(defined __18F8722_H) ||(defined __18F46K22_H) DISABLE_UART2_RX_INTERRUPT(); if(uart[1].rxDataCount > 0) result = TRUE; ENABLE_UART2_RX_INTERRUPT(); #else DISABLE_UART_RX_INTERRUPT(); if(uart.rxDataCount > 0) result = TRUE; ENABLE_UART_RX_INTERRUPT(); #endif return result; }
BOOL UART1_hasData(void) { BOOL result = FALSE; #ifdef __18F8722_H DISABLE_UART1_RX_INTERRUPT(); if(uart[0].rxDataCount > 0) result = TRUE; ENABLE_UART1_RX_INTERRUPT(); #else DISABLE_UART_RX_INTERRUPT(); if(uart.rxDataCount > 0) result = TRUE; ENABLE_UART_RX_INTERRUPT(); #endif return result; }