5.11.0.0R3
Software Development Kit
 
Loading...
Searching...
No Matches
RTOS Interface

Functions

wwd_result_t host_rtos_create_configed_thread (host_thread_type_t *thread, void(*entry_function)(uint32_t), const char *name, void *stack, uint32_t stack_size, uint32_t priority, host_rtos_thread_config_type_t *config)
 
wwd_result_t host_rtos_create_thread (host_thread_type_t *thread, void(*entry_function)(wwd_thread_arg_t arg), const char *name, void *stack, uint32_t stack_size, uint32_t priority)
 
wwd_result_t host_rtos_create_thread_with_arg (host_thread_type_t *thread, void(*entry_function)(wwd_thread_arg_t arg), const char *name, void *stack, uint32_t stack_size, uint32_t priority, wwd_thread_arg_t arg)
 
wwd_result_t host_rtos_deinit_semaphore (host_semaphore_type_t *semaphore)
 
wwd_result_t host_rtos_delay_milliseconds (uint32_t num_ms)
 
wwd_result_t host_rtos_delete_terminated_thread (host_thread_type_t *thread)
 
wwd_result_t host_rtos_finish_thread (host_thread_type_t *thread)
 
wwd_result_t host_rtos_get_semaphore (host_semaphore_type_t *semaphore, uint32_t timeout_ms, wiced_bool_t will_set_in_isr)
 
wwd_time_t host_rtos_get_time (void)
 
wwd_result_t host_rtos_init_semaphore (host_semaphore_type_t *semaphore)
 
wwd_result_t host_rtos_join_thread (host_thread_type_t *thread)
 
wwd_result_t host_rtos_register_timer_ifc (const host_rtos_timer_ifc_t *host_rtos_timer_ifc)
 
wwd_result_t host_rtos_set_semaphore (host_semaphore_type_t *semaphore, wiced_bool_t called_from_ISR)
 
wwd_result_t host_rtos_unregister_timer_ifc (const host_rtos_timer_ifc_t *host_rtos_timer_ifc)
 

Detailed Description

Allows WICED to use use RTOS resources such as threads, semaphores & timing functions in an abstract way.

Allows WICED to use use RTOS resources such as threads, semaphores & timing functions in an abstract way.

Function Documentation

◆ host_rtos_create_configed_thread()

wwd_result_t host_rtos_create_configed_thread ( host_thread_type_t * thread,
void(* entry_function )(uint32_t),
const char * name,
void * stack,
uint32_t stack_size,
uint32_t priority,
host_rtos_thread_config_type_t * config )
extern

Note: different RTOS have different parameters for creating threads. Use this function carefully if portability is important. Create a thread with RTOS specific thread argument (E.g. specify time-slicing behavior)

Implemented in the WICED RTOS interface which is specific to the RTOS in use.

Parameters
thread: pointer to a variable which will receive the new thread handle
entry_function: function pointer which points to the main function for the new thread
name: a string thread name used for a debugger
stack_size: the size of the thread stack in bytes
priority: the priority of the thread
arg: the argument to pass to the new thread
config: os specific thread configuration
Returns
WWD result code

Creates a new thread

Parameters
thread: pointer to variable which will receive handle of created thread
entry_function: main thread function
name: a string thread name used for a debugger
config: os specific thread creation params
Returns
WWD_SUCCESS on success, WICED_ERROR otherwise

Note: different RTOS have different parameters for creating threads. Use this function carefully if portability is important. Create a thread with RTOS specific thread argument (E.g. specify time-slicing behavior)

Implemented in the WICED RTOS interface which is specific to the RTOS in use.

Parameters
thread: pointer to a variable which will receive the new thread handle
entry_function: function pointer which points to the main function for the new thread
name: a string thread name used for a debugger
stack_size: the size of the thread stack in bytes
priority: the priority of the thread
arg: the argument to pass to the new thread
config: os specific thread configuration
Returns
WWD result code

◆ host_rtos_create_thread()

