356 lines
12 KiB
C++
356 lines
12 KiB
C++
/**************************************************************/
|
|
/* shtdnMon0Test.cpp Date: 2018/09/09 */
|
|
/* */
|
|
/* Copyright (c) 2019 GIS. All rights reserved. */
|
|
/* */
|
|
/**************************************************************/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "shtdnMon0Test.h"
|
|
|
|
// --------------------------------------------------
|
|
// Shutdown monitor tests
|
|
// --------------------------------------------------
|
|
int shtdnMon0Test::shtdn_mon_test (CShutdownMonitor0Auto* pShutDn, uint32_t maxOpWidth, uint32_t shiftDepth, int node, int testGroup)
|
|
{
|
|
int error = 0;
|
|
|
|
// Calculate the size of a stripe in DWords
|
|
uint32_t stripeSize1BppWords = (maxOpWidth*shiftDepth/32);
|
|
|
|
VPrint("Starting Shutdown monitor tests\n");
|
|
|
|
// Enable UART control of PIO input, and select which UART is to transmit
|
|
selTx(0, true);
|
|
|
|
// Configure the UUT/test bench for shutdown tests
|
|
configForShutdown();
|
|
|
|
// Set a good state on the bus
|
|
configTbForShutdn();
|
|
|
|
for (int idx = 0; idx <= shutdnLastTest; idx++)
|
|
{
|
|
VPrint(" loop %d\n", idx);
|
|
|
|
// Enable watchdog for first test
|
|
if (idx == shutdnTestTrig)
|
|
{
|
|
pShutDn->pControl->SetWdPeriod(10);
|
|
pShutDn->pControl->SetEnableWd(1);
|
|
}
|
|
else
|
|
{
|
|
pShutDn->pControl->SetEnableWd(0);
|
|
}
|
|
|
|
// Set pwr bit delays
|
|
for (int jdx = 0; jdx < 19; jdx++)
|
|
{
|
|
switch(jdx)
|
|
{
|
|
case0: pShutDn->pShutdnDly0->SetShutdnDly0 (jdx*10); break;
|
|
case1: pShutDn->pShutdnDly1->SetShutdnDly1 (jdx*10); break;
|
|
case2: pShutDn->pShutdnDly2->SetShutdnDly2 (jdx*10); break;
|
|
case3: pShutDn->pShutdnDly3->SetShutdnDly3 (jdx*10); break;
|
|
case4: pShutDn->pShutdnDly4->SetShutdnDly4 (jdx*10); break;
|
|
case5: pShutDn->pShutdnDly5->SetShutdnDly5 (jdx*10); break;
|
|
case6: pShutDn->pShutdnDly6->SetShutdnDly6 (jdx*10); break;
|
|
case7: pShutDn->pShutdnDly7->SetShutdnDly7 (jdx*10); break;
|
|
case8: pShutDn->pShutdnDly8->SetShutdnDly8 (jdx*10); break;
|
|
case9: pShutDn->pShutdnDly9->SetShutdnDly9 (jdx*10); break;
|
|
case10: pShutDn->pShutdnDly10->SetShutdnDly10(jdx*10); break;
|
|
case11: pShutDn->pShutdnDly11->SetShutdnDly11(jdx*10); break;
|
|
case12: pShutDn->pShutdnDly12->SetShutdnDly12(jdx*10); break;
|
|
case13: pShutDn->pShutdnDly13->SetShutdnDly13(jdx*10); break;
|
|
case14: pShutDn->pShutdnDly14->SetShutdnDly14(jdx*10); break;
|
|
case15: pShutDn->pShutdnDly15->SetShutdnDly15(jdx*10); break;
|
|
case16: pShutDn->pShutdnDly16->SetShutdnDly16(jdx*10); break;
|
|
case17: pShutDn->pShutdnDly17->SetShutdnDly17(jdx*10); break;
|
|
case18: pShutDn->pShutdnDly18->SetShutdnDly18(jdx*10); break;
|
|
default: break;
|
|
}
|
|
}
|
|
|
|
// Set new pwr mask
|
|
pShutDn->pNewPwrMask->SetNewPwrMask(0xffffffff);
|
|
|
|
// Set new trip mask (unmask test bit at least)
|
|
pShutDn->pNewTripMask->SetNewTripMask(0x3ff);
|
|
|
|
// Set trip delay
|
|
pShutDn->pTripMaskDelay->SetTripMaskDelay(32);
|
|
|
|
// Set go
|
|
pShutDn->pControl->SetGo(1);
|
|
|
|
if (idx == shutdnTestTrig)
|
|
{
|
|
// Set test shutdown bit
|
|
pShutDn->pTestShutdnSignal->SetTestShutdnSignal(1);
|
|
|
|
// Wait a bit
|
|
usleepSim(1);
|
|
|
|
// Clear test shutdown bit
|
|
pShutDn->pTestShutdnSignal->SetTestShutdnSignal(0);
|
|
}
|
|
else if (idx == shutdnLimMainTrig)
|
|
{
|
|
// Instigate a shut down by setting the LIM_MAIN0 bit
|
|
setLimMain0();
|
|
|
|
// Leave enough time for the bad status to get through the monitor's filter
|
|
nsleepSim(200);
|
|
|
|
// Reset PIO IN to good state
|
|
//pTestBench->pPioCpuValue->SetPioCpuValue(0x0007000f);
|
|
clearFaults();
|
|
|
|
// leave enough time for the cleared bad status to get through the monitor's filter
|
|
nsleepSim(200);
|
|
}
|
|
else if (idx == shutdnSomOvrTrig || idx == shutdnHmbOvrTrig || idx == shutdnHmb1OvrTrig)
|
|
{
|
|
uint32_t sel = idx == shutdnSomOvrTrig ? 0 :
|
|
idx == shutdnHmbOvrTrig ? 1 :
|
|
2;
|
|
|
|
// Enable UART control of PIO input, and select which UART is to transmit
|
|
selTx(sel, true);
|
|
|
|
// Enable bitmap for ordinal 1
|
|
enableSomUartOrdinal(1 << 1);
|
|
|
|
// Send out an alert command over-range at ordinal 1
|
|
sendOverRangeAlert(1);
|
|
|
|
// Send out an alert command return from over-range at ordinal 1
|
|
sendOverRangeReturnAlert(1);
|
|
|
|
// Allow the clearing of state to make its way through the filter
|
|
usleepSim(1);
|
|
}
|
|
else if (idx == shutdnThermTrig)
|
|
{
|
|
// Instigate a shut down by setting the THERM FAULT 0 bit
|
|
setThermFault0();
|
|
|
|
// Leave enough time for the bad status to get through the monitor's filter
|
|
nsleepSim(200);
|
|
|
|
// Reset PIO IN to good state
|
|
clearFaults();
|
|
|
|
// Leave enough time for the cleared bad status to get through the monitor's filter
|
|
nsleepSim(200);
|
|
}
|
|
else if (idx == shutdnPGoodTrig)
|
|
{
|
|
// Instigate a shut down by setting the P_GOOD inout to bad
|
|
setPGoodFault();
|
|
|
|
// Leave enough time for the bad status to get through the monitor's filter
|
|
nsleepSim(200);
|
|
|
|
// Reset PIO IN to good state
|
|
clearFaults();
|
|
|
|
// Leave enough time for the cleared bad status to get through the monitor's filter
|
|
nsleepSim(200);
|
|
|
|
}
|
|
|
|
// Read status
|
|
if (pShutDn->pStatus->GetTripped() != 1)
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor trip status failure.\n", testGroup + 0);
|
|
error |= 1;
|
|
}
|
|
|
|
// Read bad status
|
|
if (pShutDn->pBadStatus->GetBadStatus())
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor bad status not 0 failure.\n", testGroup + 1);
|
|
error |= 1;
|
|
}
|
|
|
|
uint32_t exp;
|
|
uint32_t status;
|
|
|
|
switch(idx)
|
|
{
|
|
case shutdnTestTrig : exp = 0x200; break;
|
|
case shutdnLimMainTrig : exp = 0x1; break;
|
|
case shutdnSomOvrTrig : exp = 0x20; break;
|
|
case shutdnThermTrig : exp = 0x2; break;
|
|
case shutdnPGoodTrig : exp = 0x4; break;
|
|
case shutdnHmbOvrTrig : exp = 0x80; break;
|
|
case shutdnHmb1OvrTrig : exp = 0x80; break;
|
|
default: break;
|
|
}
|
|
|
|
if ((status = pShutDn->pBadStatusSnapshot->GetBadStatusSnapshot()) != exp)
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor bad status snapshot failure (exp 0x%08x got 0x%08x)\n", testGroup + 2, exp, status);
|
|
error |= 1;
|
|
}
|
|
|
|
// Write clear trip
|
|
pShutDn->pControl->SetClearTrip(1);
|
|
|
|
// Read status
|
|
if (pShutDn->pStatus->GetTripped())
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor trip status not cleared failure.\n", testGroup + 3);
|
|
error |= 1;
|
|
}
|
|
|
|
// Read bad status
|
|
if ((status = pShutDn->pBadStatus->GetBadStatus()) != 0)
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor bad status not 0 failure (0x%08x).\n", testGroup + 4, status);
|
|
error |= 1;
|
|
}
|
|
|
|
// Read bad status snapshot
|
|
if (pShutDn->pBadStatusSnapshot->GetBadStatusSnapshot())
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor bad snapshot status not 0 failure.\n", testGroup + 5);
|
|
error |= 1;
|
|
}
|
|
|
|
if (idx == shutdnTestTrig)
|
|
{
|
|
// Allow enough time for the watchdog to trip. In test mode the count units are in us, and the timeout was 10.
|
|
usleepSim(10);
|
|
|
|
// Read status
|
|
if (!pShutDn->pStatus->GetTripped())
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor trip status failure.\n", testGroup + 6);
|
|
error |= 1;
|
|
}
|
|
|
|
// Read bad status
|
|
if ((status = pShutDn->pBadStatusSnapshot->GetBadStatusSnapshot()) != 0x80000000)
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor bad snapshot status failure (got 0x%08x exp 0x80000000.\n", testGroup + 6, status);
|
|
error |= 1;
|
|
}
|
|
|
|
// Read bad status
|
|
if ((status = pShutDn->pBadStatus->GetBadStatus()) != 0)
|
|
{
|
|
VPrint("**ERROR %03d : Shutdown monitor bad status not 0 failure (0x%08x).\n", testGroup + 7, status);
|
|
error |= 1;
|
|
}
|
|
|
|
// Write clear trip
|
|
pShutDn->pControl->SetClearTrip(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error;
|
|
}
|
|
|
|
// --------------------------------------------------
|
|
// UART tests
|
|
// --------------------------------------------------
|
|
|
|
int shtdnMon0Test::uart3_test (int numUarts, int node, int testGroup)
|
|
{
|
|
const uint32_t TEST_WORD2 = 0x19661066;
|
|
const uint32_t TEST_WORD3 = 0x18591905;
|
|
|
|
int error = 0;
|
|
uint32_t status;
|
|
|
|
VPrint("Starting UART tests\n");
|
|
|
|
// Run over all UARTs
|
|
for(int sel_uart = 0; sel_uart < numUarts; sel_uart++)
|
|
{
|
|
VPrint(" loop %d\n", sel_uart);
|
|
|
|
// Select the uart to test
|
|
CUart1mbd3Auto* pUart = getUartHal((uart1Mb_e)sel_uart);
|
|
|
|
// Write different patterns to each of the two registers in uart
|
|
pUart->pOvrgEn->SetOvrgEn(TEST_WORD2);
|
|
pUart->pUnrgEn->SetUnrgEn(TEST_WORD3);
|
|
|
|
// Read back values and check
|
|
if ((status = pUart->pOvrgEn->GetOvrgEn()) != TEST_WORD2)
|
|
{
|
|
VPrint("**ERROR %03d : UART address decode UART offset 0 read back failure (got 0x%08x exp 0x%08x)\n", testGroup + 0, status, TEST_WORD2);
|
|
error |= 1;
|
|
}
|
|
|
|
if ((status = pUart->pUnrgEn->GetUnrgEn()) != TEST_WORD3)
|
|
{
|
|
VPrint("**ERROR %03d : UART address decode UART offset 0 read back failure (got 0x%08x exp 0x%08x)\n", testGroup + 1, status, TEST_WORD3);
|
|
error |= 1;
|
|
}
|
|
|
|
// Enable UART control of PIO input, and select which UART is to transmit
|
|
selTx(sel_uart, true);
|
|
|
|
// Send out an alert command over-range at ordinal 1
|
|
sendOverRangeAlert(1);
|
|
|
|
// Allow the event to make its way through the filter
|
|
usleepSim(1);
|
|
|
|
// Check we got an IRQ
|
|
if (uartRxIrq() == 0)
|
|
{
|
|
VPrint("**ERROR %03d : UART IRQ set status failure.\n", testGroup + 2);
|
|
error |= 1;
|
|
}
|
|
|
|
// Clear IRQ
|
|
pUart->pClrAlertInt->SetClrAlertInt(1);
|
|
|
|
// Check we cleared IRQ
|
|
if (uartRxIrq() != 0)
|
|
{
|
|
VPrint("**ERROR %03d : UART IRQ clear status failure.\n", testGroup + 3);
|
|
error |= 1;
|
|
}
|
|
|
|
// Read the RX status register once (pop on read)
|
|
uint32_t rxVal = pUart->pRx->GetRx();
|
|
|
|
// Check the RX status of the UART
|
|
if ((rxVal & 0xff) != 0x61 ||
|
|
(rxVal & CSR_UART_1MBD_3_RX_PARITY_ERROR_MASK) ||
|
|
!(rxVal & CSR_UART_1MBD_3_RX_READ_DATA_VALID_MASK) ||
|
|
((rxVal & CSR_UART_1MBD_3_RX_READ_DATA_AVAIL_MASK) >> CSR_UART_1MBD_3_RX_READ_DATA_AVAIL) != 1)
|
|
{
|
|
VPrint("**ERROR %03d : UART RX register status failure (RX = 0x%08x).\n", testGroup + 4, rxVal);
|
|
error |= 1;
|
|
}
|
|
|
|
rxVal = pUart->pRx->GetRx();
|
|
|
|
// Check the RX status of the UART after the read (RX data not
|
|
// valid and no bytes available. Data is a don't care)
|
|
if ((rxVal & CSR_UART_1MBD_3_RX_PARITY_ERROR_MASK) ||
|
|
(rxVal & CSR_UART_1MBD_3_RX_READ_DATA_VALID_MASK) ||
|
|
((rxVal & CSR_UART_1MBD_3_RX_READ_DATA_AVAIL_MASK) >> CSR_UART_1MBD_3_RX_READ_DATA_AVAIL) != 0)
|
|
{
|
|
VPrint("**ERROR %03d : UART RX register status failure.\n", testGroup + 5);
|
|
error |= 1;
|
|
}
|
|
|
|
// Disable UART control of PIO input once more
|
|
releaseTbForShutdn();
|
|
}
|
|
|
|
return error;
|
|
}
|
|
|