![CYPRES CY14NVSRAMKIT-001 User Manual Download Page 43](http://html.mh-extra.com/html/cypres/cy14nvsramkit-001/cy14nvsramkit-001_user-manual_2705735043.webp)
CY14NVSRAMKIT-001 nvSRAM Development Kit User Guide, Doc. # 002-03522 Rev. *A
43
Kit Example Firmware
*****************************************************************************/
void nvSRAMRead (uint32_t address, uint8_t length, uint8_t *txData)
{
uint16_t tempData;
uint8_t u8Counter;
for (u8Counter = 0u; u8Counter < length; u8Counter = u81)
{
tempData = *((uint16_t*)(nvSRAM_BASE_A ((a u8Counter) * 2)));
// MCU reads 16-bit data
txData[(u8Counter*2)] = (uint8_t)(tempData>>8);
//Stores lower byte of 16-bit read data
txData[(u8Counter*2)+1] = (uint8_t)(tempData);
//Stores upper byte of 16-bit read data
}
}
6.2.2
void nvSRAMWrite (uint32_t address, uint16_t data)
/*******************************************************************************
** \param address - memory address
** \param data - data word to write
**
*****************************************************************************/
void nvSRAMWrite (uint32_t address, uint16_t data)
{
*(uint16_t*)(nvSRAM_BASE_A (address * 2)) = data;
// MCU writes 16-bit data to nvSRAM
}
6.2.3
void nvSRAMWriteFullMem (uint16_t data1, uint16_t data2)
/*******************************************************************************
** \param data1 - data word (data1) to write
** \param data2 - data word (data2) to write
**
*****************************************************************************/
void nvSRAMWriteFullMem (uint16_t data1, uint16_t data2)
{
uint32_t u32Counter;
for (u32Counter = 0u; u32Counter < nvSRAM_MEM_SIZE; u32Counter=u322)
{
*(uint16_t*)(nvSRAM_BASE_A (u32Counter * 2)) = data1;
*(uint16_t*)(nvSRAM_BASE_A ((u32C 1) * 2)) = data2;
}
}
6.2.4
void nvSRAMReadRTC (uint8_t address, uint8_t length, uint8_t *txData)
/******************************************************************************
** \param address - RTC address
** \param length - number of bytes to read
** \param txData - read data buffer
**
*****************************************************************************/
void nvSRAMReadRTC (uint8_t address, uint8_t length, uint8_t *txData)
{
uint16_t tempData;
uint8_t u8Counter;
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from