wwd_result_t host_rtos_create_thread ( host_thread_type_t * thread,
void(* entry_function )(wwd_thread_arg_t arg),
const char * name,
void * stack,
uint32_t stack_size,
uint32_t priority )
extern

Create a thread

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to create a new thread and start it running.

Parameters
thread: pointer to a variable which will receive the new thread handle
entry_function: function pointer which points to the main function for the new thread
name: a string thread name used for a debugger
stack_size: the size of the thread stack in bytes
priority: the priority of the thread
Returns
WWD_SUCCESS or Error code

Creates a new thread

Parameters
thread: pointer to variable which will receive handle of created thread
entry_function: main thread function
name: a string thread name used for a debugger
Returns
WWD_SUCCESS on success, WICED_ERROR otherwise

Create a thread

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to create a new thread and start it running.

Parameters
thread: pointer to a variable which will receive the new thread handle
entry_function: function pointer which points to the main function for the new thread
name: a string thread name used for a debugger
stack_size: the size of the thread stack in bytes
priority: the priority of the thread
Returns
WWD_SUCCESS or Error code

◆ host_rtos_create_thread_with_arg()

wwd_result_t host_rtos_create_thread_with_arg ( host_thread_type_t * thread,
void(* entry_function )(wwd_thread_arg_t arg),
const char * name,
void * stack,
uint32_t stack_size,
uint32_t priority,
wwd_thread_arg_t arg )
extern

Create a thread with specific thread argument

Implemented in the WICED RTOS interface which is specific to the RTOS in use.

Parameters
thread: pointer to a variable which will receive the new thread handle
entry_function: function pointer which points to the main function for the new thread
name: a string thread name used for a debugger
stack_size: the size of the thread stack in bytes
priority: the priority of the thread
arg: the argument to pass to the new thread
Returns
WWD result code

◆ host_rtos_deinit_semaphore()

wwd_result_t host_rtos_deinit_semaphore ( host_semaphore_type_t * semaphore)
extern

Deletes a semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to delete a semaphore.

Parameters
semaphore: Pointer to the semaphore handle
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully deleted : Error code if an error occurred

Deletes a semaphore

WICED uses this function to delete a semaphore.

Parameters
semaphore: Pointer to the semaphore handle
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully deleted : WICED_ERROR if an error occurred

Deletes a semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to delete a semaphore.

Parameters
semaphore: Pointer to the semaphore handle
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully deleted : Error code if an error occurred

◆ host_rtos_delay_milliseconds()

wwd_result_t host_rtos_delay_milliseconds ( uint32_t num_ms)
extern

Delay for a number of milliseconds

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to delay processing Processing of this function depends on the minimum sleep time resolution of the RTOS. The current thread should sleep for the longest period possible which is less than the delay required, then makes up the difference with a tight loop

Returns
wwd_result_t : WWD_SUCCESS if delay was successful : Error code if an error occurred

Delay for a number of milliseconds

Processing of this function depends on the minimum sleep time resolution of the RTOS. The current thread sleeps for the longest period possible which is less than the delay required, then makes up the difference with a tight loop

Returns
wwd_result_t : WWD_SUCCESS if delay was successful : WICED_ERROR if an error occurred

Delay for a number of milliseconds

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to delay processing Processing of this function depends on the minimum sleep time resolution of the RTOS. The current thread should sleep for the longest period possible which is less than the delay required, then makes up the difference with a tight loop

Returns
wwd_result_t : WWD_SUCCESS if delay was successful : Error code if an error occurred

◆ host_rtos_delete_terminated_thread()

wwd_result_t host_rtos_delete_terminated_thread ( host_thread_type_t * thread)
extern

Deletes a terminated thread

Implemented in the WICED RTOS interface which is specific to the RTOS in use. Some RTOS implementations require that another thread deletes any terminated thread If RTOS does not require this, leave empty

Parameters
thread: handle of the terminated thread to delete
Returns
WWD_SUCCESS on success, Error code otherwise

Deletes a terminated thread

ThreadX requires that another thread deletes any terminated threads

Parameters
thread: handle of the terminated thread to delete
Returns
WWD_SUCCESS on success, WICED_ERROR otherwise

