Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
threads.h
Go to the documentation of this file.
1
4#pragma once
5
6#define SCHED_NOTIFY_TIMER (1 << 0) // reserved event mask
7
8#ifdef __cplusplus
9
10#include <cstdint>
11
12namespace lampda {
13namespace bsp {
15namespace threads {
16
17extern "C" {
18#endif
19
20 typedef void* TaskHandle_t;
21
22 // store tasks names here
24 extern const uint32_t pd_taskName;
26 extern const uint32_t pdInterruptHandle_taskName;
27 // Name of the button handling task
28 extern const uint32_t button_taskName;
30 extern const uint32_t power_taskName;
32 extern const uint32_t user_taskName;
34 extern const uint32_t taskScheduler_taskName;
36 extern const uint32_t sunset_taskName;
38 extern const uint32_t ble_cli_taskName;
40 extern const uint32_t print_taskName;
41
43 typedef void (*taskfunc_t)(void);
44
53 extern void start_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize);
62 extern void start_suspended_thread(taskfunc_t taskFunction,
63 const uint32_t taskName,
64 const int priority,
65 const int stackSize);
66
68 extern void yield_this_thread();
69
71 extern void suspend_this_thread();
72
77 extern void resume_thread(const uint32_t taskName);
78
83 uint16_t get_usage_percent(const uint32_t taskName);
84
90 extern void notify_thread(const uint32_t taskName, int wakeUpEvent);
91
97 extern int wait_notification(const int timeout_ms);
98
99 // Display a threads usage report
100 extern void display_thread_debug();
101
103 extern void shutdown();
104
105#ifdef __cplusplus
106}
107
108} // namespace threads
109} // namespace bsp
110} // namespace lampda
111#endif
void notify_thread(const uint32_t taskName, int wakeUpEvent)
notify a thread to resume
Definition: threads.cpp:149
const uint32_t ble_cli_taskName
BLE cli queue.
Definition: threads.cpp:26
void suspend_this_thread()
threads can only suspend itself
Definition: threads.cpp:118
int wait_notification(const int timeout_ms)
block this thread until a timeout or notification is received
Definition: threads.cpp:160
void shutdown()
Shutdown the task driver cleanly.
Definition: threads.cpp:177
const uint32_t print_taskName
UART print task.
Definition: threads.cpp:27
const uint32_t sunset_taskName
name of the task schedule sunset
Definition: threads.cpp:25
const uint32_t taskScheduler_taskName
name of the task scheduling task
Definition: threads.cpp:24
const uint32_t user_taskName
name of the optional user task
Definition: threads.cpp:23
void(* taskfunc_t)(void)
model of a task function
Definition: threads.h:43
void resume_thread(const uint32_t taskName)
resume a target thread
Definition: threads.cpp:120
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:106
const uint32_t pdInterruptHandle_taskName
name of the USB power delivery interrupt handle task
Definition: threads.cpp:20
uint16_t get_usage_percent(const uint32_t taskName)
Get the stack usage of this task, in percent.
Definition: threads.cpp:133
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:111
void yield_this_thread()
make this thread pass the control to other threads
Definition: threads.cpp:116
const uint32_t pd_taskName
name of the USB power delivery task
Definition: threads.cpp:19
const uint32_t power_taskName
name of the main power task
Definition: threads.cpp:22
Program scope.
Definition: control_fixed_modes.hpp:12