yauclib - yet another microcontroller library. This library is an attempt to write device drivers and an abstraction layer for different microcontroller families in C++.
 
 
Go to file
Moritz Strohm 8330803810 Microcontroller_AVR: fixed wait methods, updated doc 2023-09-09 20:27:32 +00:00
doc@fd588b5ba3 Microcontroller_AVR: fixed wait methods, updated doc 2023-09-09 20:27:32 +00:00
drivers LED::setBrightness: interpret every brightness value greater zero as logical high 2023-09-09 18:43:01 +00:00
tests set UC_PACKAGE in the ucmf.config file for the led and max7219 test 2023-09-09 13:56:33 +00:00
.editorconfig LED::setBrightness: interpret every brightness value greater zero as logical high 2023-09-09 18:43:01 +00:00
.gitignore gitignore file: added output.bin.ihex 2022-06-02 20:30:18 +00:00
.gitmodules Driver interface: removed protected microcontroller attribute 2021-06-06 11:36:16 +00:00
InterruptHandler.h added Microcontroller::addTimerInterruptHandler method, added InterruptHandler interface 2021-06-04 20:34:57 +00:00
LICENSE initial commit 2021-05-19 20:49:42 +00:00
Microcontroller.h Microcontroller_AVR: replace calls to _delay_ms and _delay_us with fixed values with implementations that use the _delay_loop functions 2023-09-09 17:14:41 +00:00
Microcontroller_AVR.cpp Microcontroller_AVR: fixed wait methods, updated doc 2023-09-09 20:27:32 +00:00
README.md updated README.md 2021-06-06 11:58:22 +00:00
SystemInterrupt.h initial commit 2021-05-19 20:49:42 +00:00
definitions.h EONE1602: added printShort method, AVR: began implementation of analog pin reading 2022-06-18 15:29:52 +00:00
ucmf.config made UC_PACKAGE config parameter mandatory, fixes #1 2021-06-15 08:21:46 +00:00

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.