コード例 #1
0
ファイル: xsysace.c プロジェクト: prime5711/blackbox
/**
*
* Get all outstanding errors. Errors include the inability to read or write
* CompactFlash and the inability to successfully configure FPGA devices along
* the target FPGA chain.
*
* @param InstancePtr is a pointer to the XSysAce instance to be worked on.
*
* @return
*
* A 32-bit mask of error values. See xsysace_l.h for a description of possible
* values. The error identifiers are prefixed with XSA_ER_*.
*
* @note
*
* None.
*
******************************************************************************/
u32 XSysAce_GetErrors(XSysAce * InstancePtr)
{
	XASSERT_NONVOID(InstancePtr != NULL);
	XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);

	return XSysAce_mGetErrorReg(InstancePtr->BaseAddress);
}
コード例 #2
0
ファイル: xsysace_l.c プロジェクト: jarpil/Space-Invaders
/**
*
* Read the specified number of bytes from the data buffer of the ACE
* controller. The data buffer, which is 32 bytes, can only be read two bytes
* at a time.  Once the data buffer is read, we wait for it to be filled again
* before reading the next buffer's worth of data.
*
* @param BaseAddress is the base address of the device
* @param BufferPtr is a pointer to a buffer in which to store data.
* @param Size is the number of bytes to read
*
* @return
*
* The total number of bytes read, or 0 if an error occurred.
*
* @note
*
* If Size is not aligned with the size of the data buffer (32 bytes), this
* function will read the entire data buffer, dropping the extra bytes on the
* floor since the user did not request them. This is necessary to get the
* data buffer to be ready again.
*
******************************************************************************/
int XSysAce_ReadDataBuffer(Xuint32 BaseAddress, Xuint8 *BufferPtr, int Size)
{
    int DataBytes;         /* number of data bytes written */
    int BufferBytes;
    Xuint16 Data;

    /*
     * Read data two bytes at a time. We need to wait for the data
     * buffer to be ready before reading the buffer.
     */
    BufferBytes = 0;
    for (DataBytes = 0; DataBytes < Size;)
    {
        /*
         * If at any point during this read an error occurs, exit early
         */
        if (XSysAce_mGetErrorReg(BaseAddress) != 0)
        {
            return 0;
        }

        if (BufferBytes == 0)
        {
            /*
             * Wait for CF data buffer to ready, then reset buffer byte count
             */
            while ((XSysAce_mGetStatusReg(BaseAddress)
                    & XSA_SR_DATABUFRDY_MASK) == 0);

            BufferBytes = XSA_DATA_BUFFER_SIZE;
        }

        /*
         * Need to read two bytes. Put the first one in the output buffer
         * because if we're here we know one more is needed. Put the second one
         * in the output buffer if there is still room, or just drop it on the
         * floor if the requested number of bytes have already been read.
         */
        Data = XSysAce_RegRead16(BaseAddress + XSA_DBR_OFFSET);
        *BufferPtr++ = (Xuint8)Data;
        DataBytes++;

        if (DataBytes < Size)
        {
            /* Still more room in the output buffer */
            *BufferPtr++ = (Xuint8)(Data >> 8);
            DataBytes++;
        }

        BufferBytes -= 2;
    }
コード例 #3
0
ファイル: xsysace_selftest.c プロジェクト: aalonso/mb-ml507
/**
*
* A self-test that simply proves communication to the ACE controller from the
* device driver by obtaining an MPU lock, verifying it, then releasing it.
*
* @param InstancePtr is a pointer to the XSysAce instance to be worked on.
*
* @return
*
* XST_SUCCESS if self-test passes, or XST_FAILURE if an error occurs.
*
* @note
*
* None.
*
******************************************************************************/
int XSysAce_SelfTest(XSysAce * InstancePtr)
{
	int Result;

	XASSERT_NONVOID(InstancePtr != NULL);
	XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);

	/*
	 * Grab a lock (expect immediate success)
	 */
	Result = XSysAce_Lock(InstancePtr, TRUE);
	if (Result != XST_SUCCESS) {
		return Result;
	}

	/*
	 * Verify the lock was retrieved
	 */
	if (!XSysAce_mIsMpuLocked(InstancePtr->BaseAddress)) {
		return XST_FAILURE;
	}

	/*
	 * Release the lock
	 */
	XSysAce_Unlock(InstancePtr);

	/*
	 * Verify the lock was released
	 */
	if (XSysAce_mIsMpuLocked(InstancePtr->BaseAddress)) {
		return XST_FAILURE;
	}

	/*
	 * If there are currently any errors on the device, fail self-test
	 */
	if (XSysAce_mGetErrorReg(InstancePtr->BaseAddress) != 0) {
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}