4#include "config/config.h"
5#include "include/list.hpp"
6#include "include/clock.hpp"
7#include "include/types.hpp"
8#include "include/task.hpp"
9#include "include/prioqueue.hpp"
10#include "include/input.hpp"
13 #include "include/fsm.hpp"
16 #include "include/cli.hpp"
33 using coreFlags_t = uint32_t ;
54 struct notificationSpreader_t {
74 return ( ( i >= 1U ) && ( i <= 20U ) ) ? 0x00001000UL << ( i - 1U ) : 0x00001000UL;
83 class core final :
protected taskEvent {
86 taskFcn_t releaseSchedCallback{
nullptr };
87 task *yieldTask{
nullptr };
89 prioQueue priorityQueue{ pq_stack,
sizeof(pq_stack)/
sizeof(pq::queueStack_t) };
90 volatile coreFlags_t flag{ 0UL };
91 notificationSpreader_t nSpreader{ notifyMode::NOTIFY_NONE,
nullptr };
92 size_t taskEntries{ 0UL };
98 static const uint32_t BIT_INIT;
99 static const uint32_t BIT_FCALL_IDLE;
100 static const uint32_t BIT_RELEASE_SCHED;
101 static const uint32_t BIT_FCALL_RELEASED;
102 void triggerReleaseSchedEvent(
void )
noexcept;
103 bool checkIfReady(
void )
noexcept;
104 void dispatchTaskFillEventInfo(
task *Task )
noexcept;
105 void dispatch(
list *
const xList )
noexcept;
106 void dispatchIdle(
void )
noexcept;
107 void handleInputWatchers(
void )
noexcept;
110 void operator=(
const core & ) =
delete;
304 bool run(
void )
noexcept;
447 bool add( input::watcher &w ) noexcept;
454 bool remove( input::watcher &w ) noexcept;
static const qOS::duration_t IMMEDIATE
To specify a non-wait time value.
Definition clock.hpp:124
An AT Command Line Interface (CLI) object.
Definition cli.hpp:333
The class to interface the OS.
Definition kernel.hpp:83
bool remove(task &Task) noexcept
Remove the task from the scheduling scheme.
bool yieldToTask(task &Task) noexcept
Yield the control of the current running task to another task.
bool run(void) noexcept
Executes the scheduling scheme. It must be called once after the task pool has been defined.
task * getTaskByID(size_t id) noexcept
Tries to find the task that matches the ID provided.
bool setIdleTask(taskFcn_t callback) noexcept
Set/Change the callback for the Idle-task.
bool setSchedulerReleaseCallback(taskFcn_t callback) noexcept
Set/Change the scheduler release callback function.
task * getTaskByName(const char *name) noexcept
Tries to find the task that matches the name provided.
bool add(task &Task, taskFcn_t callback, const priority_t p, const duration_t t, const iteration_t n, const taskState s=taskState::ENABLED_STATE, void *arg=nullptr) noexcept
Add a task to the scheduling scheme. The task is scheduled to run every t time units,...
bool init(const getTickFcn_t tFcn=nullptr, taskFcn_t callbackIdle=nullptr) noexcept
Task Scheduler initialization. This core method is required and must be called once in the applicatio...
static const priority_t HIGHEST_PRIORITY
A constant that holds the value of the highest priority.
Definition kernel.hpp:117
bool setNameIdleTask(const char *tName) noexcept
Set the name for the idle task.
globalState getGlobalState(task &Task) const noexcept
Retrieve the task global-state.
static const priority_t LOWEST_PRIORITY
A constant that holds the value of the lowest priority.
Definition kernel.hpp:113
bool schedulerRelease(void) noexcept
Disables the kernel scheduling. The main thread will continue after the core::run() call.
static const priority_t MEDIUM_PRIORITY
A constant that holds the value of the medium priority.
Definition kernel.hpp:115
static core & getInstance(void) noexcept
Returns a reference to the OS control instance.
A list object (Generic double-linked)
Definition list.hpp:119
A FSM(Finite State Machine) object.
Definition fsm.hpp:822
A task node object.
Definition task.hpp:348
static const iteration_t SINGLE_SHOT
A constant to indicate that the task will be executed only once after its time has expired.
Definition task.hpp:600
bool add(task &Task, commandLineInterface &cli, const priority_t p, void *arg=nullptr) noexcept
Add a task to the scheduling scheme running an AT Command Line Interface. Task will be scheduled as e...
timeCount_t duration_t
The typedef that specified an time quantity, usually expressed in milliseconds.
Definition clock.hpp:18
clock_t(*)(void) getTickFcn_t
Pointer to a function that gets the current hardware tick value.
Definition clock.hpp:74
#define Q_PRIORITY_LEVELS
Number of priority levels.
Definition config.h:24
#define Q_PRIO_QUEUE_SIZE
The size of the priority queue.
Definition config.h:30
bool eventFlagsCheck(task &Task, taskFlag_t flagsToCheck, const bool clearOnExit=true, const bool checkForAll=false) noexcept
Check for flags set to true inside the task Event-Flags.
bool eventFlagsModify(task &Task, const taskFlag_t tFlags, const bool action) noexcept
Modify the EventFlags for the provided task.
constexpr taskFlag_t EVENT_FLAG(index_t i)
Event flag selector function.
Definition kernel.hpp:72
taskFlag_t eventFlagsRead(task &Task) const noexcept
Returns the current value of the task's EventFlags.
uint32_t taskFlag_t
A 32-bit unsigned integer type to hold the task flags.
Definition task.hpp:299
bool add(task &Task, stateMachine &m, const priority_t p, const duration_t t, const taskState s=taskState::ENABLED_STATE, void *arg=nullptr) noexcept
Add a task to the scheduling scheme running a dedicated state-machine. The task is scheduled to run e...
notifyMode
An enum that defines the modes in which a notification can be delivered.
Definition kernel.hpp:45
bool hasPendingNotifications(const task &Task) const noexcept
Check if the supplied task has pending notifications.
bool notify(notifyMode mode, task &Task, void *eventData=nullptr) noexcept
Sends a notification generating an asynchronous event. If mode = notifyMode::SIMPLE,...
core & os
The predefined instance of the OS kernel interface.
void(*)(event_t) taskFcn_t
Pointer to a task callback.
Definition task.hpp:289
globalState
An enum to describe the task global states.
Definition task.hpp:86
taskState
An enum that defines the possible task operational states.
Definition task.hpp:247
@ DISABLED_STATE
In this state, the time events will be discarded. This operational state is available when the ENABLE...
@ ENABLED_STATE
The task can catch all the events. This operational state is available when the ENABLE bit is set.
STD_TYPE_SIZE_T index_t
A type to instantiate an OS index variable. Can store the maximum size of a theoretically possible ob...
Definition types.hpp:94
STD_TYPE_INT32_T iteration_t
A type to instantiate a variable that hold the number of task iterations.
Definition types.hpp:104
STD_TYPE_UINT8_T priority_t
A type to instantiate a variable to hold the priority value of a task.
Definition types.hpp:109
OS/Kernel interfaces.
Definition bytebuffer.hpp:7