rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
|
This library allows development on a LPC17xx board from NXP. The release includes configuration for the MBED platform which uses a LPC1768.
In order to compile, you will need a gcc version tuned to build bare metal binaries. I use the one which can be build using the shell script available here: https://github.com/esden/summon-arm-toolchain
This release also includes two header files from ARM and NXP that defines C structures to access Cortex M3 and LPC17xx registers.
This library provides
A lot of stuff ! Mainly the remainder of drivers for the other devices such as
This library has mainly been developped for two purposes
For this last purpose, the MBED was a nice and affordable platform although the whole on the cloud compiler stuff was not much what pleases us as the libraries provided by mbed were HUGE and we wanted to release ALL our code open source, even the low level code. The library provided by NXP (CMSIS) was a bit too high level for what we wanted and thus, writing everything from scratch was our best option.
The first of our project which has been ported to the MBED is Smews: Smart & Mobile Embedded Web Server (http://www.lifl.fr/2XS/smews)
To use the library, you just have to compile it by issuing a 'make'
in the main folder. It will build the library as well as all the samples. But before that, you have to install an arm compiler and modify the Makefile.vars to set the path and executable names of your compiler. The library should be shipped with the configuration for arm-none-eabi-* tools suite. Modifying PREFIX
and GCC_VERSION
should be enough.
If everything builds, then you are ready to use it.
Otherwise, there are few things that you have to check:
Makefile.vars
file modified according to this compiler?The easiest way to start your first program is to copy the samples/skel folder and start from here.
In this folder, you will find two files
The Makefile rules how your program is compiled. Here is how it looks
OUTPUT_NAME
variable define the name of the final binary. Here it will generate modify_this.elf
and modify_this.bin
files SRC
variable should contain the name of all your
.c files. These files will be compiled and linked to the final binary RFLPC_DIR
is the relative path from your folder to the folder that contains the rflpc-config
file include
line includes the makefile that does all the magic for you. It contains generic rules for compiling your source files as well as the link rules to generate the
.elf and
.bin filesThus, you should just have to modify OUTPUT_NAME
and SRC
variables to create the needed makefile to compile your project.
To compile, just type make
. You should see something like that
If so, then you will have two files, an elf file and a bin file. The elf file is your program in ELF format. You can inspect it, dissassemble it... with commands such as your arm objdump. The bin file is the raw code memory file which is an extract of the .text and
.data section of your elf file. For the MBED platform, it is this file that you have to copy on the USB mass storage drive.
To program your code on the MBED, you can issue a make program
. This command will try to guess the mountpoint of your MBED (using the output of the mount
command) and copy the bin file to it. After that, you just have to reset the MBED to actually flash the code.
The library can be configured so that some features are not included. This can save loads of code memory when you just need a few drivers.
The configuration file is located in the rflpc17xx/config folder. When you clone the git repository, this file is NOT included. However, if you just use make
in the library folder, a default full configuration file is generated
This file is a C header file defining the needed MACRO to activate some functionalities To generate the file, you can use the makefile in the config folder. There are two main rules for generating a config file
make empty_config
make full_config
The first one generates an empty config file. Then, when the library is compiled it is compiled with the minimum features which are:
Pins configuration, GPIOs and LEDs are only macros or inlines in the library. Thus, the produced code will only include it if you use it. The library in the minimal configuration is about 800 bytes of code.
The second option (full_config) automatically extracts all the RFLPC_CONFIG_ENABLE_xxx
macros from the library source code and add it to the config file. Thus, all the functionalities of the library are included. At the moment, this produce a library that is about 8kB of code.
The simplest way to fine tune the library is to start by a make full_config and then remove the line you do not want from the rflpc17xx/config/config-options.h file You can either remove the lines completely or comment them
When fine tuning the configuration be sure to: