Beispiel #1
0
uint8_t FPGA_GetRCESTOP() {
    NiFpga_Bool rcestop;
    NiFpga_MergeStatus(&FPGA_Status,NiFpga_ReadBool(FPGA_Session,NiFpga_mainFPGA_IndicatorBool_RCeSTOP,&rcestop));
    if (NiFpga_IsError(FPGA_Status))
    {
            LOG.ERR("Get RCEStop Failed.");
    }
    if(rcestop == NiFpga_False)
    {
            LOG.DATA("RCEstop  = False");
            return 0;
    }
    else
    {
            LOG.DATA("RCEStop  = True");
            return 1;
    }
}
Beispiel #2
0
uint8_t FPGA_GetESTOPTriggered()
{
	NiFpga_Bool  ReStopTriggered;
	NiFpga_MergeStatus(&FPGA_Status,NiFpga_ReadBool(FPGA_Session,NiFpga_mainFPGA_IndicatorBool_eSTOPTriggered,&ReStopTriggered));
	if (NiFpga_IsError(FPGA_Status))
	{
		LOG.ERR("Get EStop Status Failed.");
	}
	if(ReStopTriggered == NiFpga_False)
	{
		LOG.DATA("EStopTriggered  = False");
		return 0;
	}
	else
	{
		LOG.DATA("EStopTriggered  = True");
		return 1;
	}
	return 0;
}
Beispiel #3
0
uint8_t FPGA_GetRCOn()
{
	NiFpga_Bool  RC;
	NiFpga_MergeStatus(&FPGA_Status,NiFpga_ReadBool(FPGA_Session,NiFpga_mainFPGA_IndicatorBool_RCOn,&RC));
	if (NiFpga_IsError(FPGA_Status))
	{
		LOG.ERR("Get RCon Status Failed.");
	}
	if(RC == NiFpga_False)
	{
		LOG.DATA("RCOn  = False");

		return 0;
	}
	else
	{
		LOG.DATA("RCOn  = True");
		return 1;
	}
	return 0;
}
Beispiel #4
0
/**
 * Opens a session to the myRIO FPGA Personality.
 *
 * This function ensures that the NiFpga library is loaded and that the correct
 * myRIO personality bitfile is programmed to the FPGA, started, and is
 * running. The myRIO personality bitfile (.lvbitx file) for your target
 * must be in the same directory as where the executable is run otherwise the
 * function will fail.
 *
 * @warning  This function is not thread-safe.
 *           It should be called before all other function calls and only once
 *           per application.
 *
 * @return  NiFpga_Status which indicates if the operation was successful.
 */
NiFpga_Status MyRio_Open()
{
    const uint32_t timeoutDelay = 5; /* 5 seconds */
    NiFpga_Status status;
    NiFpga_Bool sysReady;
    time_t currentTime;
    time_t finalTime;

    /*
     * Initialize the NiFpga Library.
     */
    status = NiFpga_Initialize();
    if (MyRio_IsNotSuccess(status))
    {
        MyRio_PrintStatus(status);
        printf("Could not load NiFpga library!\n");
        return status;
    }

    /*
     * Open the appropriate FPGA bitfile.
     */
    status = NiFpga_Open(MyRio_BitfilePath,
                         MyRio_Signature, "RIO0", NiFpga_OpenAttribute_NoRun,
                         &myrio_session);
    if (MyRio_IsNotSuccess(status))
    {
        MyRio_PrintStatus(status);
        printf("Could not Open FPGA!\n");
        if (status == NiFpga_Status_BitfileReadError)
        {
            printf("Ensure the bitfile %s exists\n", MyRio_BitfilePath);
        }
        return status;
    }

    /*
     * Ensure that the FPGA code is reset and in a known state.
     */
    status = NiFpga_Reset(myrio_session);
    if (MyRio_IsNotSuccess(status))
    {
        MyRio_PrintStatus(status);
        printf("Could not Reset FPGA!\n");
        return status;
    }

    /*
     * Start the FPGA code.
     */
    status = NiFpga_Run(myrio_session, 0);
    if (MyRio_IsNotSuccess(status))
    {
        MyRio_PrintStatus(status);
        printf("Could not Run FPGA!\n");
        return status;
    }

    /*
     * Wait for the FPGA to signal ready
     */
    time(&currentTime);
    finalTime = currentTime + timeoutDelay;
    sysReady = NiFpga_False;
    while (currentTime < finalTime && !MyRio_IsNotSuccess(status) && !sysReady)
    {
        time(&currentTime);
        NiFpga_MergeStatus(&status,
                    NiFpga_ReadBool(myrio_session, SYSRDY, &sysReady));
    }
    if (MyRio_IsNotSuccess(status))
    {
        MyRio_PrintStatus(status);
        printf("Could not read the system ready register!\n");
        return status;
    }
    if (!sysReady)
    {
        printf("Problem waiting for system ready!\n");
        printf("Timed out\n");
        return NiFpga_Status_InternalError;
    }

    return NiFpga_Status_Success;
}
Beispiel #5
0
bool nifpga::ReadBool(uint32_t indicator, NiFpga_Bool* value) {
	if (sessionOpen) return HandleStatus(NiFpga_ReadBool(sessionHandle, indicator, value));
	return false;
}