Confused with #INCLUDE in LPCOpen.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Confused with #INCLUDE in LPCOpen.

518 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kiantek on Tue Jan 27 02:44:06 MST 2015
Hi, I am confused with the use of #INCLUDE in LPCOpen. I have tried numerous attempt in modifying the code and Google for the answer, but I couldn't find a concrete explanation.

I'm developing using LPCOPEN_17XX_BOARD_EA1788. I have created a new LPCOpen project with src folder and inc folder. Error start when I tried to split the main source file into multiple functional source files.

For instance, I have created d_screen.h and d_screen.c in 'inc' folder and 'src' folder respectively.

<d_screen.h>
#ifndef D_SCREEN_H_
#define D_SCREEN_H_
LPC_USART_T *pUART;
void myTest(void);
#endif /* D_SCREEN_H_ */

<d_screen.c>
#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif
LPC_USART_T *pUART;
void myTest(void) { LPC_USART_T myUART; }

Above code can be compiled without any error. But I am puzzled with the following:

Q1:
Why <d_screen.h> does not required definition of LPC_USART type? Shall I insert #include "uart_17xx_40xx.h" at header?

Q2:
For <d_screen.c>, I failed to compiled if I change the lengthy header into #include "uart_17xx_40xx.h". Console show multiples errors as follow:
>> error: unknown type name '__IO'
>> error: expected ':', ',', ';', '}' or '__attribute__' before 'DLL'
>> error: unknown type name '__IO'
Since I'm using LPC_USART type, why can't I simply include the related header files?

Q3:
For <d_screen.c>, is there a need to insert header #include "d_screen.h"?

Q4:
Can I repeatedly use the following code for all functional source files i.e. driver files?
#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

Please advise me! My project files are getting very messy when I split the single main.c into different source file.

I hope experienced programmer could share your coding convention for similar situation.

Thank you.

Sincerely,

KT
Labels (1)
0 Kudos
Reply
1 Reply

442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kiantek on Tue Jan 27 19:10:27 MST 2015
there are missing d_screen.h and d_screen.c in the earlier post. I used angle bracket for the filename and that was hidden.

[u]"d_screen.h"[/u]
#ifndef D_SCREEN_H_
#define D_SCREEN_H_
LPC_USART_T *pUART;
void myTest(void);
#endif /* D_SCREEN_H_ */

[u]"d_screen.c"[/u]
#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif
LPC_USART_T *pUART;
void myTest(void) { LPC_USART_T myUART; }

Q1:
Why [u]"d_screen.h[/u]" does not required definition of LPC_USART type? Shall I insert #include "uart_17xx_40xx.h" at header?

Q3:
For [u]"d_screen.c"[/u], is there a need to insert header #include "d_screen.h"?

Sorry for the confusion.
0 Kudos
Reply