libemb

1. Introduction

“libemb” is a collection of libraries which try to make things needed in many STM32 (ARM-Cortex-M3) or MSP430 (MSP430G2553) based projects more convinient. It includes helbers for console output, UART usage, as well es drivers for specific hardware. The STM32 version of “libemb” relays on “libopencm3“, the MSP430 version on msp430gcc the headers that come with it.

Currently “libemb” contains the following helper libraries:

libserial

  • configure default USART/USCI to be used as UART for serial communication
  • read-/write to the default UART blocking and non-blocking

Details and usage examples

libconio

  • console IO, currently done on the UART configured by “libserial”
  • methods for printing strings and numbers
  • includes tiny version of “printf”

Details and usage examples

libshell

  • provide environment needed to build interactive (remote-) shells
  • define commands with descriptions and callback handlers
  • does the argument parsing for you

Details and usage examples

And the following driver libraries:

libnrf24l01

  • API for the Nordic nRF24l01+ wireless module
  • initialization of the SPI bus to communicate with the module
  • helper functions to configure the nRF24l01 into one of its modes: SB, ESB and ESB with payload
  • helper functions to read/modify the conf-registers of the module

Details and usage examples

2. Supported Targets

Currently the following ARM-Cortex-M3 targets are supported:

  • STM32F100 (tested on the STM32VL Discovery)
  • STM32F103 (tested on the IFLAT-32)
And the following MSP430 targets:
  • MSP430G2553 (tested on TI Launchpad)

MCU/hardware specific stuff is clearly seperated from the rest, so porting to a different target (or base library) should not be a big deal.

3. Obtaining “libemb”

The sources of “libemb” are hosted on github. You can browse them online, or clone them with the following command:

git clone http://github.com/wendlers/libemb.git

4. Compilation

STM32 version of “libemb” depends on “libopencm3“. The compilation steps described here assume, that you installed “libopencm3” allong with the “summon-arm-toolchain“, located in its default location “~/sat”.

The MSP430 version of “libemb” is written for msp430-gcc on Linux (I used v4.5.3 which is available as package on ubuntu). For flashing the “mspdebug” tool was used (also from the Ubuntu package). It is assumed, you have  a working msp430-gcc on your system.

1. Compile for STM32

To compile the libraries, change to the toplevel directory “libemb” and issue:

make clean all

This will produce the various libraries in the “lib” directory of each of the subprojects.

2. Compile for MSP430

TARCH=MSP430 make clean all

This will produce the various libraries in the “lib” directory of each of the subprojects.

You could copy the libraries to a location you like, along with the header files under each “src/include” directory of the subprojects, or use the install target as described in the next section.

5. Installation

1. Install for STM32

To instal the libraries and headers to the default location which is “$HOME/sat/arm-none-eabi”, type the following:

make install

The libraries then go to “$HOME/sat/arm-none-eabi/lib”, and the headers go to “$HOME/sat/arm-none-eabi/include/libemb/”.

2. Install for MSP430

To instal the libraries and headers to the default location which is “$HOME/msp430″, type the following:

TARCH=MSP430 make install

The libraries then go to “$HOME/msp430/lib”, and the headers go to “$HOME/msp430/include/libemb/<subproject>/”.

If yout don’t like that location specify a different one by setting “INSTDIR”:

INSTDIR=[your-location] make install

6. Compilation of the Tests

Within the directory “test”, various test firmwares are located (see the README that comes with each test for more information). While compiling the tests, make sure, to do this for the proper target MCU. Currently the targets STM32F103 (which is the default target) and STM32F100 are supported.

To compile the tests for the STM32F100:

TARCH=STM32_100 make test

And to compile the tests for the STM32F103:

TARCH=STM32_103 make test

And for the MSP430G2553:

TARCH=MSP430 make test

To flash a test firmware to your device, you could use the “flash-target” make target which is available in the makefile of each test (not in the toplevel makefile). For more details see the README provided for each test.

7. Doxygen Docs

If you installed doxygen on your system, you could generate the HTML-based API documentation by calling:

make gen-docs

This will create the API documentation unter “doc/gen/html” within each subproject.

8. Tailor to a Different Environment

If you use a different compiler etc., you could change the settings in the “common_lib.mk” file which is located in the top-level directory of “libemb”. To tailor the settings for the test firmwares, edit “common.mk” in the same directory.

2 Comments to libemb

  1. 20. August 2012 at 19:41 | Permalink

    Really nice and usefull library, im using it here: https://github.com/chris-j/microcli-stm32f0-discovery

Leave a Reply

You must be logged in to post a comment.