| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Setting up an Xpresso library project for Chip and Board drivers

Setting up an Xpresso project
A board library project contains the Chip and Board layer code that will be built into a library and used in other projects.

The example here shows how to build the board library for the Embedded Artists LCP1788 board. This library includes the IP, Chip, and Board layers.

Create a new library project
Create a new project using the New->Project selection on the file menu.

Select C/C++->C project in the new project dialog window and press Next>.

On the next dialog window, name your library project and select the static library project type. Press Next>.

On the next dialog window, select the default 'Debug' and 'Release' project configurations. This will create an unoptimized debug configuration and an optimized release configuration of the project. Press Next>.

On the next dialog window, select the device your project will use. For this example, we use the LPC1788.. Press Finish.

After pressing Finish, the project is added to the project explorer window. Before adding source files to the project, a few more items specific to the LPCOpen platform need to be configured in the project.

CORE_M? symbol setup
Although all of the default project settings should work fine, the LPCOpen platform code requires a few additional configuration steps.

Right click on the project in the Project explorer and select Properties from the popup menu. This will being up the project properties dialog window.

From the category list on the left side of the dialog window, select the C/C++ Build option. In the right half of the window, notice that the project contains 2 configurations - Debug and Release. The additional steps indicated below must be applied to both configurations separately. To switch configurations, just select the configuration in the Configuration drop down box.

Select the C/C++ Build->Settings option in the category window and the MCU C Compiler->Symbols option in the Tool Settings tab in the right window. For the device you are using, you will need to add a new symbol here of value CORE_M0, CORE_M0PLUS, CORE_M3, or CORE_M4. To add this new symbol, click the green + button and type in the name of the symbol and press OK. A list of CORE_M? values to use for each device can be found at one of the links below based on your selected device family.
CHIP: LPC8xx Chip driver build time options
CHIP: LPC11xx Chip driver build time options
CHIP: LPC13xx Chip driver build time options
CHIP: LPC17xx/40xx Chip driver build time options
CHIP: LPC18xx/43xx Chip driver build time options
The example screen below uses CORE_M3 for the LCP1788 device. Do this for both Debug and Release configurations.

sys_config.h symbols
If a symbol needed for building a platform isn't included in sys_config.h (see Adding platform definitions using sys_config.h), then is must also be added in the symbol list similar to the CORE_M value.

Xpresso run-time library selection
Most LPCOpen projects run with the Redlib(none) or Redlib(nohost) libraries. These are the recommended libraries to use when building LPCOpen. For best size, use the (none) version of the library. If you plan on using standard I/O (printf), use the (nohost) version of the library. If you use the DEBUG_ENABLE option (see Adding platform definitions using sys_config.h), then use the (nohost) option. The library type can be selected on the quickstart panel.

Adding source files
Now that the project has been setup, source files can be added to the project. Multiple source files may need to be added from multiple directories.

The example procedure below shows the files needed to build the Embedded Artists LPC1788 board library.

- Select files from the IP layer as needed by the LPC1788 device
- Select all files from the LPC17xx/40xx Chip layer
- Select all files from the Chip common code area
- Select all files from the EA1788/40xx board layer
- Select sys_config.h from the EA1788 board layer (specific to the EA1788 board)

Files are added to the Xpresso project in groups. The IP layer, Chip layer, and Board layer files each needed to be added in a separate dialog. A complete list of files to add specific to a chip or board can be found at Files required for Chip layer.

To add IP layer source files to the project, right click on the project in the project xplorer window and select import. Select the general->File System and press Next>.

Browse to the "lpc_ip" directory and a selection of files will appear in the file view below the directory box. Only check the files that apply to the device family you are using. A full IP layer file list associated with each device family can be found at IP drivers required for Chip layer code. Press Finish when all the files have been selected.
In the image below, the IP layer files for the LPC1788 device are selected.

The import procedure needs to be repeated for the Chip layer, Chip common, and Board layer files. In the images below, the Chip and Board layer files for the LPC1788 device and EA1788 board are added.
"<LPCOPEN_PATH>\software\lpc_core\lpc_chip\chip_17xx_40xx".