Deletes a terminated thread

Implemented in the WICED RTOS interface which is specific to the RTOS in use. Some RTOS implementations require that another thread deletes any terminated thread If RTOS does not require this, leave empty

Parameters
thread: handle of the terminated thread to delete
Returns
WWD_SUCCESS on success, Error code otherwise

◆ host_rtos_finish_thread()

wwd_result_t host_rtos_finish_thread ( host_thread_type_t * thread)
extern

Exit a thread

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to exit the current thread just before its main function would otherwise return. Some RTOSs allow threads to exit by simply returning from their main function. If this is the case, then the implementation of this function should be empty.

Parameters
thread: Pointer to the current thread handle
Returns
WWD_SUCCESS or Error code

Terminates the current thread

This does nothing since ThreadX threads can exit by just returning

Parameters
thread: handle of the thread to terminate
Returns
WWD_SUCCESS on success, WICED_ERROR otherwise

Exit a thread

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to exit the current thread just before its main function would otherwise return. Some RTOSs allow threads to exit by simply returning from their main function. If this is the case, then the implementation of this function should be empty.

Parameters
thread: Pointer to the current thread handle
Returns
WWD_SUCCESS or Error code

◆ host_rtos_get_semaphore()

wwd_result_t host_rtos_get_semaphore ( host_semaphore_type_t * semaphore,
uint32_t timeout_ms,
wiced_bool_t will_set_in_isr )
extern

Get a semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to get a semaphore.

  • If the semaphore value is greater than zero, the sempahore value is decremented and the function returns immediately.
  • If the semaphore value is zero, the current thread is put on a queue of threads waiting on the semaphore, and sleeps until another thread sets the semaphore and causes it to wake. Upon waking, the semaphore is decremented and the function returns.
Note
: This function must not be called from an interrupt context as it may block.
Parameters
semaphore: Pointer to the semaphore handle
timeout_ms: Maximum number of milliseconds to wait while attempting to get the semaphore. Use the NEVER_TIMEOUT constant to wait forever.
will_set_in_isr: True if the semaphore will be set in an ISR. Currently only used for NoOS/NoNS
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully acquired : WICED_TIMEOUT if semaphore was not acquired before timeout_ms period

Gets a semaphore

If value of semaphore is larger than zero, then the semaphore is decremented and function returns Else If value of semaphore is zero, then current thread is suspended until semaphore is set. Value of semaphore should never be below zero

Must not be called from interrupt context, since it could block, and since an interrupt is not a normal thread, so could cause RTOS problems if it tries to suspend it.

Parameters
semaphore: Pointer to variable which will receive handle of created semaphore
timeout_ms: Maximum period to block for. Can be passed NEVER_TIMEOUT to request no timeout
will_set_in_isr: True if the semaphore will be set in an ISR. Currently only used for NoOS/NoNS

Get a semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to get a semaphore.

  • If the semaphore value is greater than zero, the sempahore value is decremented and the function returns immediately.
  • If the semaphore value is zero, the current thread is put on a queue of threads waiting on the semaphore, and sleeps until another thread sets the semaphore and causes it to wake. Upon waking, the semaphore is decremented and the function returns.
Note
: This function must not be called from an interrupt context as it may block.
Parameters
semaphore: Pointer to the semaphore handle
timeout_ms: Maximum number of milliseconds to wait while attempting to get the semaphore. Use the NEVER_TIMEOUT constant to wait forever.
will_set_in_isr: True if the semaphore will be set in an ISR. Currently only used for NoOS/NoNS
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully acquired : WICED_TIMEOUT if semaphore was not acquired before timeout_ms period

◆ host_rtos_get_time()

wwd_time_t host_rtos_get_time ( void )
extern

Gets time in milliseconds since RTOS start

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to retrieve the current time.

Note
: Since this is only 32 bits, it will roll over every 49 days, 17 hours, 2 mins, 47.296 seconds
Returns
Time in milliseconds since the RTOS started.

Gets time in milliseconds since RTOS start

@Note: since this is only 32 bits, it will roll over every 49 days, 17 hours.

