Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
threads.h
Go to the documentation of this file.
1
5// do not use pragma once here, has this can be mocked
6#ifndef PLATFORM_THREADS_H
7#define PLATFORM_THREADS_H
8
9#ifdef __cplusplus
10
11#include <cstdint>
12
13namespace lampda {
14namespace platform {
16namespace threads {
17
18extern "C" {
19#endif
20
21#define SCHED_NOTIFY_TIMER (1 << 0) // reserved event mask
22
23 // store tasks names here
25 extern const uint32_t pd_taskName;
27 extern const uint32_t pdInterruptHandle_taskName;
29 extern const uint32_t power_taskName;
31 extern const uint32_t user_taskName;
33 extern const uint32_t taskScheduler_taskName;
34 // name of the task t schedule sunset
35 extern const uint32_t sunset_taskName;
36
38 typedef void (*taskfunc_t)(void);
39
48 extern void start_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize);
57 extern void start_suspended_thread(taskfunc_t taskFunction,
58 const uint32_t taskName,
59 const int priority,
60 const int stackSize);
61
63 extern void yield_this_thread();
64
66 extern void suspend_this_thread();
67
70 extern void suspend_all_threads();
71
76 extern int is_all_suspended();
77
82 extern void resume_thread(const uint32_t taskName);
83
89 extern void notify_thread(const uint32_t taskName, int wakeUpEvent);
90
96 extern int wait_notification(const int timeout_ms);
97
98 // compute and return a debug for threads
99 extern void get_thread_debug(char* textBuff);
100
101#ifdef __cplusplus
102}
103
104} // namespace: threads
105} // namespace: platform
106} // namespace: lampda
107#endif
108
109#endif
const uint32_t pd_taskName
name of the USB power delivery task
Definition: threads.cpp:18
void yield_this_thread()
make this thread pass the control to other threads
Definition: threads.cpp:134
const uint32_t taskScheduler_taskName
name of the task scheduling task
Definition: threads.cpp:22
void(* taskfunc_t)(void)
model of a task function
Definition: threads.h:38
void notify_thread(const uint32_t taskName, int wakeUpEvent)
notify a thread to resume
Definition: threads.cpp:180
const uint32_t power_taskName
name of the main power task
Definition: threads.cpp:20
const uint32_t pdInterruptHandle_taskName
name of the USB power delivery interrupt handle task
Definition: threads.cpp:19
int wait_notification(const int timeout_ms)
block this thread until a timeout or notification is received
Definition: threads.cpp:201
void resume_thread(const uint32_t taskName)
resume a target thread
Definition: threads.cpp:160
void suspend_this_thread()
threads can only suspend itself
Definition: threads.cpp:136
void suspend_all_threads()
Suspend all threads.
Definition: threads.cpp:138
int is_all_suspended()
check that all threads are suspended (mandatory for sleep mode)
Definition: threads.cpp:148
const uint32_t user_taskName
name of the optional user task
Definition: threads.cpp:21
void start_suspended_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize)
Start a separate thread, running until the system shuts off. Start in suspended state.
Definition: threads.cpp:104
void start_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize)
Start a separate thread, running until the system shuts off.
Definition: threads.cpp:74
Program scope.
Definition: control_fixed_modes.hpp:12