yauclib - yet another microcontroller library. This library is an attempt to write device drivers and an abstraction layer for different microcontroller families in C++.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Moritz Strohm 990e9f3737 AVR Microcontroller::readPin: fixed error 3 months ago
doc@b2efee97a5 updated doc 4 months ago
drivers moved serial code from MAX7219 into the new SerialWriter class, redefined StreamWriter::write 4 months ago
tests moved serial code from MAX7219 into the new SerialWriter class, redefined StreamWriter::write 4 months ago
.gitignore fixed errors, added LED driver test program 4 months ago
.gitmodules Driver interface: removed protected microcontroller attribute 4 months ago
InterruptHandler.h added Microcontroller::addTimerInterruptHandler method, added InterruptHandler interface 4 months ago
LICENSE initial commit 4 months ago
Microcontroller.h moved check for the UC_PACKAGE definition into Microcontroller_AVR, re #1 3 months ago
Microcontroller_AVR.cpp AVR Microcontroller::readPin: fixed error 3 months ago
README.md updated README.md 4 months ago
SystemInterrupt.h initial commit 4 months ago
definitions.h implemented reading and writing pin values and setting pin directions for some ATtiny microcontrollers 4 months ago
ucmf.config made UC_PACKAGE config parameter mandatory, fixes #1 3 months ago

README.md

yauclib - yet another microcontroller library

This library is an attempt to write device drivers and an abstraction layer for different microcontroller families in C++.

How it works

The microcontroller is represented using the Microcontroller class which provides fundamental methods like writing and reading pin values. The class acts as an abstraction layer so that programs do not need to include mircocontroller-specific code.

Pin numbers represent the physical pins on the microcontrollers package instead of using the microcontroller-specific port names. This code snippet illustrates how microcontroller programs can be written using yauclib:

//Setting Pin 5 high:
Microcontroller::writePin(5, true);
//Read from Pin 4:
bool enabled = Microcontroller::readPin(4);

Here is an example, how you would make an LED blink using yauclib:

//blink the LED: turn it on and off every 500 miliseconds:
while (true) {
    //Set pin 3 high:
    Microcontroller::writePin(3, true);
    //Wait 500 ms:
    Microcontroller::wait(500);
    //Set pin 3 low:
    Microcontroller::writePin(3, false);
    //Wait 500 ms:
    Microcontroller::wait(500);
}

In a similar way, you would access timer and PWM hardware of your microcontroller.

Drivers

Each driver is placed in the "drivers" folder. They are only added to your program if you include them using #include in your C++ program source file and add the driver source file in the compilation process.

Each driver is derived from the "Driver" base class so that they have a common interface for basic methods like mapping pins. Drivers may also include special methods if they are needed to use the device they are driving in a certain manner.

To faciliate the mapping between device and microcontroller pins, each driver has a set of named so-called "application pins". These are then mapped to physical microcontroller pin numbers using the "applyPinMapping" method. With this mapping, you can simply write which application pin is connected to which microcontroller pin. A code snippet for a serial device:

//The clock pin of the device is connected to pin 3:
serial.applyPinMapping(APIN::SCK, 3);
//The data pin is connected to pin 2:
serial.applyPinMapping(APIN::SDA, 2);

Compilation

The library itself is just a library, so it doesn't come with a compilation framework. However, it relies on certain definitions to be present that are set when compiling using the ucmf tool (see https://codeberg.org/ncc1988/ucmf). The microcontroller family and model should be set using the UC_FAMILY_... and UC_MODEL_... definitions:

//for ATtiny45:
UC_FAMILY_AVR
UC_MODEL_ATTINY45

//for 8051:
UC_FAMILY_8051
...

Examples

The "tests" folder contains test programs for the drivers that can be compiled using either the ucmf tool and make, by writing a hand-crafted shell script or some other fancy compilation process. They are written independent of any particular microcontroller architecture.

Documentation

The documentation is available on Codeberg.org:

https://codeberg.org/ncc1988/yauclib/wiki/Home

It is also available as git submodule of this repository. To download the documentation, use the following git commands:

git submodule init
git submodule update

The documentation can then be found in the "doc" folder.