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;
28 // Name of the button handling task
29 extern const uint32_t button_taskName;
31 extern const uint32_t power_taskName;
33 extern const uint32_t user_taskName;
35 extern const uint32_t taskScheduler_taskName;
36 // name of the task schedule sunset
37 extern const uint32_t sunset_taskName;
38
40 typedef void (*taskfunc_t)(void);
41
50 extern void start_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize);
59 extern void start_suspended_thread(taskfunc_t taskFunction,
60 const uint32_t taskName,
61 const int priority,
62 const int stackSize);
63
65 extern void yield_this_thread();
66
68 extern void suspend_this_thread();
69
72 extern void suspend_all_threads();
73
78 extern int is_all_suspended();
79
84 extern void resume_thread(const uint32_t taskName);
85
91 extern void notify_thread(const uint32_t taskName, int wakeUpEvent);
92
98 extern int wait_notification(const int timeout_ms);
99
100 // compute and return a debug for threads
101 extern void get_thread_debug(char* textBuff);
102
104 extern void shutdown();
105
106#ifdef __cplusplus
107}
108
109} // namespace: threads
110} // namespace: platform
111} // namespace: lampda
112#endif
113
114#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:137
const uint32_t taskScheduler_taskName
name of the task scheduling task
Definition: threads.cpp:23
void(* taskfunc_t)(void)
model of a task function
Definition: threads.h:40
void shutdown()
Shutdown the task driver cleanly.
Definition: threads.cpp:231
void notify_thread(const uint32_t taskName, int wakeUpEvent)
notify a thread to resume
Definition: threads.cpp:183
const uint32_t power_taskName
name of the main power task
Definition: threads.cpp:21
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:204
void resume_thread(const uint32_t taskName)
resume a target thread
Definition: threads.cpp:163
void suspend_this_thread()
threads can only suspend itself
Definition: threads.cpp:139
void suspend_all_threads()
Suspend all threads.
Definition: threads.cpp:141
int is_all_suspended()
check that all threads are suspended (mandatory for sleep mode)
Definition: threads.cpp:151
const uint32_t user_taskName
name of the optional user task
Definition: threads.cpp:22
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:107
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:77
Program scope.
Definition: control_fixed_modes.hpp:12