RTOS
Ameba SDK

RTOS functions. More...

## Data Structures

struct | timer_list
struct | task_struct
struct | rtw_worker_thread_t
struct | rtw_event_message_t
struct | worker_timer_entry
struct | osdep_service_ops

## Macros

#define | CONFIG_LITTLE_ENDIAN
#define | CONFIG_PLATFORM_AMEBA_X
#define | CONFIG_USE_TCM_HEAP 1 /* USE TCM HEAP */
#define | USE_MUTEX_FOR_SPINLOCK 1
#define | CONFIG_MEM_MONITOR MEM_MONITOR_SIMPLE
#define | RTW_MAX_DELAY 0xFFFFFFFF
#define | RTW_WAIT_FOREVER 0xFFFFFFFF
#define | OS_SCHEDULER_NOT_STARTED 0
| Definitions returned by xTaskGetSchedulerState().
#define | OS_SCHEDULER_RUNNING 1
#define | OS_SCHEDULER_SUSPENDED 2
#define | CONFIG_THREAD_COMM_SEMA
#define | MEM_MONITOR_SIMPLE 0x1
#define | MEM_MONITOR_LEAK 0x2
#define | MEM_MONITOR_FLAG_WIFI_DRV 0x1
#define | MEM_MONITOR_FLAG_WPAS 0x2
#define | rtw_free(buf) rtw_mfree((u8 *)buf, 0)
#define | rtw_warn_on(condition) do {} while (0)
#define | LIST_CONTAINOR(ptr, type, member) ((type *)((char *)(ptr)-(SIZE_T)((char *)&((type *)ptr)->member - (char *)ptr)))
#define | time_after(a, b) ((long)(b) - (long)(a) < 0)
#define | time_before(a, b) time_after(b,a)
#define | time_after_eq(a, b) ((long)(a) - (long)(b) >= 0)
#define | time_before_eq(a, b) time_after_eq(b,a)
#define | _RND(sz, r) ((((sz)+((r)-1))/(r))*(r))
#define | RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2)
#define | RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
#define | RTW_PUT_BE16(a, val)
#define | RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
#define | RTW_PUT_LE16(a, val)
#define | RTW_GET_BE24(a)
#define | RTW_PUT_BE24(a, val)
#define | RTW_GET_BE32(a)
#define | RTW_PUT_BE32(a, val)
#define | RTW_GET_LE32(a)
#define | RTW_PUT_LE32(a, val)
#define | RTW_GET_BE64(a)
#define | RTW_PUT_BE64(a, val)
#define | RTW_GET_LE64(a)

## Typedefs

typedef thread_return(* | thread_func_t) (thread_context context)
typedef void(* | TIMER_FUN) (void *context)
typedef int(* | event_handler_t) (char *buf, int buf_len, int flags, void *user_data)

## Functions

