Function Pointer

Thread Starter

aamirali

Joined Feb 2, 2012
412
Function Pointer

Rich (BB code):
#define IAP_LOCATION 0x1FFF1FF1
typedef void (*IAP) (	unsigned int command[],
						unsigned int result[] );
static const IAP iap_entry = (IAP) IAP_LOCATION;

void writeEEPROM( uint16_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount )
{	
	unsigned int command[5], result[4];	

	command[0] = 61;                  
	command[1] = (uint32_t) eeAddress;
	command[2] = (uint32_t) buffAddress;
	command[3] = byteCount;            
	command[4] = 375;
	
	/* Invoke IAP call...*/
	iap_entry(command, result);
	if (0 != result[0])
	{
		//Trap error
		while(1);
	}
	return;
}
 

Thread Starter

aamirali

Joined Feb 2, 2012
412
I couldn't complete my query,sry 4 dat.


What does below line do in above code:

static const IAP iap_entry = (IAP) IAP_LOCATION;
 

takao21203

Joined Apr 28, 2012
3,702
I couldn't complete my query,sry 4 dat.


What does below line do in above code:

static const IAP iap_entry = (IAP) IAP_LOCATION;
Ohhhhhhh. mobile device??

(IAP) is a typecast. IAP location is a numerical value.

"static const" is very compiler specific.
But normally const means the particle will be placed in ROM.
 

spinnaker

Joined Oct 29, 2009
7,830
I couldn't complete my query,sry 4 dat.


What does below line do in above code:

static const IAP iap_entry = (IAP) IAP_LOCATION;

No one is going to be able to help you if you can't give full details of your issue. If you are having trouble with English then perhaps you should try and find a friend or co worker help you to write your question.
 

takao21203

Joined Apr 28, 2012
3,702
What does below line do in above code:

static const IAP iap_entry = (IAP) IAP_LOCATION;
static const - let's think of that as ROM for the time being.

so it is

rom IAP iap_entry = .....

this is misleading, as IAP and iap_entry can be confused for each other by people who don't know much C.

It means, an IAP structure named iap_entry is declared, and placed in ROM.

it is also assigned a value: IAP_LOCATION (which is simply numeric).
This value is casted into IAP using a typecast: (IAP).

I hope this helps.
 
Top