#include "eeprom.h"
#include <avr/io.h>

void eeprom_writebyte(unsigned int loc, unsigned char data)
{
  while (EECR & (1 << EEWE));

  EEAR = loc;
  EEDR = data;
  EECR |= (1 << EEMWE);
  EECR |= (1 << EEWE);
}

void eeprom_writeint(unsigned int loc, unsigned int data)
{
  eeprom_writebyte(loc, (data >> 8));
  eeprom_writebyte(loc + 1, (data & 0xff));
}
