![]() |
OS
v1.7.5
Documentation
|
Download the latest release from the official repository :
Unpack the release package and add the sources files to your project.
You only need to clone the main
branch as follows:
Add the OS kernel as a submodule to your project:
Then, run the initialize command to fetch the code for the first time:
To update the submodule to the latest just run:
The file config.h
provides specific Configuration macros to customize several aspects of the OS. In order to build your solution with QuarkTS++, you should provided your own copy of this configuration file. You can obtain a copy with the default configuration by issuing the following command:
Include the source files to your project. Also, make sure you add a copy of the file config.h
and modify it according to your needs. Setup your compiler including the path of the OS directory. Include the header file QuarkTS.h
and setup the instance of the kernel using the qOS::core::init() inside the main thread to initialize te kernel, specify the reference clock and the idle-task ( see Timing Approach). Additional configuration to the target compiler may be required to add the path to the directory of header files. The code below shows a common initialization procedure in the main source file.
File main.c
In the above code, the following considerations should be taken:
os.init()
must be called before any interaction with the OS. Here, the os
its an instance of the qOS::core kernel interface.HardwareSetup()
should be a function with all the hardware instructions needed to initialize the target system.Configure_Periodic_Timer_Interrupt_1ms()
should be a function with all the hardware instructions needed to initialize and enable a timer with an overflow tick of one millisecond.Tasks can be later added to the scheduling scheme by simply calling qOS::core::add() with any of its overloads for specific purpose tasks.
This example demonstrates a simple environment setup for multiple tasks. Initially, only task1
and task2
are enabled. task1
runs every 2 seconds 10 times and then stops. task2
runs every 3 seconds indefinitely. task1
enables task3
at its first run. task3
run every 5 seconds. task1
disables task3
on its last iteration and change task2
to run every 1/2 seconds. In the end, task2
is the only task running every 1/2 seconds.
When adding tasks, they can accept a parameter of type pointer to void void*
also called the storage pointer. This parameter could be used for multiple applications, including storage, task identification, duplication removal and others. The following example shows the usage of this argument to avoid callback duplication among tasks with the same behavior.
Consider a scenario where you have to build a digital controller for several physical variables, for example, a PID controller for temperature, humidity and light. The PID algorithm will be the same for all variables. The only difference will be the variable input, the controlled output action and the PID gains. In this case, each of the PID tasks will utilize the same callback methods. The only difference will be the I/O parameters (specific for each PID controller).
Let’s define a PID data structure with the I/O variables and gains.
A task will be added to the scheme to collect the sensor data and apply the respective control output.
Then, three different tasks are created to apply the respective PID controller. Note that these tasks refer to the same callback method and we assign pointers to the respective variables.
QuarkTS++ is widely compatible with most Arduino cores including 8bit architectures. To install the QuarkTS++ OS into your Arduino IDE you can use the Library Manager (available from IDE version 1.6.2). Open the IDE and click to the "Sketch" menu and then Include Library > Manage Libraries.
Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. Type in the search box "QuarkTS" and when listed, click the install button. Once it has finished, an Installed tag should appear next to the library. You can close the library manager.
You can now find the new library available in the Sketch > Include Library menu.
When invoking the os.init()
for the first time, make sure to pass the millis
function as argument