void initCommunications() { initUart2(42); // Initialize UART2 for 57600 baud. }
/******************************************************************************* * main() * * Description: * Main application code * * See also: * * Arguments: * void * * Returns: * void * * Callers: C start-up code * * Notes : * *******************************************************************************/ int main(void) { CBUFFNUM testBufferNum; CBUFFNUM uartOutBufferNum; volatile unsigned int x = 0; /* Initialise all used hardware and */ /* related interrupts */ initLEDs(); initUart2(); initTimer2(); initInterrupts(); termInit(); /* Create circular buffers */ cbuffInit(); testBufferNum = cbuffCreate(testBuffer, TESTBUFFERSIZE, &testBufferObj); uartOutBufferNum = cbuffCreate(uartOutBuffer, UARTOUTBUFFERSIZE, &uartOutBufferObj); /* Check buffers were created */ if (testBufferNum == 0 || uartOutBufferNum == 0) { error(); } /* Get handles to buffers */ hTestBuffer = cbuffOpen(testBufferNum); hUartOutBuffer = cbuffOpen(uartOutBufferNum); /* Check buffers were opened */ if (hTestBuffer == (HCBUFF) 0 || hUartOutBuffer == (HCBUFF) 0) { error(); } /* Start Timer based data generation */ startTimer2(); /* Output statistics */ while(1) { triggerUART2(hUartOutBuffer); updateStats(hTestBuffer); //termOutput(hUartOutBuffer); if(termIsAutomatic()) { if(cbuffGetSpace(hTestBuffer) <= termGetEmptyTrigger()) { termCheckBuffer(hTestBuffer); termFullScreenUpdate(); } } else if(emptyBuffer == 1) { emptyBuffer = 0; termCheckBuffer(hTestBuffer); termFullScreenUpdate(); } if (x >= 0x0FFF) { termOutput(hUartOutBuffer); x = 0; } else { x++; } } }