views:

57

answers:

1

Hello,

I have a question or best approach of connecting interface either during run-time or compile/link time. For my embedded projects the device drivers and I/O have interfaces that need to be bound (i.e. glued) to their corresponding interface dependencies. For example, for the analog device driver it requires an interface to the discrete output driver in order to set the MUX and Enable lines and the interface for this looks like:

unsigned char (*SetDiscOutput)(unsigned short signalID, unsigned char state);

Currently, I am using a configuration table that associates the module's interface requirement to the associated interface dependency then during run-time the environment configuration iterates through this list and assigns the dependencies. The other method, that I have come up with thus far, is to use hardware configuration file that will bind the module interfaces to their associated dependency interfaces which will be assigned during compile/link time.

Which would be a better approach (pro/cons) to each other and more importantly is there a more elegant way of binding these interface dependencies.

Mark

+1  A: 

I like to MUX them with semaphores. But it really depends on if you are going to be using an OS and if there is any point to having it available for change. I have kept it in software so that different versions of embedded hardware could run the same code, just with different settings.

Myforwik