Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
lampda::hal::threads Namespace Reference

Define tasks and threads specifics. More...

Typedefs

typedef void(* taskfunc_t) (void)
 
typedef void * TaskHandle_t
 

Functions

static void _redirect_task (void *arg)
 
static void _redirect_suspend_task (void *arg)
 
uint32_t HAL_create_thread (TaskHandle_t *const handle, taskfunc_t task, char const *const name, const int priority, const int stackSize, const int startSuspended)
 Create a thread from the given function and return the associated handle.
 
void HAL_yield ()
 Yield this thread.
 
void HAL_suspend ()
 Suspend this thread.
 
int HAL_wait_notification (const int timeout_ms)
 Put this thread in suspended mode, waiting for a notification. This function wil block execution until the timeout is reached or a value is received.
 
void HAL_notify_thread (TaskHandle_t handle, int wakeUpEvent)
 Notify a thread with a value.
 
void HAL_suspend_thread (TaskHandle_t handle)
 Suspend the target thread.
 
int HAL_is_suspended (TaskHandle_t handle)
 Return 0 if thread is suspended.
 
void HAL_resume_thread (TaskHandle_t handle)
 Resume a suspended thread.
 
uint32_t HAL_get_task_high_water_mark_byte (TaskHandle_t handle)
 Return a task stack high water mark in bytes.
 
void HAL_get_debug_thread_text (char *textBuff)
 Given a buffer, return a buffer debug text.
 
void HAL_shutdown ()
 Shutdown the thread HAL.
 

Variables

volatile bool canRun = true
 
std::hash< std::thread::id > threadHasher
 

Detailed Description

Define tasks and threads specifics.

Function Documentation

◆ HAL_create_thread()

uint32_t lampda::hal::threads::HAL_create_thread ( TaskHandle_t *const  handle,
taskfunc_t  task,
char const *const  name,
const int  priority,
const int  stackSize,
const int  startSuspended 
)

Create a thread from the given function and return the associated handle.

[in] handle Handle that will be allocated by the thread

Parameters
[in]taskTask function to execute. it will be called in a loop
[in]nameinternal name of the thread
[in]priorityfrom to 2, this thread priority
[in]stackSizeThe size of the stack to allocate.
[in]startSuspendedif == 0, start the thread in a suspended mode
Returns
The task allocated stack in bytes, or 0 for failure

◆ HAL_wait_notification()

int lampda::hal::threads::HAL_wait_notification ( const int  timeout_ms)

Put this thread in suspended mode, waiting for a notification. This function wil block execution until the timeout is reached or a value is received.

Parameters
[in]timeout_msTimeout delay. Can be zero of less for no timeout
Returns
the value that woke up this thread