/* ********************************************************************************************************* * RawRead() * * Description : Reads the specified number of bytes from a mounted RAW window from the specified starting * index; * * Argument(s) : rawId -- RAW window ID being read from * startIndex -- start index within RAW window to read from * length -- number of bytes to read from the RAW window * p_dest -- pointer to Host buffer where read data is copied * * Return(s) : error code * * Caller(s) : WF Driver * * Notes: : None * ********************************************************************************************************* */ void RawRead(UINT8 rawId, UINT16 startIndex, UINT16 length, UINT8 *p_dest) { RawSetIndex(rawId, startIndex); RawGetByte(rawId, p_dest, length); }
/* ********************************************************************************************************* * RawRead() * * Description : Reads the specified number of bytes from a mounted RAW window from the specified starting * index; * * Argument(s) : rawId -- RAW window ID being read from * startIndex -- start index within RAW window to read from * length -- number of bytes to read from the RAW window * p_dest -- pointer to Host buffer where read data is copied * * Return(s) : error code * * Caller(s) : WF Driver * * Notes: : None * ********************************************************************************************************* */ void RawRead(uint8_t rawId, uint16_t startIndex, uint16_t length, uint8_t *p_dest) { RawSetIndex(rawId, startIndex); RawGetByte(rawId, p_dest, length); }
void RawCopyTest() { BOOL res; UINT8 i; UINT8 byte; UINT16 rawIndex; UINT16 bufAvail; UINT16 srcRawId = 5; UINT16 byteCount; /* get total bytes available for MGMT tx memory pool */ bufAvail = Read16BitWFRegister(WF_HOST_WFIFO_BCNT1_REG) & 0x0fff; /* LS 12 bits contain length */ /* verify we can read and write from scratch buffer (already mounted) */ RawSetIndex(RAW_SCRATCH_ID, 0); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); for (i = 0; i < 128; ++i) { RawSetByte(RAW_SCRATCH_ID, &i, 1); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == i + 1); } rawIndex = RawGetIndex(RAW_SCRATCH_ID); /* raw index should be at 128 */ WF_ASSERT(rawIndex == 128); RawSetIndex(RAW_SCRATCH_ID, 0); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); for (i = 0; i < 128; ++i) { RawGetByte(RAW_SCRATCH_ID, &byte, 1); WF_ASSERT(byte == i); } RawSetIndex(RAW_SCRATCH_ID, 0); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); /* now zero out scratch */ byte = 0; for (i = 0; i < 128; ++i) { RawSetByte(RAW_SCRATCH_ID, &byte, 1); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == i + 1); } RawSetIndex(RAW_SCRATCH_ID, 0); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); /* verify scratch is zeroed out */ for (i = 0; i < 128; ++i) { RawGetByte(RAW_SCRATCH_ID, &byte, 1); WF_ASSERT(byte == 0); } RawSetIndex(RAW_SCRATCH_ID, 0); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); /* allocate raw buffer of 128 bytes */ byteCount = RawMove(srcRawId, RAW_MGMT_POOL, TRUE, 128); WF_ASSERT(byteCount >= 128); /* fill up buffer with known values */ for (i = 0; i < 128; ++i) { RawSetByte(srcRawId, &i, 1); } rawIndex = RawGetIndex(srcRawId); /* raw index should be at 128 */ WF_ASSERT(rawIndex == 128); /* put raw index back to 0 and verify */ res = RawSetIndex(srcRawId, 0); WF_ASSERT(res == TRUE); rawIndex = RawGetIndex(srcRawId); WF_ASSERT(rawIndex == 0); /* read back from source buffer to ensure write was successful */ for (i = 0; i < 128; ++i) { RawGetByte(srcRawId, &byte, 1); rawIndex = RawGetIndex(srcRawId); WF_ASSERT(rawIndex == i + 1); if (byte != i) { WF_ASSERT(FALSE); } } /* put raw index back to 0 and verify */ res = RawSetIndex(srcRawId, 0); WF_ASSERT(res == TRUE); rawIndex = RawGetIndex(srcRawId); WF_ASSERT(rawIndex == 0); /* set the Scratch index to 0 and verify */ RawSetIndex(RAW_SCRATCH_ID, 0); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); /* set the raw source index to 0 and verify */ RawSetIndex(srcRawId, 0); rawIndex = RawGetIndex(srcRawId); WF_ASSERT(rawIndex == 0); /* perform raw to raw copy and verify raw indexes*/ RawToRawCopy(RAW_SCRATCH_ID, srcRawId, 128); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 128); rawIndex = RawGetIndex(srcRawId); WF_ASSERT(rawIndex == 128); /* put scratch raw index back to 0 */ res = RawSetIndex(RAW_SCRATCH_ID, 0); WF_ASSERT(res == TRUE); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == 0); /* read data from scratch and see if it matches what was copied */ for (i = 0; i < 128; ++i) { RawGetByte(RAW_SCRATCH_ID, &byte, 1); rawIndex = RawGetIndex(RAW_SCRATCH_ID); WF_ASSERT(rawIndex == (i+1)); if (byte != i) { WF_ASSERT(FALSE); } } }
// similar to RawRead, but takes advantage of the auto-increment feature and does // not set the index before reading void RawReadRelative(uint8_t rawId, uint16_t length, uint8_t *p_dest) { RawGetByte(rawId, p_dest, length); }