?? zl5011xmm.c
字號:
extMemBurstLength, 0, 0, 0, 0, 0);
if ((extMemBurstLength < ZL5011X_MM_MIN_BURST_LENGTH) ||
(extMemBurstLength > ZL5011X_MM_MAX_BURST_LENGTH))
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
status = zl5011xWrite(zl5011xParams, ZL5011X_MM_BURSTL, extMemBurstLength);
zl5011xParams->packetMemory.extMemBurstLength = extMemBurstLength;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xMmTestPacketMemory
Description:
This function runs a software test on the packet memory, returning a bad
status on error. Test mem by writing a counting value to successive locations,
first counting up then repeat counting down (invert count).
Inputs:
zl5011xParams Pointer to the structure for this device instance
startAddr start address,
memSize in bytes
Outputs:
none
Returns:
zlStatusE
Remarks:
*******************************************************************************/
extern zlStatusE zl5011xMmTestPacketMemory(zl5011xParamsS *zl5011xParams, Uint32T startAddr, Uint32T memSize)
{
zlStatusE status = ZL5011X_OK;
zlStatusE result = ZL5011X_OK;
Uint32T count = 0, reso = sizeof(Uint32T);
Uint32T writeValue = 0, readValue = 0xFFFFFFFF;
Uint8T inverted;
#ifdef _DEBUG
Uint32T traceFnFilterTemp;
traceFnFilterTemp = zl5011xTraceFnFilter;
/* turn off the read and write traces for the duration of the memory test */
zl5011xTraceFnFilter &= ~(ZL5011X_READ | ZL5011X_WRITE);
#endif
ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmTestPacketMemory: start 0x%08x, memSize 0x%08x", startAddr, memSize, 0, 0, 0, 0);
/* loop twice: first with count then inverted count */
for(inverted = 0; inverted <= 1; inverted++)
{
if ((status!= ZL5011X_OK) || (result!= ZL5011X_OK))
{
break;
}
/* write to all specified locations */
readValue = 0xFFFFFFFF;
for(count = 0; count< memSize; count+= reso)
{
if (inverted == 0)
{
writeValue = count;
}
else
{
writeValue = ~count;
}
status = zl5011xWrite(zl5011xParams, count+ startAddr, writeValue);
}
/* check all mem locations */
for(count = 0; count< memSize; count+= reso)
{
if ((status!= ZL5011X_OK) || (result!= ZL5011X_OK))
{
break;
}
if (inverted == 0)
{
writeValue = count;
}
else
{
writeValue = ~count;
}
status = zl5011xRead(zl5011xParams, count+ startAddr, &readValue);
if (writeValue != readValue)
{
result = ZL5011X_PACKET_MEMORY_FAIL;
}
}
}
if (result == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmTestPacketMemory: PASSED ", 0, 0, 0, 0, 0, 0);
}
else
{
ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmTestPacketMemory: FAILED at address 0x%08x,"
" counting up(0)/down(1)=%d, expected 0x%08x, "
" read 0x%08x",
count+ startAddr, inverted, writeValue, readValue, 0, 0);
}
#ifdef _DEBUG
/* the memory test is finished, so restore the settings for the read and write traces */
zl5011xTraceFnFilter = traceFnFilterTemp;
#endif
return(status);
}
/*******************************************************************************
Function:
zl5011xMmControlExternalMemory
Description:
This function can be used to put the external memory into low power modes.
Inputs:
zl5011xParams Pointer to the structure for this device instance
extMemReadiness disable, sleep, enable
Outputs:
none
Returns:
zlStatusE
Remarks:
*******************************************************************************/
extern zlStatusE zl5011xMmControlExternalMemory(zl5011xParamsS *zl5011xParams,
zl5011xExtMemReadinessE extMemReadiness)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_MM_FN_ID,
"zl5011xMmControlExternalMemory: %d ",
extMemReadiness, 0, 0, 0, 0, 0);
if ((extMemReadiness>= ZL5011X_MM_DISABLED) && (extMemReadiness <= ZL5011X_MM_SLEEP))
{
status = zl5011xWrite(zl5011xParams, ZL5011X_MM_EMEMENB, extMemReadiness);
}
else
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
zl5011xParams->packetMemory.extMemReadiness = extMemReadiness;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xMmSetParityMode
Description:
This function sets parity of ext memory
Inputs:
zl5011xParams Pointer to the structure for this device instance
extMemParity none, odd, OR even
Outputs:
none
Returns:
zlStatusE
Remarks:
*******************************************************************************/
extern zlStatusE zl5011xMmSetParityMode(zl5011xParamsS *zl5011xParams,
zl5011xExtMemParityE extMemParity)
{
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmSetParityMode: %d ",
extMemParity, 0, 0, 0, 0, 0);
switch (extMemParity)
{
case ZL5011X_MM_PARITY_NONE: /* fall through intended */
case ZL5011X_MM_PARITY_ODD: /* fall through intended */
case ZL5011X_MM_PARITY_EVEN:
status = zl5011xWrite(zl5011xParams, ZL5011X_MM_EMEMPARITY1, extMemParity);
break;
default:
status = ZL5011X_PARAMETER_INVALID;
break;
}
if (status == ZL5011X_OK)
{
zl5011xParams->packetMemory.extMemParity = extMemParity;
}
return(status);
}
/*******************************************************************************
Function:
zl5011xMmSetParityErrorThreshold
Description:
This function sets the parity trip point.
Inputs:
zl5011xParams Pointer to the structure for this device instance
extMemParityTripPoint number of parity failures that cause an interrupt.
Outputs:
none
Returns:
zlStatusE
Remarks:
Also resets the parity count to 0, to give a known start condition.
*******************************************************************************/
extern zlStatusE zl5011xMmSetParityErrorThreshold(zl5011xParamsS *zl5011xParams,
Uint32T extMemParityTripPoint)
{
Uint8T pExtMemParityCount;
zl5011xBooleanE pExtMemParityFailed;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmSetParityErrorThreshold: 0x%08x ",
extMemParityTripPoint, 0, 0, 0, 0, 0);
if (extMemParityTripPoint > ZL5011X_EMEMPARITY2_LIMIT)
{
extMemParityTripPoint = ZL5011X_EMEMPARITY2_LIMIT;
}
status = zl5011xWrite(zl5011xParams, ZL5011X_MM_EMEMPARITY2, extMemParityTripPoint);
zl5011xParams->packetMemory.extMemParityTripPoint = extMemParityTripPoint;
if (status == ZL5011X_OK)
{
/* force the parity count to 0 by reading the register */
status = zl5011xMmGetParityStatus(zl5011xParams, &pExtMemParityCount,
&pExtMemParityFailed);
}
return(status);
}
/*******************************************************************************
Function:
zl5011xMmGetParityStatus
Description:
This function gets the count of parity failures from the EMEMPTYCNT register,
which also contains a boolean indicator of parity fail.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
pExtMemParityCount count of parity fails.
pExtMemParityFailed indicates a failure has occurred.
Returns:
zlStatusE
Remarks:
*******************************************************************************/
extern zlStatusE zl5011xMmGetParityStatus(zl5011xParamsS *zl5011xParams, Uint8T *pExtMemParityCount,
zl5011xBooleanE *pExtMemParityFailed)
{
zlStatusE status = ZL5011X_OK;
Uint32T readValue;
status = zl5011xRead(zl5011xParams, ZL5011X_MM_EMEMPTYCNT, &readValue);
if (status == ZL5011X_OK)
{
if ((readValue & ZL5011X_1BIT_MASK)== 0)
{
*pExtMemParityFailed = ZL5011X_FALSE;
}
else
{
*pExtMemParityFailed = ZL5011X_TRUE;
*pExtMemParityCount = (Uint8T)((readValue >> ZL5011X_MM_PARITY_FAIL_COUNT_LSB)& ZL5011X_4BIT_MASK);
}
}
ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmGetParityStatus: Parity count %2d"
"Parity fail %d (1=FAIL, 0= OK)",
*pExtMemParityCount, *pExtMemParityFailed, 0, 0, 0, 0);
return(status);
}
/*******************************************************************************
Function:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -