Gents,
For the past weeks I have been properly organizing several of my projects, which by accident of nature were mostly built in a rush and were a mess of copy/paste accross different circuit boards.
Long story short, I am now "post-writing" libraries for some of the sensors, communication protocols, etc. They are all CCS Static Libraries, TivaWare based.
Most of these functionalities require to know the system clock, to configure the likes of SSI, I2C, UART and other clocks.
I can easily pass the system_clock to the library, in one of the typical initialization functions - something like InitCommLib(sysclock, portnumber). The main applications already store the value on the typical g_ui32_systemclock variables, no problem: on TM4C123x boards I'd use SysCtlClockGet(), and on 129x's it is the returned value from SysCtlClockFreqSet().
It is just not elegant that a library can't figure out the system's clock by itself...
They say good code is code that works. If that's true, I should go do something else. But...
Question is: I don't think I can add, inside the static library, compile conditionals like #ifdef TARGET_IS_TM4C123 use one one method, else use the other, correct? Hence, any of you have an elegant suggestion around this?
Cheers,