Skip to content

akouz/a_coos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

a_coos

rev 1.6

Very simple COoperative Operating System for Arduino based on the standard setjmp library.

Kernel uses about 1K bytes. Highly portable, it has no assembler code and it is independent from hardware. System ticks 1 ms based on millis(). Should run on any Arduino board. Tested with the following boards:

  • Arfuino Uno, Arduino Pro Mini and Seeeduino (ATmega328P)
  • Arduino Leonardo (ATmega32U4)
  • Arduino MKR1000 (SAMD21)
  • XMC1100 Boot Kit and XMC 2Go (XMC1100)
  • RAK Creator Pro (RTL8711)
  • NodeMCU and Wemos Lolin (ESP8266)
  • HBnode (AVR64DD32)
  • Coos does not work with ESP32 because of problems in the ESP32 setjmp library.

Coos made as C++ template. Library consists of a single file coos.h.

Warnings:

  • COOS_DELAY(x) must be used in the task itself; it cannot be used in functions called from task.
  • Variables used by a task should be declared as static, otherwise their value will be lost after COOS_DELAY(x) call.
  • For ATmega microcontrollers, tick can be selected either 1 ms in average, or 1.024 ms. Uptime, daysec, hour and minute calculated correctly disregard of tick selected. Other microcontrollers always have an accurate tick of 1 ms.
  • Actual number of tasks should be less or equal to the declared.

Usage

Place coos.h file into the same folder where the sketch is. In the sketch include coos.h as:

#include "coos.h"

Alternatively, it can be used as an Arduino library. Once installed, there is no need to copy coos.h file into every project any more. To install it as library, locate your Arduino libraries folder. Typically it is:

C:\Users\user\Documents\Arduino\libraries\

Add folder coos:

C:\Users\user\Documents\Arduino\libraries\coos\

Copy files coos.h, library.properties, keywords.txt and folder examples there. In your sketch include coos library as:

#include <coos.h>

Required number of coos tasks and coos tick should be declared in your sketch as follows:

Coos <6, 0> coos; // number 6 in the angle brackets specifies number of user tasks; 0 selects 1 ms tick

Instance name coos must be used, otherwise macro COOS_DELAY(x) cannot operate correctly.

When 1 ms tick selected

Coos <6, 0> coos; 

60,000 ticks in 60 sec:

== COOS demo ==
tick 1 ms average
............................................................ uptime = 60 sec 
............................................................ uptime = 120 sec 
............................................................ uptime = 180 sec 
............................................................ uptime = 240 sec 
............................................................ uptime = 300 sec 

When 1.024 ms tick selected

Coos <6, 1> coos; 

60,000 ticks in aprrox 61 sec:

== COOS demo ==
tick 1.024 ms
............................................................ uptime = 61 sec 
............................................................ uptime = 122 sec 
............................................................ uptime = 184 sec 
............................................................ uptime = 245 sec 
............................................................ uptime = 307 sec 

About

Simple COoperative Operating System for Arduino.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages