Infineon Logo AIROC BTSDK v4.6 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Worker Thread

Defines a group of APIs which enable the use of worker threads. More...

Functions

wiced_worker_thread_t * wiced_rtos_create_worker_thread (void)
 Allocates memory for a new worker thread instance and returns the pointer. More...
 
wiced_result_t wiced_rtos_init_worker_thread (wiced_worker_thread_t *worker_thread, uint8_t priority, uint32_t stack_size, uint32_t event_queue_size)
 Initializes the worker thread instance that was allocated in wiced_rtos_create_worker_thread. More...
 
wiced_result_t wiced_rtos_send_asynchronous_event (wiced_worker_thread_t *worker_thread, event_handler_t function, void *arg)
 Enqueue an asynchronous event to be triggered in the given worker thread. More...
 

Detailed Description

Defines a group of APIs which enable the use of worker threads.

Each thread can be created with its own stack size, priority, and task queue size. In the work thread, the only way to execute code is to enqueue a new task and have it execute a callback.

Note
The worker thread APIs will not function until wiced_bt_stack_init is called so that the proper buffer space is allocated at runtime.

Function Documentation

wiced_worker_thread_t* wiced_rtos_create_worker_thread ( void  )

Allocates memory for a new worker thread instance and returns the pointer.

The created instance must be initialized using wiced_rtos_init_worker_thread before use.

Parameters
void
Returns
  • NULL an error occurred and the instance was not allocated, do not init
  • valid pointer to worker thread instance, which can now we initialized
wiced_result_t wiced_rtos_init_worker_thread ( wiced_worker_thread_t *  worker_thread,
uint8_t  priority,
uint32_t  stack_size,
uint32_t  event_queue_size 
)

Initializes the worker thread instance that was allocated in wiced_rtos_create_worker_thread.

The worker thread creates a regular RTOS thread with the given stack size and priority, as well as an RTOS queue. The created thread blocks indefinitely until a task in enqueued. The task is dequeued and executed in the worker thread context, then the thread loops back around to wait for the next task.

Parameters
[in]worker_threadworker thread instance to init
[in]prioritythread priority
[in]stack_sizethread's stack size in number of bytes
[in]event_queue_sizenumber of events the task queue can hold
Returns
  • WICED_SUCCESS
  • WICED_ERROR
Note
The number of buffers in wiced_bt_cfg_settings_t::max_number_of_buffer_pools must be increased for each worker thread the application will utilize.
wiced_result_t wiced_rtos_send_asynchronous_event ( wiced_worker_thread_t *  worker_thread,
event_handler_t  function,
void *  arg 
)

Enqueue an asynchronous event to be triggered in the given worker thread.

Parameters
[in]worker_threadworker thread instance to which the event is sent
[in]functioncallback function executed in worker thread
[in]argargument passed to the callback function
Returns
  • WICED_SUCCESS
  • WICED_ERROR
Note
Be sure to only pass a pointer to 'arg' which points to a global or static variable. The pointer will be referenced in a different context after the current function returns and will not be able to access local variables.