"<LPCOPEN_PATH>\software\lpc_core\lpc_chip\chip_common".

"<LPCOPEN_PATH>\software\lpc_core\lpc_board\boards_17xx_40xx\ea_devkit_17884088".

What about common board code? Do I need to add it to the project?
Common board source code files (files in the "<LPCOPEN_PATH>\software\lpc_core\lpc_board\board_common" directory) do not need to be added to the project, although this directory needs to be added as an include path. When a board file is neede by a platform, the source code for that Board later will include the necessary common board source files as part of it's source code.

Adding include paths
To add include paths to the project, right click on the project in the project explorer window and select properties. Select the C/C++ Build->Settings option in the category window and the MCU C Compiler->Includes option in the Tool Settings tab in the right window. Add include paths one at a time to the project by pressing the green + symbol. Be sure to do this for both Debug and Release configurations. Once all the include paths have been added, press OK to return to the workspace view.
For the EA1788 board project, the following include paths are needed:

- "<LPCOPEN_PATH>\software\CMSIS\CMSIS\Include"
- "<LPCOPEN_PATH>\software\lpc_core\lpc_ip"
- "<LPCOPEN_PATH>\software\lpc_core\lpc_chip\chip_common"
- "<LPCOPEN_PATH>\software\lpc_core\lpc_chip\chip_lpc17xx_40xx"
- "<LPCOPEN_PATH>\software\lpc_core\lpc_boards\board_common"
- "<LPCOPEN_PATH>\software\lpc_core\lpc_boards\boards_17xx_40xx\ea_devkit_17884088"
- "<LPCOPEN_PATH>\software\lpc_core\lpc_boards\boards_17xx_40xx\ea_devkit_17884088\ea_devkit_1788" (for EA1788 sys_config.h only)
  Include paths needed for the Chip and Board layers for a device family can be found at LPCOpen library configurations.

