Hi,
I found no documentation for accessing the eeprom on the evmdm365 -
DM365. The device is /dev/mtd5. I would like to post application code
for working with EEPROM:
// ---------------------------------------------
// write params to EEPROM
#define EEPROM_FILE_NAME "/dev/mtd5" // "/opt/http/cam_params.txt"
#define EEPROM_PARAMS_START_ADDR 0x40
Write_Param_EEPROM()
{
FILE* F=fopen(EEPROM_FILE_NAME,"w");
if (!F)
{
printf("Read_Params_EEPROM - Error opening file\n");
return -1;
}
if (fseek(F,EEPROM_PARAMS_START_ADDR,SEEK_SET))
{
printf("Read_Params_EEPROM - Error seeking file\n");
fclose(F);
return -1;
}
// save all params to the file
// store parameter self
fprintf(F,"This string will be stored in eeprom.");
fclose(F);
}
// ---------------------------------------------
Also working with keypad on evmdm365 can be handled with this code:
// --------------------------------
#define KEY_CODE_STOP 12
static int buttons_fd=0;
#define KEYBOARD_FILE_NAME "/dev/input/event0"
static void HandleButtons()
{
int rb;
int i;
#define MAX_EVENTS 1
struct input_event ev[MAX_EVENTS];
if (!buttons_fd)
{
printf("SetupApply HandleButtons - Error zero handle " KEYBOARD_FILE_NAME
"\n");
return;
}
rb = read(buttons_fd, ev, sizeof(ev));
if (rb<1) return;
if (rb < (int) sizeof(struct input_event)) {
printf("HandleButtons: short read\n");
return;
}
for (i = 0;
i < (int) (rb / sizeof(struct input_event));
i++)
{
if (EV_KEY == ev[i].type)
{
printf("HandleButtons i %d time %ld.%06ld ",
i,
ev[i].time.tv_sec,
ev[i].time.tv_usec);
printf("HandleButtons type %d code %d value %d\n",
ev[i].type,
ev[i].code, ev[i].value);
if (ev[i].value==1)
{
switch (ev[i].code)
{
case KEY_CODE_STOP:
printf("Button stop was pressed\n");
break;
}
}
}
}
}
// --------------------------------
static void StartButtonsHandler()
{
buttons_fd = open(KEYBOARD_FILE_NAME, 0); // O_NONBLOCK
if (buttons_fd)
{
printf("SetupApply InitButtons - OK " KEYBOARD_FILE_NAME "\n");
}
else
{
printf("SetupApply InitButtons - Error opening handle " KEYBOARD_FILE_NAME
"\n");
return;
}
while (1)
{
HandleButtons();
usleep(100);
}
}
// --------------------------------
Best regards,
Juraj
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source