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

Define tasks and threads specifics. More...

Typedefs

typedef void(* taskfunc_t) (void)
 model of a task function
 

Functions

static void _redirect_task (void *arg)
 
static void _redirect_suspend_task (void *arg)
 
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.
 
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.
 
void yield_this_thread ()
 make this thread pass the control to other threads
 
void suspend_this_thread ()
 threads can only suspend itself
 
void suspend_all_threads ()
 Suspend all threads.
 
int is_all_suspended ()
 check that all threads are suspended (mandatory for sleep mode)
 
void resume_thread (const char *const taskName)
 resume a target thread
 
void notify_thread (const char *const taskName, int wakeUpEvent)
 notify a thread to resume
 
int wait_notification (const int timeout_ms)
 block this thread until a timeout or notification is received
 
void get_thread_debug (char *textBuff)
 

Variables

std::map< const char *const, TaskHandle_t > handles
 
const char *const pd_taskName = "usbpd"
 name of the USB power delivery task
 
const char *const pdInterruptHandle_taskName = "intpd"
 name of the USB power delivery interrupt handle task
 
const char *const power_taskName = "power"
 name of the main power task
 
const char *const user_taskName = "user"
 name of the optional user task
 
const char *const taskScheduler_taskName = "task_sched"
 name of the task scheduling task
 

Detailed Description

Define tasks and threads specifics.

Function Documentation

◆ is_all_suspended()

int lampda::platform::threads::is_all_suspended ( )

check that all threads are suspended (mandatory for sleep mode)

Returns
1 for success, 0 for failure

◆ notify_thread()

void lampda::platform::threads::notify_thread ( const char *const  taskName,
int  wakeUpEvent 
)

notify a thread to resume

Parameters
[in]taskNametarget task name
[in]wakeUpEventtype of the event to send

◆ resume_thread()

void lampda::platform::threads::resume_thread ( const char *const  taskName)

resume a target thread

Parameters
[in]taskNametarget task name

◆ start_suspended_thread()

void lampda::platform::threads::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.

Parameters
taskFunctionthe function to run
[in]taskNameThe name associated
[in]priorityfrom to 2, this thread priority
[in]stackSizeThe size of the stack to allocate. can be ignored and checked while running using the command line

◆ start_thread()

void lampda::platform::threads::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.

Parameters
taskFunctionthe function to run
[in]taskNameThe name associated
[in]priorityfrom to 2, this thread priority
[in]stackSizeThe size of the stack to allocate. can be ignored and checked while running using the command line

◆ suspend_all_threads()

void lampda::platform::threads::suspend_all_threads ( )

Suspend all threads.

Warning
: Can deadlock the system if called from a subthread.

◆ wait_notification()

int lampda::platform::threads::wait_notification ( const int  timeout_ms)

block this thread until a timeout or notification is received

Parameters
[in]timeout_msTimeout delay. Can be zero of less for no timeout
Returns
the wake up flag