void | init_mem_monitor (_list *pmem_table, int *used_num)
| This function initializes a memory table. More...
void | deinit_mem_monitor (_list *pmem_table, int *used_num)
| This function deinitializes a memory table. More...
void | add_mem_usage (_list *pmem_table, void *ptr, int size, int *used_num, int flag)
| This function alloc mem_entry to the memory table. More...
void | del_mem_usage (_list *pmem_table, void *ptr, int *used_num, int flag)
| This function frees memory from the memory table. More...
int | get_mem_usage (_list *pmem_table)
| This function get the memory usage of a memory table. More...
u8 * | _rtw_vmalloc (u32 sz)
u8 * | _rtw_zvmalloc (u32 sz)
void | _rtw_vmfree (u8 *pbuf, u32 sz)
u8 * | _rtw_zmalloc (u32 sz)
u8 * | _rtw_malloc (u32 sz)
void | _rtw_mfree (u8 *pbuf, u32 sz)
u8 * | rtw_vmalloc (u32 sz)
| This function allocates the virtually contiguous memory. More...
u8 * | rtw_zvmalloc (u32 sz)
| This function allocates the virtually contiguous memory and the values of the memory are setted to 0. More...
void | rtw_vmfree (u8 *pbuf, u32 sz)
| This function frees the virtually contiguous memory. More...
u8 * | rtw_zmalloc (u32 sz)
| This function allocates the memory and the values of the memory are setted to 0. More...
u8 * | rtw_malloc (u32 sz)
| This function allocates the memory. More...
void | rtw_mfree (u8 *pbuf, u32 sz)
| This function frees the virtually contiguous memory. More...
void * | rtw_malloc2d (int h, int w, int size)
| This function allocates a 2 dimensional array memory. More...
void | rtw_mfree2d (void *pbuf, int h, int w, int size)
| This function deallocates the block of memory previously allocated to make it available again. More...
void | rtw_memcpy (void *dst, void *src, u32 sz)
| This function copies the values of "sz" bytes from the location pointed to by "src" directly to the memory block pointed to by "des". More...
int | rtw_memcmp (void *dst, void *src, u32 sz)
| This function compares the first "sz" bytes of the block of memory pointed by "dst" to the first "sz" bytes pointed by "src". More...
void | rtw_memset (void *pbuf, int c, u32 sz)
| This function sets the first "sz" bytes of the block of memory pointed by "pbuf" to the specified "c". More...
void | rtw_init_listhead (_list *list)
| This function initializes the head of the list. More...
u32 | rtw_is_list_empty (_list *phead)
| This function tests whether a list is empty. More...
void | rtw_list_insert_head (_list *plist, _list *phead)
| This function adds a new entry after "phead" for the list. More...
void | rtw_list_insert_tail (_list *plist, _list *phead)
| This function adds a new entry before "phead" for the list. More...
void | rtw_list_delete (_list *plist)
| This function deletes entry from list and reinitialize it. More...
void | rtw_init_sema (_sema *sema, int init_val)
| This function initializes the unnamed semaphore referred to by "sema" to the value "init_val". More...
void | rtw_free_sema (_sema *sema)
| This function deletes the semaphore. More...
void | rtw_up_sema (_sema *sema)
| This function releases the semaphore. This macro must not be used from an ISR. More...
void | rtw_up_sema_from_isr (_sema *sema)
| This function releases the semaphore. This macro can be used from an ISR. More...
u32 | rtw_down_sema (_sema *sema)
| This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up. More...
u32 | rtw_down_timeout_sema (_sema *sema, u32 timeout)
| This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up. More...
void | rtw_mutex_init (_mutex *pmutex)
| This function implements a mutex semaphore by using the existing queue mechanism. More...
void | rtw_mutex_free (_mutex *pmutex)
| This function deletes the mutex semaphore. More...
void | rtw_mutex_put (_mutex *pmutex)
| This function releases a mutex semaphore. More...
void | rtw_mutex_get (_mutex *pmutex)
| This function obtains a mutex semaphore. More...
int | rtw_mutex_get_timeout (_mutex *pmutex, u32 timeout_ms)
| This function obtains a mutex semaphore with a timeout setting. More...
void | rtw_enter_critical (_lock *plock, _irqL *pirqL)
| This function marks the start of a critical code region. Preemptive context switches cannot occur when in a critical region. More...
void | rtw_exit_critical (_lock *plock, _irqL *pirqL)
| This function marks end of a critical code region. Preemptive context switches cannot occur when in a critical region. More...
void | rtw_enter_critical_from_isr (_lock *plock, _irqL *pirqL)
| This function marks the start of a critical code region from isr. More...
void | rtw_exit_critical_from_isr (_lock *plock, _irqL *pirqL)
| This function marks the end of a critical code region from isr. More...
void | rtw_enter_critical_bh (_lock *plock, _irqL *pirqL)
| This function obtains a spin lock semaphore. More...
void | rtw_exit_critical_bh (_lock *plock, _irqL *pirqL)
| This function releases a spin lock semaphore. More...
int | rtw_enter_critical_mutex (_mutex *pmutex, _irqL *pirqL)
| This function obtains a semaphore. More...
void | rtw_exit_critical_mutex (_mutex *pmutex, _irqL *pirqL)
| This function releases a semaphore. More...
void | rtw_spinlock_init (_lock *plock)
| This function implements a spin lock semaphore by using the existing queue mechanism. More...
void | rtw_spinlock_free (_lock *plock)
| This function deletes the spin lock semaphore. More...
void | rtw_spin_lock (_lock *plock)
| This function obtains a spin lock semaphore. More...
void | rtw_spin_unlock (_lock *plock)
| This function releases a spin lock semaphore. More...
void | rtw_spinlock_irqsave (_lock *plock, _irqL *irqL)
| This function marks the start of a critical code region and obtains a spin lock semaphore. More...
void | rtw_spinunlock_irqsave (_lock *plock, _irqL *irqL)
| This function releases a spin lock semaphore and marks the end of a critical code region. More...
int | rtw_init_xqueue (_xqueue *queue, const char *name, u32 message_size, u32 number_of_messages)
| This function creates a new queue instance. More...
int | rtw_push_to_xqueue (_xqueue *queue, void *message, u32 timeout_ms)
| This function posts a message to the back of a queue. The message is queued by copy, not by reference. More...
int | rtw_pop_from_xqueue (_xqueue *queue, void *message, u32 timeout_ms)
| This function receives a message from a queue. The message is recieved by copy so a buffer adequate size must be provided. More...
int | rtw_deinit_xqueue (_xqueue *queue)
| Delete a queue - freeing all the memory allocated for storing of messages placed on the queue. More...
void | rtw_init_queue (_queue *pqueue)
| This function creates a new queue instance. More...
void | rtw_deinit_queue (_queue *pqueue)
u32 | rtw_is_queue_empty (_queue *pqueue)
u32 | rtw_queue_empty (_queue *pqueue)
| This function tests whether the queue is empty. More...
u32 | rtw_end_of_queue_search (_list *queue, _list *pelement)
| This function tests whether the "pelement" is at the "queue". More...
_list * | rtw_get_queue_head (_queue *queue)
u32 | rtw_get_current_time (void)
| Get the count of ticks since the vTaskStartScheduler was called. More...
u32 | rtw_systime_to_ms (u32 systime)
| Convert system time to milliseconds. More...
u32 | rtw_systime_to_sec (u32 systime)
| Convert system time to seconds. More...
u32 | rtw_ms_to_systime (u32 ms)
| Convert milliseconds to system time. More...
u32 | rtw_sec_to_systime (u32 sec)
| Convert seconds to system time. More...
s32 | rtw_get_passing_time_ms (u32 start)
| Get the passing time from the "start" in milliseconds. More...
s32 | rtw_get_time_interval_ms (u32 start, u32 end)
| Get the interval time from the "start" to "end" in milliseconds. More...
void | rtw_msleep_os (int ms)
| This function suspends execution of the calling thread for "ms" milliseconds. More...
void | rtw_usleep_os (int us)
| This function suspends execution of the calling thread for "us" microseconds. More...
u32 | rtw_atoi (u8 *s)
| This function converts the initial portion of the string to integer. More...
void | rtw_mdelay_os (int ms)
| This function delays a task for the giving time in milliseconds. More...
void | rtw_udelay_os (int us)
| This function delays a task for the giving time in microseconds. More...
void | rtw_yield_os (void)
| This function for forcing a context switch. More...
void | ATOMIC_SET (ATOMIC_T *v, int i)
| This function atomically sets the value of the variable. More...
int | ATOMIC_READ (ATOMIC_T *v)
| This function atomically reads the value of the variable. More...
void | ATOMIC_ADD (ATOMIC_T *v, int i)
| This function adds "i" to the contained "v". More...
void | ATOMIC_SUB (ATOMIC_T *v, int i)
| This function subtracts "i" from th econtained "v". More...
void | ATOMIC_INC (ATOMIC_T *v)
| This function adds 1 to the contained "v". More...
void | ATOMIC_DEC (ATOMIC_T *v)
| This function subtracts 1 from th econtained "v". More...
int | ATOMIC_ADD_RETURN (ATOMIC_T *v, int i)
| This function adds "i" to the contained "v" and returns the result. More...
int | ATOMIC_SUB_RETURN (ATOMIC_T *v, int i)
| This function subtracts "i" from th econtained "v" and returns the result. More...
int | ATOMIC_INC_RETURN (ATOMIC_T *v)
| This function adds 1 to the contained "v" and returns the result. More...
int | ATOMIC_DEC_RETURN (ATOMIC_T *v)
| This function subtracts 1 from th econtained "v" and returns the result. More...
int | ATOMIC_DEC_AND_TEST (ATOMIC_T *v)
| This function subtracts 1 from th econtained "v" and test if the result equals 0. More...
u64 | rtw_modular64 (u64 x, u64 y)
int | rtw_get_random_bytes (void *dst, u32 size)
| This function generates random bytes. More...
u32 | rtw_getFreeHeapSize (void)
| This function gets the available heap size. More...
void | flush_signals_thread (void)
void | rtw_acquire_wakelock (void)
| This function indicates that the WLAN needs to stay on which means cannot go into power saving mode. More...
void | rtw_release_wakelock (void)
| This function indicates that the WLAN does not need to stay on which means can go into power saving mode. More...
void | rtw_wakelock_timeout (u32 timeout)
int | rtw_create_task (struct task_struct *task, const char *name, u32 stack_size, u32 priority, thread_func_t func, void *thctx)
| This function creates a new task and adds it to the list of tasks that are ready to run. More...
void | rtw_delete_task (struct task_struct *task)
| This function deletes a task. More...
void | rtw_wakeup_task (struct task_struct *task)
| This function wake up a task. More...
int | rtw_create_worker_thread (rtw_worker_thread_t *worker_thread, u8 priority, u32 stack_size, u32 event_queue_size)
| This function creates a new worker thread. More...
int | rtw_delete_worker_thread (rtw_worker_thread_t *worker_thread)
| This function deletes a worker thread. More...
void | rtw_thread_enter (char *name)
| This function prints the name of the thread in DBG_INFO. More...
void | rtw_thread_exit (void)
| This function exits the calling thread. More...
u8 | rtw_get_scheduler_state (void)
| This function gets the scheduler state of the calling thread. More...
_timerHandle | rtw_timerCreate (const signed char *pcTimerName, osdepTickType xTimerPeriodInTicks, u32 uxAutoReload, void *pvTimerID, TIMER_FUN pxCallbackFunction)
| This function creates a new software timer instance. More...
u32 | rtw_timerDelete (_timerHandle xTimer, osdepTickType xBlockTime)
| This function deletes a timer that was previously created using rtw_timerCreate. More...
u32 | rtw_timerIsTimerActive (_timerHandle xTimer)
| This function queries a timer to see if it is active or dormant. More...
u32 | rtw_timerStop (_timerHandle xTimer, osdepTickType xBlockTime)
| This function stops a timer that was previously started. More...
u32 | rtw_timerChangePeriod (_timerHandle xTimer, osdepTickType xNewPeriod, osdepTickType xBlockTime)
| This function changes the period of a timer that was previously created. More...
void * | rtw_timerGetID (_timerHandle xTimer)
u32 | rtw_timerStart (_timerHandle xTimer, osdepTickType xBlockTime)
u32 | rtw_timerStartFromISR (_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32 | rtw_timerStopFromISR (_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32 | rtw_timerResetFromISR (_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32 | rtw_timerChangePeriodFromISR (_timerHandle xTimer, osdepTickType xNewPeriod, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32 | rtw_timerReset (_timerHandle xTimer, osdepTickType xBlockTime)

## Variables

_timerHandle | timer_hdl
unsigned long | data
void(* | function )(void *)
const char * | task_name
_thread_hdl_ | task
_sema | wakeup_sema
_sema | terminate_sema
u32 | blocked
u32 | callback_running
_xqueue | event_queue
struct task_struct | thread
event_handler_t | function
char * | buf
int | buf_len
int | flags
void * | user_data
struct list_head | list
_timerHandle | timer_hdl
rtw_event_message_t | message
rtw_worker_thread_t * | worker_thread
u32 | timeout
u8 *(* | rtw_vmalloc )(u32 sz)
u8 *(* | rtw_zvmalloc )(u32 sz)
void(* | rtw_vmfree )(u8 *pbuf, u32 sz)
u8 *(* | rtw_malloc )(u32 sz)
u8 *(* | rtw_zmalloc )(u32 sz)
void(* | rtw_mfree )(u8 *pbuf, u32 sz)
void(* | rtw_memcpy )(void *dst, void *src, u32 sz)
int(* | rtw_memcmp )(void *dst, void *src, u32 sz)
void(* | rtw_memset )(void *pbuf, int c, u32 sz)
void(* | rtw_init_sema )(_sema *sema, int init_val)
void(* | rtw_free_sema )(_sema *sema)
void(* | rtw_up_sema )(_sema *sema)
void(* | rtw_up_sema_from_isr )(_sema *sema)
u32(* | rtw_down_timeout_sema )(_sema *sema, u32 timeout)
void(* | rtw_mutex_init )(_mutex *pmutex)
void(* | rtw_mutex_free )(_mutex *pmutex)
void(* | rtw_mutex_get )(_mutex *pmutex)
int(* | rtw_mutex_get_timeout )(_mutex *pmutex, u32 timeout_ms)
void(* | rtw_mutex_put )(_mutex *pmutex)
void(* | rtw_enter_critical )(_lock *plock, _irqL *pirqL)
void(* | rtw_exit_critical )(_lock *plock, _irqL *pirqL)
void(* | rtw_enter_critical_from_isr )(_lock *plock, _irqL *pirqL)
void(* | rtw_exit_critical_from_isr )(_lock *plock, _irqL *pirqL)
void(* | rtw_enter_critical_bh )(_lock *plock, _irqL *pirqL)
void(* | rtw_exit_critical_bh )(_lock *plock, _irqL *pirqL)
int(* | rtw_enter_critical_mutex )(_mutex *pmutex, _irqL *pirqL)
void(* | rtw_exit_critical_mutex )(_mutex *pmutex, _irqL *pirqL)
void(* | rtw_spinlock_init )(_lock *plock)
void(* | rtw_spinlock_free )(_lock *plock)
void(* | rtw_spin_lock )(_lock *plock)
void(* | rtw_spin_unlock )(_lock *plock)
void(* | rtw_spinlock_irqsave )(_lock *plock, _irqL *irqL)
void(* | rtw_spinunlock_irqsave )(_lock *plock, _irqL *irqL)
int(* | rtw_init_xqueue )(_xqueue *queue, const char *name, u32 message_size, u32 number_of_messages)
int(* | rtw_push_to_xqueue )(_xqueue *queue, void *message, u32 timeout_ms)
int(* | rtw_pop_from_xqueue )(_xqueue *queue, void *message, u32 timeout_ms)
int(* | rtw_deinit_xqueue )(_xqueue *queue)
u32(* | rtw_get_current_time )(void)
u32(* | rtw_systime_to_ms )(u32 systime)
u32(* | rtw_systime_to_sec )(u32 systime)
u32(* | rtw_ms_to_systime )(u32 ms)
u32(* | rtw_sec_to_systime )(u32 sec)
void(* | rtw_msleep_os )(int ms)
void(* | rtw_usleep_os )(int us)
void(* | rtw_mdelay_os )(int ms)
void(* | rtw_udelay_os )(int us)
void(* | rtw_yield_os )(void)
void(* | ATOMIC_SET )(ATOMIC_T *v, int i)
int(* | ATOMIC_READ )(ATOMIC_T *v)
void(* | ATOMIC_ADD )(ATOMIC_T *v, int i)
void(* | ATOMIC_SUB )(ATOMIC_T *v, int i)
void(* | ATOMIC_INC )(ATOMIC_T *v)
void(* | ATOMIC_DEC )(ATOMIC_T *v)
int(* | ATOMIC_ADD_RETURN )(ATOMIC_T *v, int i)
int(* | ATOMIC_SUB_RETURN )(ATOMIC_T *v, int i)
int(* | ATOMIC_INC_RETURN )(ATOMIC_T *v)
int(* | ATOMIC_DEC_RETURN )(ATOMIC_T *v)
u64(* | rtw_modular64 )(u64 x, u64 y)
int(* | rtw_get_random_bytes )(void *dst, u32 size)
u32(* | rtw_getFreeHeapSize )(void)
int(* | rtw_create_task )(struct task_struct *task, const char *name, u32 stack_size, u32 priority, thread_func_t func, void *thctx)
void(* | rtw_delete_task )(struct task_struct *task)
void(* | rtw_wakeup_task )(struct task_struct *task)
void(* | rtw_thread_enter )(char *name)
void(* | rtw_thread_exit )(void)
_timerHandle(* | rtw_timerCreate )(const signed char *pcTimerName, osdepTickType xTimerPeriodInTicks, u32 uxAutoReload, void *pvTimerID, TIMER_FUN pxCallbackFunction)
u32(* | rtw_timerDelete )(_timerHandle xTimer, osdepTickType xBlockTime)
u32(* | rtw_timerIsTimerActive )(_timerHandle xTimer)
u32(* | rtw_timerStop )(_timerHandle xTimer, osdepTickType xBlockTime)
u32(* | rtw_timerChangePeriod )(_timerHandle xTimer, osdepTickType xNewPeriod, osdepTickType xBlockTime)
void *(* | rtw_timerGetID )(_timerHandle xTimer)
u32(* | rtw_timerStart )(_timerHandle xTimer, osdepTickType xBlockTime)
u32(* | rtw_timerStartFromISR )(_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32(* | rtw_timerStopFromISR )(_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32(* | rtw_timerResetFromISR )(_timerHandle xTimer, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32(* | rtw_timerChangePeriodFromISR )(_timerHandle xTimer, osdepTickType xNewPeriod, osdepBASE_TYPE *pxHigherPriorityTaskWoken)
u32(* | rtw_timerReset )(_timerHandle xTimer, osdepTickType xBlockTime)
void(* | rtw_acquire_wakelock )(void)
void(* | rtw_release_wakelock )(void)
void(* | rtw_wakelock_timeout )(u32 timeoutMs)
u8(* | rtw_get_scheduler_state )(void)

## Detailed Description

RTOS functions.

## Macro Definition Documentation

#define RTW_GET_BE24 | ( |  | a | ) |

Value:
((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
((u32) (a)[2]))

#define RTW_GET_BE32 | ( |  | a | ) |

Value:
((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
(((u32) (a)[2]) << 8) | ((u32) (a)[3]))

#define RTW_GET_BE64 | ( |  | a | ) |

Value:
((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
(((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
(((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
(((u64) (a)[6]) << 8) | ((u64) (a)[7]))

#define RTW_GET_LE32 | ( |  | a | ) |

Value:
((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
(((u32) (a)[1]) << 8) | ((u32) (a)[0]))

#define RTW_GET_LE64 | ( |  | a | ) |

Value:
((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
(((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
(((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
(((u64) (a)[1]) << 8) | ((u64) (a)[0]))

#define RTW_PUT_BE16 | ( |  | a,
|  |  | val
| ) |  |

Value:
do { \
(a)[0] = ((u16) (val)) >> 8; \
(a)[1] = ((u16) (val)) & 0xff; \
} while (0)

#define RTW_PUT_BE24 | ( |  | a,
|  |  | val
| ) |  |

Value:
do { \
(a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \
(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
(a)[2] = (u8) (((u32) (val)) & 0xff); \
} while (0)

#define RTW_PUT_BE32 | ( |  | a,
|  |  | val
| ) |  |

Value:
do { \
(a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
(a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
(a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
(a)[3] = (u8) (((u32) (val)) & 0xff); \
} while (0)

#define RTW_PUT_BE64 | ( |  | a,
|  |  | val
| ) |  |

Value:
do { \
(a)[0] = (u8) (((u64) (val)) >> 56); \
(a)[1] = (u8) (((u64) (val)) >> 48); \
(a)[2] = (u8) (((u64) (val)) >> 40); \
(a)[3] = (u8) (((u64) (val)) >> 32); \
(a)[4] = (u8) (((u64) (val)) >> 24); \
(a)[5] = (u8) (((u64) (val)) >> 16); \
(a)[6] = (u8) (((u64) (val)) >> 8); \
(a)[7] = (u8) (((u64) (val)) & 0xff); \
} while (0)

#define RTW_PUT_LE16 | ( |  | a,
|  |  | val
| ) |  |

Value:
do { \
(a)[1] = ((u16) (val)) >> 8; \
(a)[0] = ((u16) (val)) & 0xff; \
} while (0)

#define RTW_PUT_LE32 | ( |  | a,
|  |  | val
| ) |  |

Value:
do { \
(a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \
(a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \
(a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
(a)[0] = (u8) (((u32) (val)) & 0xff); \
} while (0)

## Function Documentation

void add_mem_usage | ( | _list * | pmem_table,
|  | void * | ptr,
|  | int | size,
|  | int * | used_num,
|  | int | flag
| ) |  |

This function alloc mem_entry to the memory table.

Parameters

  [in] | pmem_table | The pointer to the memory table to be added.
  [in] | ptr | The pointer to the position to be added.
  [in] | size | The size of added memory.
  [in] | used_num | The number of mem_entry kept in monitor which will add 1 after.
  [in] | flag | MEM_MONITOR_FLAG_WPAS/MEM_MONITOR_FLAG_WIFI_DRV

Returns
  None

void ATOMIC_ADD | ( | ATOMIC_T * | v,
|  | int | i
| ) |  |

This function adds "i" to the contained "v".

Parameters

  [in] | v | Pointer of type atomic_t.
  [in] | i | value to add.

Returns
  None

int ATOMIC_ADD_RETURN | ( | ATOMIC_T * | v,
|  | int | i
| ) |  |

This function adds "i" to the contained "v" and returns the result.

Parameters

  [in] | v | Pointer of type atomic_t.
  [in] | i | value to add.

Returns
  None

void ATOMIC_DEC | ( | ATOMIC_T * | v | ) |

This function subtracts 1 from th econtained "v".

Parameters

  [in] | v | Pointer of type atomic_t.

Returns
  None

int ATOMIC_DEC_AND_TEST | ( | ATOMIC_T * | v | ) |

This function subtracts 1 from th econtained "v" and test if the result equals 0.

Parameters

  [in] | v | Pointer of type atomic_t.

Returns
  0: The result after subtracting 1 is 0
  -1: The result after subtracting 1 is not 0

int ATOMIC_DEC_RETURN | ( | ATOMIC_T * | v | ) |

This function subtracts 1 from th econtained "v" and returns the result.

Parameters

  [in] | v | Pointer of type atomic_t.

Returns
  None

void ATOMIC_INC | ( | ATOMIC_T * | v | ) |

This function adds 1 to the contained "v".

Parameters

  [in] | v | Pointer of type atomic_t.

Returns
  None

int ATOMIC_INC_RETURN | ( | ATOMIC_T * | v | ) |

This function adds 1 to the contained "v" and returns the result.

Parameters

  [in] | v | Pointer of type atomic_t.

Returns
  None

int ATOMIC_READ | ( | ATOMIC_T * | v | ) |

This function atomically reads the value of the variable.

Parameters

  [in] | v | Pointer of type atomic_t that to be read.

Returns
  The value of the variable.

Note
  The guaranteed useful range of an atomic_t is only 24 bits.

void ATOMIC_SET | ( | ATOMIC_T * | v,
|  | int | i
| ) |  |

This function atomically sets the value of the variable.

Parameters

  [in] | v | Pointer of type atomic_t that to be set value.
  [in] | i | Required value.

Returns
  None

Note
  The guaranteed useful range of an atomic_t is only 24 bits.

void ATOMIC_SUB | ( | ATOMIC_T * | v,
|  | int | i
| ) |  |

This function subtracts "i" from th econtained "v".

Parameters

  [in] | v | Pointer of type atomic_t.
  [in] | i | value to subtract.

Returns
  None

int ATOMIC_SUB_RETURN | ( | ATOMIC_T * | v,
|  | int | i
| ) |  |

This function subtracts "i" from th econtained "v" and returns the result.

Parameters

  [in] | v | Pointer of type atomic_t.
  [in] | i | value to subtract.

Returns
  None

void deinit_mem_monitor | ( | _list * | pmem_table,
|  | int * | used_num
| ) |  |

This function deinitializes a memory table.

Parameters

  [in] | pmem_table | The pointer to the memory table.
  [in] | used_num | The number of mem_entry kept in monitor.

Returns
  None

void del_mem_usage | ( | _list * | pmem_table,
|  | void * | ptr,
|  | int * | used_num,
|  | int | flag
| ) |  |

This function frees memory from the memory table.

Parameters

  [in] | pmem_table | The pointer to the memory table
  [in] | ptr | The pointer to the position to be free.
  [in] | used_num | The number of mem_entry kept in monitor.
  [in] | flag | MEM_MONITOR_FLAG_WPAS/MEM_MONITOR_FLAG_WIFI_DRV

Returns
  None

int get_mem_usage | ( | _list * | pmem_table | ) |

This function get the memory usage of a memory table.

Parameters

  [in] | pmem_table | The pointer to the memory table.

Returns
  The size of the memory used

void init_mem_monitor | ( | _list * | pmem_table,
|  | int * | used_num
| ) |  |

This function initializes a memory table.

Parameters

  [in] | pmem_table | The pointer to the memory table.
  [in] | used_num | The number of mem_entry kept in monitor which will be set to 0.

Returns
  None

void rtw_acquire_wakelock | ( | void |  | ) |

This function indicates that the WLAN needs to stay on which means cannot go into power saving mode.

Returns
  None

Note
  Defining configUSE_WAKELOCK_PMU 1 in "FreeRTOSConfig.h" needs to be done before compiling, or this API won't be effective.

u32 rtw_atoi | ( | u8 * | s | ) |

This function converts the initial portion of the string to integer.

Parameters

  [in] | s | The pointer to the string to be converted.

Returns
  The converted value.

int rtw_create_task | ( | struct task_struct * | task,
|  | const char * | name,
|  | u32 | stack_size,
|  | u32 | priority,
|  | thread_func_t | func,
|  | void * | thctx
| ) |  |

This function creates a new task and adds it to the list of tasks that are ready to run.

Parameters

  [in] | task | The task stucture which will store the task related infomation.
  [in] | name | A descriptive name for the task.
  [in] | stack_size | The size of the task stack specified as the variables the stack can hold.
  [in] | priority | The priority at which the task should run.
  [in] | func | The task entry function.
  [in] | thctx | The pointer that will be used as the parameter for the task being created.

Returns
  pdPASS: The task was successfully created and added to a ready list.
  other error code defined in the file errors.h.

Note
  For the task name, please do not use "rtw_little_wifi_mcu_thread", "rtw_check_in_req_state_thread", "rtw_TDMA_change_state_thread", "xmit_thread", "recv_thread", "rtw_recv_tasklet", "rtw_xmit_tasklet", "rtw_interrupt_thread", "cmd_thread", "usb_init", "MSC_BULK_CMD" and "MSC_BULK_DATA".

int rtw_create_worker_thread | ( | rtw_worker_thread_t * | worker_thread,
|  | u8 | priority,
|  | u32 | stack_size,
|  | u32 | event_queue_size
| ) |  |

This function creates a new worker thread.

Parameters

  [in] | worker_thread | The pointer to the worker thread stucture.
  [in] | priority | The priority of the thread.
  [in] | stack_size | The size of the thread stack specified as the variables the stack can hold.
  [in] | event_queue_size | The queue size of events.

Returns
  SUCCESS/FAIL.

int rtw_deinit_xqueue | ( | _xqueue * | queue | ) |

Delete a queue - freeing all the memory allocated for storing of messages placed on the queue.

Parameters

  [in] | queue | The handle to the queue to be deleted.

Returns
  0: The queue was successfully deleted.
  -1: The queue was not empty so cannot be deleted.

void rtw_delete_task | ( | struct task_struct * | task | ) |

This function deletes a task.

Parameters

  [in] | task | The task stucture which will be deleted.

Returns
  None

int rtw_delete_worker_thread | ( | rtw_worker_thread_t * | worker_thread | ) |

This function deletes a worker thread.

Parameters

  [in] | worker_thread | The pointer to the worker thread stucture to be deleted.

Returns
  SUCCESS/FAIL.

u32 rtw_down_sema | ( | _sema * | sema | ) |

This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up.

Parameters

  [in] | sema | The semaphore to be acquired.

Returns
  pdTRUE: The semaphore was obtained.
  pdFALSE: Obtain the semaphore failed.

u32 rtw_down_timeout_sema | ( | _sema * | sema,
|  | u32 | timeout
| ) |  |

This function acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is up.

Parameters

  [in] | sema | The semaphore to be acquired.
  [in] | timeout | The time in ms to wait for the semaphore to become available.

Returns
  pdTRUE: The semaphore was obtained.
  pdFALSE: Timeout without the semaphore becoming available.

u32 rtw_end_of_queue_search | ( | _list * | queue,
|  | _list * | pelement
| ) |  |

This function tests whether the "pelement" is at the "queue".

Parameters

  [in] | queue | The pointer to the queue that to be tested.
  [in] | pelement | The element that to be tested.

Returns
  _TRUE/_FALSE

void rtw_enter_critical | ( | _lock * | plock,
|  | _irqL * | pirqL
| ) |  |

This function marks the start of a critical code region. Preemptive context switches cannot occur when in a critical region.

Parameters

  [in] | plock | Pointer to the spin lock semaphore.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

Note
  : This may alter the stack (depending on the portable implementation) so must be used with care!

void rtw_enter_critical_bh | ( | _lock * | plock,
|  | _irqL * | pirqL
| ) |  |

This function obtains a spin lock semaphore.

Parameters

  [in] | plock | Pointer to the spin lock semaphore being taken - obtained when the mutex semaphore was created.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

void rtw_enter_critical_from_isr | ( | _lock * | plock,
|  | _irqL * | pirqL
| ) |  |

This function marks the start of a critical code region from isr.

Parameters

  [in] | plock | Pointer to the spin lock semaphore.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

int rtw_enter_critical_mutex | ( | _mutex * | pmutex,
|  | _irqL * | pirqL
| ) |  |

This function obtains a semaphore.

Parameters

  [in] | pmutex | The handle to the mutex semaphore to be obtained.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

void rtw_exit_critical | ( | _lock * | plock,
|  | _irqL * | pirqL
| ) |  |

This function marks end of a critical code region. Preemptive context switches cannot occur when in a critical region.

Parameters

  [in] | plock | Pointer to the spin lock semaphore.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

Note
  : This may alter the stack (depending on the portable implementation) so must be used with care!

void rtw_exit_critical_bh | ( | _lock * | plock,
|  | _irqL * | pirqL
| ) |  |

This function releases a spin lock semaphore.

Parameters

  [in] | plock | Pointer to the spin lock semaphore to be released.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

void rtw_exit_critical_from_isr | ( | _lock * | plock,
|  | _irqL * | pirqL
| ) |  |

This function marks the end of a critical code region from isr.

Parameters

  [in] | plock | Pointer to the spin lock semaphore.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

void rtw_exit_critical_mutex | ( | _mutex * | pmutex,
|  | _irqL * | pirqL
| ) |  |

This function releases a semaphore.

Parameters

  [in] | pmutex | The handle to the mutex semaphore to be released.
  [in] | pirqL | Pointer to the IRQ.

Returns
  None

void rtw_free_sema | ( | _sema * | sema | ) |

This function deletes the semaphore.

Parameters

  [in] | sema | The semaphore to be deleted.

Returns
  None

u32 rtw_get_current_time | ( | void |  | ) |

Get the count of ticks since the vTaskStartScheduler was called.

Returns
  The count of ticks since the vTaskStartScheduler was called.

s32 rtw_get_passing_time_ms | ( | u32 | start | ) |

Get the passing time from the "start" in milliseconds.

Parameters

  [in] | start | The start time which is in system time format.

Returns
  : The passing time from "start" in milliseconds.

int rtw_get_random_bytes | ( | void * | dst,
|  | u32 | size
| ) |  |

This function generates random bytes.

Parameters

  [in] | dst | The pointer to the buffer to store the random bytes.
  [in] | size | The size of the random bytes.

Returns
  0

u8 rtw_get_scheduler_state | ( | void |  | ) |

This function gets the scheduler state of the calling thread.

Returns
  OS_SCHEDULER_NOT_STARTED
  OS_SCHEDULER_RUNNING
  OS_SCHEDULER_SUSPENDED

s32 rtw_get_time_interval_ms | ( | u32 | start,
|  | u32 | end
| ) |  |

Get the interval time from the "start" to "end" in milliseconds.

Parameters

  [in] | start | The start time which is in system time format.
  [in] | end | The end time which is in system time format.

Returns
  : The interval time from "start" to "end" in milliseconds.

u32 rtw_getFreeHeapSize | ( | void |  | ) |

This function gets the available heap size.

Returns
  The value of the available heap size.

void rtw_init_listhead | ( | _list * | list | ) |

This function initializes the head of the list.

Parameters

  [in] | list | Pointer to the list to be initialized.

Returns
  None

void rtw_init_queue | ( | _queue * | pqueue | ) |

This function creates a new queue instance.

Parameters

  [in] | pqueue | The handle to the newly created queue.

Returns
  None

void rtw_init_sema | ( | _sema * | sema,
|  | int | init_val
| ) |  |

This function initializes the unnamed semaphore referred to by "sema" to the value "init_val".

Parameters

  [in] | sema | Pointer to the semaphore handle to be initialized.
  [in] | init_val | Initial value for semaphore.

Returns
  None

int rtw_init_xqueue | ( | _xqueue * | queue,
|  | const char * | name,
|  | u32 | message_size,
|  | u32 | number_of_messages
| ) |  |

This function creates a new queue instance.

Parameters

  [in] | queue | The handle to the newly created queue.
  [in] | name | The name of the queue
  [in] | message_size | The number of bytes each message in the queue will require.
  [in] | number_of_messages | The maximum number of messages that kthe queue can contain.

Returns
  0: Creating queue success
  -1: Creating queue fail

u32 rtw_is_list_empty | ( | _list * | phead | ) |

This function tests whether a list is empty.

Parameters

  [in] | phead | Pointer to the list to test.

Returns
  _TRUE/_FALSE

void rtw_list_delete | ( | _list * | plist | ) |

This function deletes entry from list and reinitialize it.

Parameters

  [in] | plist | The element to delete from the list.

Returns
  None

Note
  Caller must check if the list is empty before calling rtw_list_delete

void rtw_list_insert_head | ( | _list * | plist,
|  | _list * | phead
| ) |  |

This function adds a new entry after "phead" for the list.

Parameters

  [in] | plist | Pointer to the list to be added.
  [in] | phead | List head to add it after.

Returns
  None

void rtw_list_insert_tail | ( | _list * | plist,
|  | _list * | phead
| ) |  |

This function adds a new entry before "phead" for the list.

Parameters

  [in] | plist | Pointer to the list to be added.
  [in] | phead | List head to add it before.

Returns
  None

u8* rtw_malloc | ( | u32 | sz | ) |

This function allocates the memory.

Parameters

  [in] | sz | The size of memory to be allocated.

Returns
  The pointer to the beginning of the memory

void* rtw_malloc2d | ( | int | h,
|  | int | w,
|  | int | size
| ) |  |

This function allocates a 2 dimensional array memory.

Parameters

  [in] | h | The height of the 2D array.
  [in] | w | The width of the 2D array.
  [in] | size | The size of the each charactor in array.

Returns
  the pointer to the beginning of the block

void rtw_mdelay_os | ( | int | ms | ) |

This function delays a task for the giving time in milliseconds.

Parameters

  [in] | ms | The amount of time, in milliseconds, that the calling task should block.

Returns
  None

int rtw_memcmp | ( | void * | dst,
|  | void * | src,
|  | u32 | sz
| ) |  |

This function compares the first "sz" bytes of the block of memory pointed by "dst" to the first "sz" bytes pointed by "src".

Parameters

  [in] | dst | Pointer to block of memory to be compared.
  [in] | src | pointer to block of memory to compare.
  [in] | sz | Size of memory to compare.

Returns
  <0: The first byte that does not match in both memory blocks has a lower value in dst than in src.
  0: The contents of both memory blocks are equal.
  <0: The first byte that does not match in both memory blocks has a greater value in dst than in src.

void rtw_memcpy | ( | void * | dst,
|  | void * | src,
|  | u32 | sz
| ) |  |

This function copies the values of "sz" bytes from the location pointed to by "src" directly to the memory block pointed to by "des".

Parameters

  [in] | dst | Pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
  [in] | src | Pointer to the source of data to be copied, type-casted to a pointer of type void*.
  [in] | sz | Size of memory to copy.

Returns
  None

void rtw_memset | ( | void * | pbuf,
|  | int | c,
|  | u32 | sz
| ) |  |

This function sets the first "sz" bytes of the block of memory pointed by "pbuf" to the specified "c".

Parameters

  [in] | pbuf | Pointer to the block of memory to fill.
  [in] | c | Value to be set.
  [in] | sz | Size of memory to be set to the value "c".

Returns
  None

void rtw_mfree | ( | u8 * | pbuf,
|  | u32 | sz
| ) |  |

This function frees the virtually contiguous memory.

Parameters

  [in] | pbuf | The pointer to the beginning of the memory to be free
  [in] | sz | The size of memory allocated.

Returns
  None

void rtw_mfree2d | ( | void * | pbuf,
|  | int | h,
|  | int | w,
|  | int | size
| ) |  |

This function deallocates the block of memory previously allocated to make it available again.

Parameters

  [in] | pbuf | Pointer to a memory block previously allocated.
  [in] | h | The height of the 2D array.
  [in] | w | The width of the 2D array.
  [in] | size | The size of the each charactor in array.

Returns
  None

u32 rtw_ms_to_systime | ( | u32 | ms | ) |

Convert milliseconds to system time.

Parameters

  [in] | systime | The milliseconds to be converted.

Returns
  : The system time that converted by the milliseconds.

void rtw_msleep_os | ( | int | ms | ) |

This function suspends execution of the calling thread for "ms" milliseconds.

Parameters

  [in] | ms | The time that the function sleep in milliseconds

Returns
  None

void rtw_mutex_free | ( | _mutex * | pmutex | ) |

This function deletes the mutex semaphore.

Parameters

  [in] | pmutex | Pointer to the mutex semaphore to be deleted.

Returns
  None

void rtw_mutex_get | ( | _mutex * | pmutex | ) |

This function obtains a mutex semaphore.

Parameters

  [in] | pmutex | Pointer to the mutex semaphore being taken - obtained when the mutex semaphore was created.

Returns
  None

int rtw_mutex_get_timeout | ( | _mutex * | pmutex,
|  | u32 | timeout_ms
| ) |  |

This function obtains a mutex semaphore with a timeout setting.

Parameters

  [in] | pmutex | Pointer to the mutex semaphore being taken - obtained when the mutex semaphore was created.
  [in] | timeout | The time in ms to wait for the semaphore to become available.

Returns
  0: The semaphore was obtained.
  -1: Timeout without the semaphore becoming available.

void rtw_mutex_init | ( | _mutex * | pmutex | ) |

This function implements a mutex semaphore by using the existing queue mechanism.

Parameters

  [in] | pmutex | Pointer to the created mutex semaphore.

Returns
  None

void rtw_mutex_put | ( | _mutex * | pmutex | ) |

This function releases a mutex semaphore.

Parameters

  [in] | pmutex | Pointer to the mutex semaphore to be released.

Returns
  None

int rtw_pop_from_xqueue | ( | _xqueue * | queue,
|  | void * | message,
|  | u32 | timeout_ms
| ) |  |

This function receives a message from a queue. The message is recieved by copy so a buffer adequate size must be provided.

Parameters

  [in] | queue | The handle to the queue from which the message is to be received.
  [in] | message | The pointer to the buffer into which the received message will be copied.
  [in] | timeout_ms | The maximum amout of time the task should block waiting for a message to receive should the queue be empty at the time of the call. The time is defined in ms.

Returns
  0: A message was successfully received from the queue.
  -1: No message was received from the queue.

int rtw_push_to_xqueue | ( | _xqueue * | queue,
|  | void * | message,
|  | u32 | timeout_ms
| ) |  |

This function posts a message to the back of a queue. The message is queued by copy, not by reference.

Parameters

  [in] | queue | The handle to the queue on which the message is to be posted.
  [in] | message | The pointer to the message that is to be placed on the queue.
  [in] | timeout_ms | The maximum amout of time the task should block waiting for the space to become available on the queue, should it already be full. The time is defined in ms.

Returns
  0: The message was successfully posted.
  -1: The message was not posted.

u32 rtw_queue_empty | ( | _queue * | pqueue | ) |

This function tests whether the queue is empty.

Parameters

  [in] | pqueue | The handle to the queue to be tested.

Returns
  None

void rtw_release_wakelock | ( | void |  | ) |

This function indicates that the WLAN does not need to stay on which means can go into power saving mode.

Returns
  None

Note
  Defining configUSE_WAKELOCK_PMU 1 in "FreeRTOSConfig.h" needs to be done before compiling, or this API won't be effective.

u32 rtw_sec_to_systime | ( | u32 | sec | ) |

Convert seconds to system time.

Parameters

  [in] | systime | The seconds to be converted.

Returns
  : The system time that converted by the seconds.

void rtw_spin_lock | ( | _lock * | plock | ) |

This function obtains a spin lock semaphore.

Parameters

  [in] | plock | Pointer to the spin lock semaphore being taken - obtained when the mutex semaphore was created.

Returns
  None

void rtw_spin_unlock | ( | _lock * | plock | ) |

This function releases a spin lock semaphore.

Parameters

  [in] | plock | Pointer to the spin lock semaphore to be released.

Returns
  None

void rtw_spinlock_free | ( | _lock * | plock | ) |

This function deletes the spin lock semaphore.

Parameters

  [in] | pmutex | Pointer to the spin lock semaphore to be deleted.

Returns
  None

void rtw_spinlock_init | ( | _lock * | plock | ) |

This function implements a spin lock semaphore by using the existing queue mechanism.

Parameters

  [in] | plock | Pointer to the created spin lock semaphore.

Returns
  None

void rtw_spinlock_irqsave | ( | _lock * | plock,
|  | _irqL * | irqL
| ) |  |

This function marks the start of a critical code region and obtains a spin lock semaphore.

Parameters

  [in] | plock | Pointer to the spin lock semaphore being taken - obtained when the mutex semaphore was created.
  [in] | irqL | Pointer to the IRQ.

Returns
  None

void rtw_spinunlock_irqsave | ( | _lock * | plock,
|  | _irqL * | irqL
| ) |  |

This function releases a spin lock semaphore and marks the end of a critical code region.

Parameters

  [in] | plock | Pointer to the spin lock semaphore to be released.
  [in] | irqL | Pointer to the IRQ.

Returns
  None

u32 rtw_systime_to_ms | ( | u32 | systime | ) |

Convert system time to milliseconds.

Parameters

  [in] | systime | The system time to be converted.

Returns
  : The milliseconds that converted by the system time.

u32 rtw_systime_to_sec | ( | u32 | systime | ) |

Convert system time to seconds.

Parameters

  [in] | systime | The system time to be converted.

Returns
  : The seconds that converted by the system time.

void rtw_thread_enter | ( | char * | name | ) |

This function prints the name of the thread in DBG_INFO.

Parameters

  [in] | name | The name of the thread.

Returns
  None

void rtw_thread_exit | ( | void |  | ) |

This function exits the calling thread.

Returns
  None

u32 rtw_timerChangePeriod | ( | _timerHandle | xTimer,
|  | osdepTickType | xNewPeriod,
|  | osdepTickType | xBlockTime
| ) |  |

This function changes the period of a timer that was previously created.

Parameters

  [in] | xTimer | The handle of the timer that is having its period changed.
  [in] | xNewPeriod | The new period for xTimer.
  [in] | xBlockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the change period command to be successfully sent to the timer command queue, should the queue already be full when rtw_timerChangePeriod() was called.

Returns
  pdFAIL will be returned if the change period command could not be sent to the timer command queue even after xTicksToWait ticks had passed. pdPASS will be returned if the command was successfully sent to the timer command queue. When the command is actually processed will depend on the priority of the timer service/daemon task relative to other tasks in the system.

_timerHandle rtw_timerCreate | ( | const signed char * | pcTimerName,
|  | osdepTickType | xTimerPeriodInTicks,
|  | u32 | uxAutoReload,
|  | void * | pvTimerID,
|  | TIMER_FUN | pxCallbackFunction
| ) |  |

This function creates a new software timer instance.

Parameters

  [in] | pcTimerName | A text name that is assigned to the timer.
  [in] | xTimerPeriodInTicks | The timer period which is defined in tick periods.
  [in] | uxAutoReload | If uxAutoReload is set to pdTRUE then the timer will expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and enter the dormant state after it expires.
  [in] | pvTimerID | An identifier that is assigned to the timer being created.
  [in] | pxCallbackFunction | The function to call when the timer expires.

Returns
  If the timer is successfully create then a handle to the newly created timer is returned. If the timer cannot be created, then 0 is returned.

u32 rtw_timerDelete | ( | _timerHandle | xTimer,
|  | osdepTickType | xBlockTime
| ) |  |

This function deletes a timer that was previously created using rtw_timerCreate.

Parameters

  [in] | xTimer | The handle of the timer being deleted.
  [in] | xBlockTime | Specifies th etime, in ticks, that the calling task should be held in the Blocked State to wait for the delete command to be successfully sent to the timer command queue, should the queue already be full when rtw_timerDelete was called.

Returns
  pdFAIL will be returned if the delete command could not be sent to the timer command queue even after xTicksToWait ticks had passed. pdPASS will be returned if the command was successfully sent to the timer command queue. When the command is actually processed will depend on the priority of the timer service/daemon task relative to other tasks in the system.

u32 rtw_timerIsTimerActive | ( | _timerHandle | xTimer | ) |

This function queries a timer to see if it is active or dormant.

Parameters

  [in] | xTimer | The timer being queried.

Returns
  pdFALSE will be returned if the timer is dormant. A value other than pdFALSE will be returned if the timer is active.

Note
  A timer will be dormant if: 1) It has been created but not started, or 2) It is an expired one-shot timer that has not been restarted.

u32 rtw_timerStop | ( | _timerHandle | xTimer,
|  | osdepTickType | xBlockTime
| ) |  |

This function stops a timer that was previously started.

Parameters

  [in] | xTimer | The handle of the timer being stopped.
  [in] | xBlockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the stop command to be successfully sent to the timer command queue, should the queue already be full when rtw_timerStop() was called.

Returns
  pdFAIL will be returned if the stop command could not be sent to the timer command queue even after xTicksToWait ticks had passed. pdPASS will be returned if the command was successfully sent to the timer command queue. When the command is actually processed will depend on the priority of the timer service/daemon task relative to other tasks in the system.

void rtw_udelay_os | ( | int | us | ) |

This function delays a task for the giving time in microseconds.

Parameters

  [in] | ms | The amount of time, in microseconds, that the calling task should block.

Returns
  None

void rtw_up_sema | ( | _sema * | sema | ) |

This function releases the semaphore. This macro must not be used from an ISR.

Parameters

  [in] | sema | The semaphore to be released.

Returns
  None

void rtw_up_sema_from_isr | ( | _sema * | sema | ) |

This function releases the semaphore. This macro can be used from an ISR.

Parameters

  [in] | sema | The semaphore to be released.

Returns
  None

void rtw_usleep_os | ( | int | us | ) |

This function suspends execution of the calling thread for "us" microseconds.

Parameters

  [in] | ms | The time that the function sleep in microseconds

Returns
  None

u8* rtw_vmalloc | ( | u32 | sz | ) |

This function allocates the virtually contiguous memory.

Parameters

  [in] | sz | The size of memory to be allocated.

Returns
  The pointer to the beginning of the memory

void rtw_vmfree | ( | u8 * | pbuf,
|  | u32 | sz
| ) |  |

This function frees the virtually contiguous memory.

Parameters

  [in] | pbuf | The pointer to the beginning of the memory to be free
  [in] | sz | The size of memory allocated.

Returns
  None

void rtw_wakeup_task | ( | struct task_struct * | task | ) |

This function wake up a task.

Parameters

  [in] | task | The task stucture which will be waked up.

Returns
  None

void rtw_yield_os | ( | void |  | ) |

This function for forcing a context switch.

Returns
  None

u8* rtw_zmalloc | ( | u32 | sz | ) |

This function allocates the memory and the values of the memory are setted to 0.

Parameters

  [in] | sz | The size of memory to be allocated.

Returns
  The pointer to the beginning of the memory

u8* rtw_zvmalloc | ( | u32 | sz | ) |

This function allocates the virtually contiguous memory and the values of the memory are setted to 0.

Parameters

  [in] | sz | The size of memory to be allocated.

Returns
  The pointer to the beginning of the memory