/*
 * eeprom.h
 *
 * Created: 23-Sep-19 10:41:56 AM
 *  Author: M19892
 */ 


#ifndef EEPROM_H_
#define EEPROM_H_

#define EEPROM(_pageAddr, _byteAddr) \
((uint8_t *) MAPPED_EEPROM_START)[_pageAddr*EEPROM_PAGE_SIZE + _byteAddr]

#define NVM_EXEC()	asm("push r30"      "\n\t"	\
"push r31"      "\n\t"	\
"push r16"      "\n\t"	\
"push r18"      "\n\t"	\
"ldi r30, 0xCB" "\n\t"	\
"ldi r31, 0x01" "\n\t"	\
"ldi r16, 0xD8" "\n\t"	\
"ldi r18, 0x01" "\n\t"	\
"out 0x34, r16" "\n\t"	\
"st Z, r18"	    "\n\t"	\
"pop r18"       "\n\t"	\
"pop r16"       "\n\t"	\
"pop r31"       "\n\t"	\
"pop r30"       "\n\t"	\
)

void EEPROM_WriteByte( uint8_t pageAddr, uint8_t byteAddr, uint8_t value );
uint8_t EEPROM_ReadByte( uint8_t pageAddr, uint8_t byteAddr );
void EEPROM_WaitForNVM( void );
void EEPROM_FlushBuffer( void );



#endif /* EEPROM_H_ */