User's Manual
MiraBoxUser Guide –page25 / 27
Copy this program to file “i2c_led.c” and save to “/home” directory or other else, and compile it use
cross-compile tool just have been installed.
#cd /home
#arm-marvell-linux-gnueabi-gcc -o led i2c_led.c
Then copy the executable file “led” to Mirabox and run it. You can see the LED is controlled by youself.
/***********controltheGPIOOP‐4**************************************/
//turnonLED
sleep(1);
(e2prom_data.msgs[0]).buf[0]=0x1c;//e2promwriteaddress
(e2prom_data.msgs[0]).buf[1]=0x0;//thedatatowrite
ret=ioctl(fd,I2C_RDWR,(unsignedlong)&e2prom_data);
if(ret<0)
{
perror("ioctlerror5");
}
//turnoffLED
sleep(1);
(e2prom_data.msgs[0]).buf[0]=0x1c;//e2promwriteaddress
(e2prom_data.msgs[0]).buf[1]=0xFF;//thedatatowrite
ret=ioctl(fd,I2C_RDWR,(unsignedlong)&e2prom_data);
if(ret<0)
{
perror("ioctlerror5");
}
printf("testingok\n");
close(fd);
return0;
}