Dear All, Its been almost a year working on Cortex-M3 (LPC1768, to be specific). Have developed an application code, with almost all peripherals. From the day 1st of development, i have been of the view to develop a generalized device driver file (actually library) which can be used directly by my colleagues and for future projects. with this view, i have tried to write whole code.
In the application developed by me, i have written different C source files for all peripherals, (Eg: uart.c, i2c.c, dac.c, qei.c, ...etc) with their respective header files (Eg: uart.h, i2c.h, dac.h, ...etc) . The declarations of global variables (as externs) and the global functions are done in the respective headers. The code looks nicely structured and organised. :)
The real problem starts when my colleagues use these (as i call them) generalized driver files to create their own projects. They are compelled to use the global variable names that i have used. Hence the driver files are not generalized in real sense. But then i also have limitation as cannot pass or return a buffer used in interrupt of peripheral (specially the communication buffers viz. uart-buffers, spi-buffers,...etc) Also they have to include many header files (and remove some) in all the source files depending upon peripherals used in their application.
The real question is, how can i make these files really generalized and hence have a library which can be included directly to the project irrespective of whether a peripheral is used or not?
Have googled. But could not find any documentation giving the detailed explaination about writing code that are generalized and can be used to create library.
I cant develop the code using any other language then C. Kindly guide.
Dear Andrew, Thank you for the links. Earlier, i was searching with keywords "how to write a generalised library code", "writing device drivers for lpc1768", "writing code for building library" and so on... But your keyword "api design" opened a new direction. Thanks for the valuable guidance. :)
Regards, Dhaval