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
10namespace lampda {
11namespace platform {
13namespace threads {
14
15extern "C" {
16#endif
17
18#define SCHED_NOTIFY_TIMER (1 << 0) // reserved event mask
19
20 // store tasks names here
22 const char* const pd_taskName = "usbpd";
24 const char* const pdInterruptHandle_taskName = "intpd";
26 const char* const power_taskName = "power";
28 const char* const user_taskName = "user";
30 const char* const taskScheduler_taskName = "task_sched";
31
33 typedef void (*taskfunc_t)(void);
34
43 extern void start_thread(taskfunc_t taskFunction,
44 const char* const taskName,
45 const int priority,
46 const int stackSize);
55 extern void start_suspended_thread(taskfunc_t taskFunction,
56 const char* const taskName,
57 const int priority,
58 const int stackSize);
59
61 extern void yield_this_thread();
62
64 extern void suspend_this_thread();
65
68 extern void suspend_all_threads();
69
74 extern int is_all_suspended();
75
80 extern void resume_thread(const char* const taskName);
81
87 extern void notify_thread(const char* const taskName, int wakeUpEvent);
88
94 extern int wait_notification(const int timeout_ms);
95
96 // compute and return a debug for threads
97 extern void get_thread_debug(char* textBuff);
98
99#ifdef __cplusplus
100}
101
102} // namespace: threads
103} // namespace: platform
104} // namespace: lampda
105#endif
106
107#endif
void yield_this_thread()
make this thread pass the control to other threads
Definition: threads.cpp:105
const char *const pd_taskName
name of the USB power delivery task
Definition: threads.h:22
void(* taskfunc_t)(void)
model of a task function
Definition: threads.h:33
void start_suspended_thread(taskfunc_t taskFunction, const char *const taskName, const int priority, const int stackSize)
Start a separate thread, running until the system shuts off. Start in suspended state.
Definition: threads.cpp:72
const char *const pdInterruptHandle_taskName
name of the USB power delivery interrupt handle task
Definition: threads.h:24
void start_thread(taskfunc_t taskFunction, const char *const taskName, const int priority, const int stackSize)
Start a separate thread, running until the system shuts off.
Definition: threads.cpp:42
const char *const user_taskName
name of the optional user task
Definition: threads.h:28
void notify_thread(const char *const taskName, int wakeUpEvent)
notify a thread to resume
Definition: threads.cpp:151
void resume_thread(const char *const taskName)
resume a target thread
Definition: threads.cpp:131
const char *const taskScheduler_taskName
name of the task scheduling task
Definition: threads.h:30
int wait_notification(const int timeout_ms)
block this thread until a timeout or notification is received
Definition: threads.cpp:172
void suspend_this_thread()
threads can only suspend itself
Definition: threads.cpp:107
void suspend_all_threads()
Suspend all threads.
Definition: threads.cpp:109
int is_all_suspended()
check that all threads are suspended (mandatory for sleep mode)
Definition: threads.cpp:119
const char *const power_taskName
name of the main power task
Definition: threads.h:26
Program scope.
Definition: control_fixed_modes.hpp:12