Appendix A
60
ECX-BW00 User’s Manual
0x4408, //DI_4
0x4428, //DO_1
0x4420, //DO_2
0x4440, //DO_3
0x4410}; //DO_4
DWORD addr=0;
int main()
{
DWORD RetVal = 0;
DWORD gGpioLvValue = 0;
int
i=0;
//Read the DI pin 1~4 vaulue
into_PT_mode();//into the protect mode
printf("Read DI_1~4 value\n");
for (i=0; i<4; i++)
{
RetVal = read_mem_dword(MEM_BASE_A addr_offset[i]);
gGpioLvValue = RetVal & 0x1;
printf("DI_%d = %d\n",i+1 ,gGpioLvValue > 0);
}
into_RL_mode();
system("pause");
//Read the DO pin 1~4 value
into_PT_mode();
printf("Read DO_1~4 value\n");
for (i=4; i<8; i++)
{
RetVal = read_mem_dword(MEM_BASE_A addr_offset[i]);
gGpioLvValue = RetVal & 0x2;
printf("DO_%d = %d\n",i-3 ,gGpioLvValue > 0);
}
into_RL_mode();
system("pause");
//Write the DO pin 1~4 to High