Returns
Time in milliseconds since RTOS started.

Gets time in milliseconds since RTOS start

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to retrieve the current time.

Note
: Since this is only 32 bits, it will roll over every 49 days, 17 hours, 2 mins, 47.296 seconds
Returns
Time in milliseconds since the RTOS started.

◆ host_rtos_init_semaphore()

wwd_result_t host_rtos_init_semaphore ( host_semaphore_type_t * semaphore)
extern

Create a Semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to create a semaphore

Parameters
semaphore: Pointer to the semaphore handle to be initialized
Returns
WWD_SUCCESS or Error code

Creates a semaphore

Parameters
semaphore: pointer to variable which will receive handle of created semaphore
Returns
WWD_SUCCESS on success, WICED_ERROR otherwise

Create a Semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to create a semaphore

Parameters
semaphore: Pointer to the semaphore handle to be initialized
Returns
WWD_SUCCESS or Error code

◆ host_rtos_join_thread()

wwd_result_t host_rtos_join_thread ( host_thread_type_t * thread)
extern

Waits for a thread to complete

Implemented in the WICED RTOS interface which is specific to the RTOS in use.

Parameters
thread: handle of the thread to wait for
Returns
WWD_SUCCESS on success, Error code otherwise

Blocks the current thread until the indicated thread is complete

Parameters
thread: handle of the thread to terminate
Returns
WWD_SUCCESS on success, WICED_ERROR otherwise

Waits for a thread to complete

Implemented in the WICED RTOS interface which is specific to the RTOS in use.

Parameters
thread: handle of the thread to wait for
Returns
WWD_SUCCESS on success, Error code otherwise

◆ host_rtos_register_timer_ifc()

wwd_result_t host_rtos_register_timer_ifc ( const host_rtos_timer_ifc_t * host_rtos_timer_ifc)
extern

Register a timer interface for WWD to use.

Returns
wwd_result_t : WWD_SUCCESS if successful : Error code if an error occurred

◆ host_rtos_set_semaphore()

wwd_result_t host_rtos_set_semaphore ( host_semaphore_type_t * semaphore,
wiced_bool_t called_from_ISR )
extern

Set a semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to set a semaphore. The value of the semaphore is incremented, and if there are any threads waiting on the semaphore, then the first waiting thread is woken.

Some RTOS implementations require different processing when setting a semaphore from within an ISR. A parameter is provided to allow this.

Parameters
semaphore: Pointer to the semaphore handle
called_from_ISR: Value of WICED_TRUE indicates calling from interrupt context Value of WICED_FALSE indicates calling from normal thread context
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully set : Error code if an error occurred

Sets a semaphore

If any threads are waiting on the semaphore, the first thread is resumed Else increment semaphore.

Can be called from interrupt context, so must be able to handle resuming other threads from interrupt context.

Parameters
semaphore: Pointer to variable which will receive handle of created semaphore
called_from_ISR: Value of WICED_TRUE indicates calling from interrupt context Value of WICED_FALSE indicates calling from normal thread context
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully set : WICED_ERROR if an error occurred

Set a semaphore

Implemented in the WICED RTOS interface which is specific to the RTOS in use. WICED uses this function to set a semaphore. The value of the semaphore is incremented, and if there are any threads waiting on the semaphore, then the first waiting thread is woken.

Some RTOS implementations require different processing when setting a semaphore from within an ISR. A parameter is provided to allow this.

Parameters
semaphore: Pointer to the semaphore handle
called_from_ISR: Value of WICED_TRUE indicates calling from interrupt context Value of WICED_FALSE indicates calling from normal thread context
Returns
wwd_result_t : WWD_SUCCESS if semaphore was successfully set : Error code if an error occurred

◆ host_rtos_unregister_timer_ifc()

wwd_result_t host_rtos_unregister_timer_ifc ( const host_rtos_timer_ifc_t * host_rtos_timer_ifc)
extern

Unregister a timer interface WWD was using.

Returns
wwd_result_t : WWD_SUCCESS if successful : Error code if an error occurred