This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2355: coding question on access to higher level #defines

Part Number: MSP430FR2355

Hello...

I have a h file at a high level application layer and a c file at a low level driver space.....I would like to access some #defines from the h file.  Can someone tell me how to go about this??? (most likely very simple but....)

I have tried including the h file into my low level but it creates a conflict as my low level driver h file is included in the top level application h file.....

Thanks

  • Hi Steve,

    Are you using header guards? Generally this is the best way to avoid dependency problems. 

    I'm not sure I fully understood your problem. Can you help me understand exactly what you are trying to do?

    Files:

    • high_level.h: #defile TOP_LEVEL_DEF and #include low_level.h
    • low_level.h: this file uses TOP_LEVEL_DEF and #include high_level.h
    • low_level.c: this file uses TOP_LEVEL_DEF and #incldue low_level.h

    Is the above an accurate representation of your application include structure? If so, you have a circular dependency. You should move all the #defines that are needed at all levels of your application to a constants.h file. Make sure to use a header guard there.

    Regards,

    Evan

  • Thanks Evan....

    I have guards....I had a #define in main.h......I then wanted to use it in an i2c.c driver file I created....but as you can imagine the i2c.h file was included in main.h....The solution was to create a middleware (lcd.h and lcd.h) and move the function in i2c.c up a level (as it really was lcd dependent and not i2c).  I then moved the #define (which was also lcd related) down into the lcd.h file....Everybody is now happy.

**Attention** This is a public forum