/*
 *  eeprom.c
 *
 *  read/write eeprom inside LinPAC
 *
 *  History
 *
 *  v 0.0 2017.3.1 by Moki Matsushima  
 *    create, ... ok, i keep this as simple as possible
 */

#include<stdio.h>
#include<stdlib.h>
#include "msw.h"

/* ------------------------------------------------------------------- */
int main()
{
	int addr=0, wRetVal, data=0;
	wRetVal = Open_Slot(0);
	if (wRetVal > 0) {
		printf("open Slot failed!\n");
		return (-1);
	}
	
	Enable_EEP();
	data = 20;
	printf("Write address 0(0x0000) = %d\n", data);
	Write_EEP(0,addr,(unsigned char)data);
 
	data = 25;
	printf("Write address 254(0x00FE) = %d\n", data);
	Write_EEP(0,addr+254,(unsigned char)data);
 
	data = 130;
	printf("Write address 1277(0x4FD) = %d\n", data);
	Write_EEP(0,addr+1277,(unsigned char)data);
	Disable_EEP();
 
	printf("Read address 0 = %d\n", Read_EEP(0,addr));
	printf("Read address 254 = %d\n", Read_EEP(0,addr+254));
	printf("Read address 1277 = %d\n", Read_EEP(0,addr+1277));

	Disable_EEP();
	
	Close_Slot(0);
	return 0;
}

