EPPL example libraries  0.1 alpha
 All Files Functions Variables Groups Pages
Example libraries using EPPL

Example library created to show the possibilities of EPPL. Also the EPPL library was tested on this code.

Simple library configuration

The libraries are written for maximum configurability. In every library folder, there is [Library_name]_config_template.h file that you may use for the configuration.

Fallowing subsections describes shortly about the ideology of simple configuration of created libraries.

Alphanumeric LCD library

Alphanumeric LCD library supports many LCD configurations. All can be configured quite straightforward:

  • 8 or 4 bit data bus: To set 4 bits mode just define the fallowing pins of data bus ALCD_D7, ALCD_D6, ALCD_D5 and ALCD_D4. Leave younger nibble undefined or set it to EPPL_NP (ALCD_D3, ALCD_D2, ALCD_D1 and ALCD_D0). For 8 bits mode you have to define every of 8 data lines.
  • Use busy flag or just delay HD44780 gives the possibility to read internal status register. If we can read it, we can check busy flag before sending new data or instruction. If we cannot read busy flag we have to wait predefined period of time after each instruction. Configuration of using busy flag is done by defining or non-defining ALCD_RW pin connection.

Software Pulse Width Modulation library

Software Pulse Width Modulation library supports any number of outputs and its active/non active state. The only limit is in currently supported number of pins in EPPL.

Everything there is configured just by one definition: SPWM_OUTPUTS_ALL

Target microcontroller

Currently only AVR8 microcontrollers are supported.

Standard convention for libraries written using EPPL

I also have tried there to create some standard convention to make libraries usage easier. There are some standard definitions for usage in your code.

Header files to be included

I was trying to write all library header files to include all they needs. It means that you do not have to include anything more than just selected library header file.

Library pins initialization

One of the important strengths of EPPL ideology is that all IO pins are initialized in one call in very beginning of the code.

But how to reconcile it to write external library and initialize all ports in one place? I have done it by defining [Library_name]_PINCONFIG constant in the library header (ALCD_PINCONFIG, SPWM_PINCONFIG). It contains list of pin configuration. To use it, just put it into your eppl initialization instruction like below:

EPPL_mode_inPU, // default
ALCD_PINCONFIG, // LCD config
EPPL_SC(BUTTON1, EPPL_mode_inPU) // button
);

Hotpins inside library

If library uses any pins in interrupt runtime, they becomes Hotpins. To make it easier to mark this pins I have defined in library constant [Library_name]_HOTPINS (see SPWM_HOTPINS).

This constant may be used in global or local hotpins declaration as fallows:

#define EPPL_HOTPINS SPWM_HOTPINS, OTHERLIBRARY_HOTPINS, MY_ISR_DRIVEN_PIN

Take care about the place where Hotpins are defined

There are two types of libraries - one witch can support multithreaded style Hotpins definition and one that can only support global Hotpins definition.

ALCD library has its own source file where a lot of processing is done. There Hotpins are processed during compilation of that file, and cannot be changed when calling from different files. The only possibility for such a library to work in multithreaded program is to set Hotpins inside alcd_config.h file to cover all possibilities.

But if you wish to use ALCD in multithreaded application you have to understand that not only pins operations have to be protected. LCD has its own driver that holds some state. If LCD accessing is divided between treads, the whole access to LCD has to be protected.

In second hand SPWM library has every processing function inlined. Becouse of that, you can set EPPL_HOTPINS definition just right before