If you are developing a new project for LPCOpen, you will need to setup the project include paths, library paths and files, and other any source files needed for the project. Because LPCOpen code is shared across many platforms, the needed locations aren't centrally located in a single area. To make things more complex, different device families may have different sets of files.
This topic provides an overview of the include paths needed for LPCOpen projects, the locations of generated libraries, and locations of reference source code such as startup code needed for building a project.
Files and locations can be broken up into multiple categories, but most LPCOpen packages have 3 categories in common that are central to all LPCOpen projects - the chip layer, board layer, and example code.
LPCOpen releases for IAR/Keil and LPCXpresso
LPCopen releases for IAR Embedded Workbench and Keil uVision (MDK) have different organization and file locations than LPCXpresso releases. Depending on which toolchain you are using, the locations of these files may differ. The paths listed here are only for the IAR and Keil toolchains.
If things get confusing, you can always examine the paths in an existing IAR, Keil, or LPCXpresso project.
Chip layer include paths
For a minimum project configuration, you will need the the chip driver header files, common chip layer header files, USBDROM header files, and the chip specific configuration file(s).
Chip layer header files
The chip driver header files include the individual driver header files and the chip.h file specific to the LPCOpen device family you are using.
The chip driver header files are in the "lpcopen/software/lpc_core/chip_<CHIP>" directory. Simply add the include path to these files to your project.
Example: For LPC8xx projects, you will need the "lpcopen/software/lpc_core/lpc_chip/chip_8xx" directory.
Common chip layer header files
The common chip layer files are common header files that are shared across multiple chip families. These include generic chip components such as common error code, ring buffer implementations, common type definitions, etc.
The common chip header files are in the "lpcopen/software/lpc_core/lpc_chip/chip_common" directory. Simply add the include path to these files to your project.
USBDROM header files
The USB device ROM library header files are included in a separate directory from chip files. These header files are only needed for projects that use the USB device ROM stack. Device family releases that do not have USB or USBD ROM support will not have these files.
The USBDROM header files are in the "lpcopen/software/lpc_core/lpc_chip/usbd_rom" directory. Simply add the include path to these files to your project.
Chip specific configuration file(s)
When the chip driver functions are being compiled, the specific target family device they will be built for must be defined to select the features for that device family. These include specific device family features, interrupt IRQ number and vector mapping, core revisions, etc. A single device family such as the LPC11xx may have multiple possible build time configurations that select the features for that device.
The device features are selected with the definition such as 'CHIP_LPC11XX'. These definitions are defined in configuration sub-directories inside the chip driver directory. One or more of these directories may exist for a specific device family and the path that matches the device the chip layer code will be built for must be included in the project, Only one configuration directory must be included, with the name of the directory indicating the supported device family.
Example: "lpcopen/software/lpc_core/lpc_chip/chip_11xx/config_11xxlv" must be added to the project when building the code for the LPC11XXLV device family.
Board layer include paths
The board layer provides some abstracted functions for board setup, debug input/output, LED control, system startup code, and peripheral setup functions. The board layer isn't required to build and run LPCOpen code when used with the chip layer and other source code.
Board layer header files
The board layer header files include the common board API header file and the board.h file specific to the supported LPCOpen board you are using.
The board driver header files are in the "lpcopen/software/lpc_core/lpc_board/board_<CHIP>/<BOARD>" directory. Simply add the include path to these files to your project.
Example: For the LPC1769 release, the supported board is the LPCXpresso LPC1769 board located in the "lpcopen/software/lpc_core/boards_8xx/nxp_xpresso_1769" directory.
Common board layer header files
The common board layer files are common header files that are shared across multiple platforms or boards. These include generic board components such as LED control, debug input/output, specific peripheral setup, etc.
The common board header files are in the "lpcopen/software/lpc_core/lpc_board/board_common" directory. Simply add the include path to these files to your project.
Typical include paths as part of a project for the Keil MCB4300 (LPC4357) board with the Keil Uvision toolchain
Chip layer source files
For LPCOpen platform releases, you can add all the code in the chip layer (chip specific, common chip, and chip configuration) into your project. Depending on which device family you use, it is possible you may get files in your project that do not apply to your device (such as getting a CAN driver for a device that doesn't support CAN). Any files that do not apply to your device family will build as empty files and will still compile without errors - this prevents trying to figure out which files go with your device family.
Board layer source files
LPCopen platform specific releases only include board files specific to the platform the release is for, so you can add all the files in the board specific and common areas to your project.
Other project source files
In addition to the chip and optional board layer functions, projects that generate an executable image also need startup code and optional system initialization code. The startup code provides the entry point for the application, IRQ vector table, and initial stack and heap (if used) setup code. The startup code is located in the "lpcopen/applications/<CHIP>/startup" area. Versions of the startup code exists for IAR, Keil, and LPCXpresso - just add the needed startup code version to your project.
You will need to provide the application code that enters via the main() function. The startup code will get handed off to main() once it is complete.
The startup code calls SystemInit() prior to calling main(). This function is provided as part of the chip layer code in sysinit_<CHIP>.c. the function normally called a board layer function to provide board specific setup, but can be changed to do nothing or call a chip specific setup function. To get this handler, you will need to add the sysinit_<CHIP>.c file to your project. This file is located with the startup code.
Chip libraries are built with all chip specific and common chip code. Board libraries are built with the board specific and board common code. Chip and board libraries and are generated in a sub-directory in the chip layer and board layer code directories under the names tool output directory. If you plan on using libraries generated with the LPCOpen chip and board library projects, you will find them in the "lpcopen/software/lpc_core/lpc_board/board_<CHIP>/<BOARD>/keil_output" and "lpcopen/software/lpc_core/lpc_board/board_<CHIP>/<BOARD>/iar_output" directories.