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 typedef uint32_t TaskBuffer_t;
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;
37 extern const uint32_t sunset_taskName;
39 extern const uint32_t ble_cli_taskName;
41 extern const uint32_t print_taskName;
42
44 typedef void (*taskfunc_t)(void);
45
55 extern void start_thread(taskfunc_t taskFunction,
56 const uint32_t taskName,
57 const int priority,
58 const int stackSize,
59 TaskBuffer_t* buffer);
69 extern void start_suspended_thread(taskfunc_t taskFunction,
70 const uint32_t taskName,
71 const int priority,
72 const int stackSize,
73 TaskBuffer_t* buffer);
74
76 extern void yield_this_thread();
77
79 extern void suspend_this_thread();
80
85 extern void resume_thread(const uint32_t taskName);
86
91 uint16_t get_usage_percent(const uint32_t taskName);
92
98 extern void notify_thread(const uint32_t taskName, int wakeUpEvent);
99
105 extern int wait_notification(const int timeout_ms);
106
107 // Display a threads usage report
108 extern void display_thread_debug();
109
111 extern void shutdown();
112
113#ifdef __cplusplus
114}
115
116} // namespace threads
117} // namespace bsp
118} // namespace lampda
119#endif
void notify_thread(const uint32_t taskName, int wakeUpEvent)
notify a thread to resume
Definition: threads.cpp:161
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:130
int wait_notification(const int timeout_ms)
block this thread until a timeout or notification is received
Definition: threads.cpp:172
void shutdown()
Shutdown the task driver cleanly.
Definition: threads.cpp:189
void start_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize, TaskBuffer_t *buffer)
Start a separate thread, running until the system shuts off.
Definition: threads.cpp:116
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:44
void resume_thread(const uint32_t taskName)
resume a target thread
Definition: threads.cpp:132
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:145
void start_suspended_thread(taskfunc_t taskFunction, const uint32_t taskName, const int priority, const int stackSize, TaskBuffer_t *buffer)
Start a separate thread, running until the system shuts off. Start in suspended state.
Definition: threads.cpp:122
void yield_this_thread()
make this thread pass the control to other threads
Definition: threads.cpp:128
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