#ifndef _MEMORY_H #define _MEMORY_H /************************************************************************** * Written by Marcin O'BenY Benka * Version 1.1 (20091124) * * NOTE: * * Operations on volatile SRAM memory. **************************************************************************/ /*************************************************************************** * INCLUDES ***************************************************************************/ #include "global.h" /*************************************************************************** * DEFINITIONS ***************************************************************************/ /* GLOBAL: data send/receive buffer for communication with PC */ extern BYTE data_buffer[262]; /*************************************************************************** * FUNCTIONS ***************************************************************************/ /* clear whole memory, writting 0x00 to each cell */ /* ----------------------------------------------------------------------- RETURN VAL : TRUE on success, FALSE on fail ARGS : NONE * ----------------------------------------------------------------------- */ BOOL memoryClear(); /* test SRAM memory, writting different patterns */ /* ----------------------------------------------------------------------- RETURN VAL : TRUE on success, FALSE on fail ARGS : NONE * ----------------------------------------------------------------------- */ BOOL memoryTest(); /* write byte to memory */ /* ----------------------------------------------------------------------- RETURN VAL : TRUE on success, FALSE on fail ARGS : addr - address in memory matrix byte - byte to write to memory * ----------------------------------------------------------------------- */ BOOL memoryWrite(const UINT16 addr, const BYTE byte); /* write block of data to memory */ /* ----------------------------------------------------------------------- RETURN VAL : TRUE on success, FALSE on fail ARGS : addr - address of first byte in memory matrix size - bytes number to write to memory buffer - pointer to data buffer with data to write * ----------------------------------------------------------------------- */ BOOL memoryWriteBlock(const UINT16 addr, const UINT16 size, const BYTE* buffer); /* read byte from memory */ /* ----------------------------------------------------------------------- RETURN VAL : pointer to byte read ARGS : addr - address in memory matrix * ----------------------------------------------------------------------- */ BYTE* memoryRead(const UINT16 addr); /* read block of data from memory */ /* ----------------------------------------------------------------------- RETURN VAL : pointer to data read ARGS : addr - address of first byte in memory matrix size - bytes number to read from memory buffer - pointer to buffer where data will be written * ----------------------------------------------------------------------- */ BYTE* memoryReadBlock(const UINT16 addr, const UINT16 size, BYTE* buffer); /* enable ECU to read from memory */ /* ----------------------------------------------------------------------- RETURN VAL : NONE ARGS : NONE * ----------------------------------------------------------------------- */ void setMemoryAccessEcuRead(); /* enable MCU to read from memory */ /* ----------------------------------------------------------------------- RETURN VAL : NONE ARGS : NONE * ----------------------------------------------------------------------- */ void setMemoryAccessMcuRead(); /* enable MCU to write to memory */ /* ----------------------------------------------------------------------- RETURN VAL : NONE ARGS : NONE * ----------------------------------------------------------------------- */ void setMemoryAccessMcuWrite(); /* set memory address */ /* ----------------------------------------------------------------------- RETURN VAL : NONE ARGS : NONE * ----------------------------------------------------------------------- */ void setMemoryAddress(const UINT16 addr); #endif /* _MEMORY_H */ /* END */