Enter a short description of your topic here (optional).
Application level example functions are provided in examples\driver_examples.c. When we develop an application in the main.c file, these functions may be useful to call and adapt (if required), in order to very quickly build and test peripheral functionality. The following is the example generated for the USART Basic driver:
static uint8_t rx[16]; uint8_t USART_0_test_usart_basic(void) { uint8_t i; // If USART Basic driver is in IRQ-mode, enable global interrupts. ENABLE_INTERRUPTS(); // Test driver functions, assumes that the USART RX and // TX pins have been loopbacked, or that USART hardware // is configured in loopback mode // Test printf() support printf("hello"); // Check that "hello" was received on loopback RX. // Initialize rx buffer so strncmp() check will work memset(rx, 0, sizeof(rx)); for (i = 0; i < strlen("hello"); i++) { rx[i] = USART_0_read(); // Blocks until character is available } // Compare received and expected data if (strncmp("hello", (char *)rx, strlen("hello")) != 0) return 0; // Error: Mismatch // If we get here, everything was OK printf("ok"); return 1; }