Jump to content
OMRON Forums

Using ACC-72EX in C


Recommended Posts

I wrote a small library of functions for accessing ACC-72EX's memory in C. It's below.

 

In each function "CardIndex" is the index i that addresses the card. ArrayIndex is the element of the array you want to access.

 

 

 



short Acc72EX_Idata16(unsigned int CardIndex, unsigned int ArrayIndex)
{
unsigned int *myptr = (unsigned int *)piom + (DPRCSBase + CardIndex * 0x100000) / 4;
return (short)((myptr[ArrayIndex] << 8) >> 16);
}

unsigned short Acc72EX_Udata16(unsigned int CardIndex, unsigned int ArrayIndex)
{
unsigned int *myptr = (unsigned int *)piom + (DPRCSBase + CardIndex * 0x100000) / 4;
return (unsigned short)((myptr[ArrayIndex] << 8) >> 16);
}

char Acc72EX_Data8(unsigned int CardIndex, unsigned int ArrayIndex)
{
unsigned int *myptr = (unsigned int *)piom + (DPRCSBase + CardIndex * 0x100000) / 4;
return (myptr[ArrayIndex / 2] << (16 / (1 + (ArrayIndex % 4) % 2))) >> 24;
}

unsigned int Acc72EX_Udata32(unsigned int CardIndex, unsigned int ArrayIndex)
{
unsigned int i = ArrayIndex * 4, j, k = 0;
unsigned int out = 0;

for(j = i; j <= i + 3; j++)
{
	out |= (unsigned int)((unsigned int)Acc72EX_Data8(CardIndex, j) << (8 * k));
	k++;
}

return out;
}


int Acc72EX_Idata32(unsigned int CardIndex, unsigned int ArrayIndex)
{
return (int)Acc72EX_Udata32(CardIndex, ArrayIndex);
}

 

For example, to acquire Acc72EX[0].Udata32[1], use:

 

Acc72EX_Udata32(0,1)

Link to comment
Share on other sites

  • 1 year later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
Guest
This topic is now closed to further replies.

×
×
  • Create New...