At this point, the library project is complete. You can build test the debug and release configurations of your project now.

    Building target: libboard_lib_1788.a
    Invoking: MCU Archiver
    arm-none-eabi-ar -r  "libboard_lib_1788.a"  ./adc_001.o ./adc_17xx_40xx.o ./board_ea_devkit_17884088.o ./can_001.o ./can_17xx_40xx.o ./clock_17xx_40xx.o ./cmp_17xx_40xx.o ./crc_001.o ./crc_17xx_40xx.o ./dac_001.o ./dac_17xx_40xx.o ./eeprom_001.o ./eeprom_17xx_40xx.o ./emc_17xx_40xx.o ./enet_002.o ./enet_17xx_40xx.o ./gpdma_001.o ./gpdma_17xx_40xx.o ./i2c_001.o ./i2c_17xx_40xx.o ./i2s_001.o ./i2s_17xx_40xx.o ./iocon_17xx_40xx.o ./lcd_001.o ./lcd_17xx_40xx.o ./mem_tests.o ./ring_buffer.o ./ritimer_17xx_40xx.o ./rtc_001.o ./rtc_17xx_40xx.o ./sdc_001.o ./sdc_17xx_40xx.o ./sdmmc_17xx_40xx.o ./spi_17xx_40xx.o ./ssp_001.o ./ssp_17xx_40xx.o ./sysctl_17xx_40xx.o ./sysinit_ea_devkit_17884088.o ./timer_001.o ./timer_17xx_40xx.o ./uart_17xx_40xx.o ./usart_001.o ./wwdt_001.o ./wwdt_17xx_40xx.o
    c:\nxp\LPCXpresso_5.2.4_2122\lpcxpresso\tools\bin\arm-none-eabi-ar.exe: creating libboard_lib_1788.a
    Finished building target: libboard_lib_1788.a

    make --no-print-directory post-build
    Performing post-build steps
    arm-none-eabi-size "libboard_lib_1788.a" ; # arm-none-eabi-objdump -h -S "libboard_lib_1788.a" >"libboard_lib_1788.lss"
       text    data     bss     dec     hex filename
        660       0       0     660     294 adc_001.o (ex libboard_lib_1788.a)
        428       0       0     428     1ac adc_17xx_40xx.o (ex libboard_lib_1788.a)
       8772      16      18    8806    2266 board_ea_devkit_17884088.o (ex libboard_lib_1788.a)
       9492       0       0    9492    2514 can_001.o (ex libboard_lib_1788.a)
        612       0       0     612     264 can_17xx_40xx.o (ex libboard_lib_1788.a)
       1848       0       0    1848     738 clock_17xx_40xx.o (ex libboard_lib_1788.a)
          0       0       0       0       0 cmp_17xx_40xx.o (ex libboard_lib_1788.a)
        400       0       0     400     190 crc_001.o (ex libboard_lib_1788.a)
        180       0       0     180      b4 crc_17xx_40xx.o (ex libboard_lib_1788.a)
        216       0       0     216      d8 dac_001.o (ex libboard_lib_1788.a)
         32       0       0      32      20 dac_17xx_40xx.o (ex libboard_lib_1788.a)
       1168       0       0    1168     490 eeprom_001.o (ex libboard_lib_1788.a)
        264       0       0     264     108 eeprom_17xx_40xx.o (ex libboard_lib_1788.a)
        132       0       0     132      84 emc_17xx_40xx.o (ex libboard_lib_1788.a)
       1016       0       4    1020     3fc enet_002.o (ex libboard_lib_1788.a)
        248       0       0     248      f8 enet_17xx_40xx.o (ex libboard_lib_1788.a)
        988       0       0     988     3dc gpdma_001.o (ex libboard_lib_1788.a)
       1740     128       8    1876     754 gpdma_17xx_40xx.o (ex libboard_lib_1788.a)
       1748       0       0    1748     6d4 i2c_001.o (ex libboard_lib_1788.a)
       2344      84     120    2548     9f4 i2c_17xx_40xx.o (ex libboard_lib_1788.a)
       1504       0       0    1504     5e0 i2s_001.o (ex libboard_lib_1788.a)
        928       0       0     928     3a0 i2s_17xx_40xx.o (ex libboard_lib_1788.a)
          0       0       0       0       0 iocon_17xx_40xx.o (ex libboard_lib_1788.a)
        608       0       0     608     260 lcd_001.o (ex libboard_lib_1788.a)
        640       1       0     641     281 lcd_17xx_40xx.o (ex libboard_lib_1788.a)
       1232       0       0    1232     4d0 mem_tests.o (ex libboard_lib_1788.a)
       1120       0       0    1120     460 ring_buffer.o (ex libboard_lib_1788.a)
          0       0       0       0       0 ritimer_17xx_40xx.o (ex libboard_lib_1788.a)
       1264       0       0    1264     4f0 rtc_001.o (ex libboard_lib_1788.a)
         92       0       0      92      5c rtc_17xx_40xx.o (ex libboard_lib_1788.a)
        820       0       0     820     334 sdc_001.o (ex libboard_lib_1788.a)
        292       0       0     292     124 sdc_17xx_40xx.o (ex libboard_lib_1788.a)
       5760       0       0    5760    1680 sdmmc_17xx_40xx.o (ex libboard_lib_1788.a)
          0       0       0       0       0 spi_17xx_40xx.o (ex libboard_lib_1788.a)
         60       0       0      60      3c ssp_001.o (ex libboard_lib_1788.a)
       2468       0       0    2468     9a4 ssp_17xx_40xx.o (ex libboard_lib_1788.a)
        192       0       0     192      c0 sysctl_17xx_40xx.o (ex libboard_lib_1788.a)
       1272       0       0    1272     4f8 sysinit_ea_devkit_17884088.o (ex libboard_lib_1788.a)
        168       0       0     168      a8 timer_001.o (ex libboard_lib_1788.a)
        160       0       0     160      a0 timer_17xx_40xx.o (ex libboard_lib_1788.a)
       2072       0     530    2602     a2a uart_17xx_40xx.o (ex libboard_lib_1788.a)
       2060       0       0    2060     80c usart_001.o (ex libboard_lib_1788.a)
        116       0       0     116      74 wwdt_001.o (ex libboard_lib_1788.a)
         24       0       0      24      18 wwdt_17xx_40xx.o (ex libboard_lib_1788.a)

    15:14:52 Build Finished (took 33s.883ms)