We program Freescale PowerPC Microcontrollers in 'C' language.
Following structure declared by lower layer library is as follows: It is instantiated by top
layer application. A pointer to this structure is passed to lower layer library functions.
typedef struct { /* Initialization Function */ void (*fc_init) (alg_work_t *work, alg_cfg_t *config);
/* Main Function */ void (*fc_main) (alg_work_t *work, alg_cfg_t *config);
/* This structure is used to read the raw frequency/direction from the hardware */
frqqd_config_t input_config;
/* some member */ int member1;
} spdwdir_config_t;
typedef struct { int tpu; int primary_channel; int secondary_channel; int edge; int tcr; int tpu_priority; int debounce_time; unsigned int max_period; unsigned int min_period; unsigned int timeout;
} frqqd_config_t;
In new platform, structure frqqd_config_t does not exist. Top layer application still needs to pass
following members from this structure to lower layer library functions:
typed struct { void * primary_channel int debounce_time; unsigned int max_period; unsigned int min_period; unsigned int timeout;
} app_frqqd_config_t;
POSSIBLE SOLUTIONS: Since lower layer library does not declare frqqd_config_t in new platform, top layer application
needs to declare new structure with members needed from frqqd_config_t. Requirement is to use same set of files for both platforms, old and new. One possibility is use compile time platform flags as follows:
typedef struct { /* Initialization Function */ void (*fc_init) (alg_work_t *work, alg_cfg_t *config);
/* Main Function */ void (*fc_main) (alg_work_t *work, alg_cfg_t *config); #if (old_platform)
/* This structure is used to read the raw frequency/direction from the hardware */
frqqd_config_t input_config; #else app_frqq_config_t *input_config; #endif
/* some member */ int member1;
} spdwdir_config_t;
By the way, instead of pointer to app_frqq_config_t, why not just say the following:
app_frqq_config_t input;
What are other solutions? what's the best solution.
--------------------------------------- Posted through