Here is the example code Frederic-Bonne Chance.

 

Mousssa

 

 

#ifndef AVERAGE_H

#define AVERAGE_H

 

            //Functions pointers that describe your function signatures

            //change to fit your application

            

typedef void (* driverInitFunc_f)(void*);

typedef void (* driverSampleFunc_f)(void*,uint8_t,uint16_t, uint16_t);

typedef void (* driverProcessFunc_f)(void*, uint8_t,uint16_t*);

 

typedef struct {

  uint32_t avgX;

  uint32_t avgY;

} average_mem_t;

 

    //Structure that will go in Flash at 0x1080

typedef struct {

    uint16_t driverId;

    driverInitFunc_f  init;

    driverSampleFunc_f  sample;

    driverProcessFunc_f  process;

    uint16_t magicNumber;

} average_driverInfo_t;

 

extern void averageInit(average_mem_t* averageMem);

extern void averageSample(average_mem_t* averageMem, uint8_t sample,
uint16_t magX, uint16_t magY);

extern void averageProcess(average_mem_t* averageMem, uint8_t samples,
uint16_t *payload);

 

extern volatile const average_driverInfo_t average_driverInfo;

 

#endif

 

 

 

#include <btypes.h>

#include <msp430F1132.h>

#include <average.h>

 

    // zero out memory

   //Same signature as driverInitFunc_f

void averageInit(average_mem_t* averageMem) {

  return;

}

 

    // accumulate x,y values to memory

   //Same signature as driverSampleFunc_t

void averageSample(average_mem_t* averageMem, uint8_t sample, uint16_t magX,
uint16_t magY) {

 

    //Your Code hEre

  

   return;

}

 

    // calculate average and write result to payload  

   //Same signature as driverProcessFunc_t

void averageProcess(average_mem_t* averageMem, uint8_t samples, uint16_t
*payload) {

    //Your Code hEre

  return;

}

 

 

    //Puts the structure at the beginning of the .INFOA structure

    //#define avgStruct ((average_driverInfo_t *) 0x1080))

    //You can reference it with avgStruct->averageInit(....)

    //                          avgStruct->averageSample(....)

    //                          avgStruct->averageProcess(....)

volatile const average_driverInfo_t average_driverInfo
__attribute__((section(".INFOA"))) = {

  0xFFFF,

  averageInit,

  averageSample,

  averageProcess,

  0xBEEF

};

 

 

   _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Frederic
Beaulieu
Sent: Thursday, March 31, 2005 11:42 AM
To: [email protected]
Subject: RE: [Mspgcc-users] Expert needed - How to put functions at specific
address (not specific section)???

 

Is it possible to give me an example of how I can get the function pointer
at compile time?

Thank you very much!

Fred

 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Moussa Ba
Sent: Wednesday, March 30, 2005 5:49 PM
To: [email protected]
Subject: RE: [Mspgcc-users] Expert needed - How to put functions at specific
address (not specific section)???

 

Instead of putting the functions at specific locations, you can have a
structure of function pointers that you initialize at compile time and for
that structure to be in the information FLASH, then you always know where to
find the structure and the actual function pointers can move within a
segment or groups of segment but their address would always be stored at the
same location.  Let me know ifyou need an example on how to do this.

 

Moussa


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 3/27/2005



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 3/25/2005



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 3/25/2005



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 3/27/2005



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 3/27/2005



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.6 - Release Date: 3/30/2005



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.6 - Release Date: 3/30/2005
 

Reply via email to