What is a CheckState function?
The purpose of a CheckState function is to ensure that its peripheral is in a known state. This doesn't have to be the Power On Reset (POR) state but one in which one might reasonably expect it to be in, prior to running a test action. Typically, the function should check that no interrupts are pending and, say, all FIFOs are empty. It is expected that test actions will 'tidy up' after themselves and so the CheckState function will ensure that this has been done. The structure of the file <peripheral>_CheckState.c containing the CheckState function should be exactly the same as any other test action (see FAQ PXP - PXP310 - Verification - Adding a test action). The example below shows part of a UART CheckState function: avSYS_eTestResponse avUART_PL011_CheckState(avSYS_SystemElement *uart) {
avSYS_eTestResponse testResult = avTestPassed ; UWORD32 regVal ; volatile struct s_uart_pl011 *pUartReg ; pUartReg = (volatile struct s_uart_pl011 *) uart->BaseAddress ;
avSYS_Print(1, "UART state check test (instance ") ; avSYS_Printf(1, avPrintDec, &uart->Instance) ; avSYS_Print(1, ")") ;
// Check that: Flag register: TXFE bit = 1 // RXFE bit = 1 // BUSY bit = 0 // (All Other bits) = Don't care // RIS register = 0 // Control register: Enable bit = 0 // (All Other bits) = Don't care // Test Control register = 0 regVal = pUartReg->UartFR & (uart_pl011UartFRTXFE | uart_pl011UartFRRXFE | uart_pl011UartFRBUSY) ; if(regVal != (uart_pl011UartFRTXFE | uart_pl011UartFRRXFE)) { avSYS_Print(0, "\n ERROR: Flag register = ") ; avSYS_Printf(0, avPrintHex, ®Val) ; testResult = avTestFailed ; } : // Other checks in here
avSYS_Print(0, "\n") ; return testResult ; } The example shows a check to ensure that both of the FIFO EMPTY flags are set in the UART's Flag Register.
 |