-
Notifications
You must be signed in to change notification settings - Fork 1.1k
AliOS Things API KERNEL Guide
- 1 aos_reboot
- 2 aos_get_hz
- 3 aos_version_get
- 4 aos_task_new
- 5 aos_task_new_ext
- 6 aos_task_exit
- 7 aos_task_name
- 8 aos_task_key_create
- 9 aos_task_key_delete
- 10 aos_task_setspecific
- 11 aos_task_getspecific
- 12 aos_mutex_new
- 13 aos_mutex_free
- 14 aos_mutex_lock
- 15 aos_mutex_unlock
- 16 aos_mutex_is_valid
- 17 aos_sem_new
- 18 aos_sem_free
- 19 aos_sem_wait
- 20 aos_sem_signal
- 21 aos_sem_is_valid
- 22 aos_sem_signal_all
- 23 aos_queue_new
- 24 aos_queue_free
- 25 aos_queue_send
- 26 aos_queue_recv
- 27 aos_queue_is_valid
- 28 aos_queue_buf_ptr
- 29 aos_sched_disable
- 30 aos_sched_enable
- 31 aos_timer_new
- 32 aos_timer_free
- 33 aos_timer_start
- 34 aos_timer_stop
- 35 aos_timer_change
- 36 aos_workqueue_create
- 37 aos_workqueue_del
- 38 aos_work_init
- 39 aos_work_destroy
- 40 aos_work_run
- 41 aos_work_sched
- 42 aos_work_cancel
- 43 aos_realloc
- 44 aos_malloc
- 45 aos_zalloc
- 46 aos_alloc_trace
- 47 aos_free
- 48 aos_now
- 49 aos_now_ms
- 50 aos_msleep
void aos_reboot(void)
-
Description
Reboot AliOS.
-
Parameters
None.
-
Returns
None.
int aos_get_hz(void)
-
Description
Get HZ(ticks per second).
-
Parameters
None.
-
Returns
RHINO_CONFIG_TICKS_PER_SECOND.
const char *aos_version_get(void)
-
Description
Get kernel version.
-
Parameters
None.
-
Returns
SYSINFO_KERNEL_VERSION.
int aos_task_new(const char *name, void (*fn)(void *), void *arg, int stack_size)
-
Description
Create a task.
-
Parameters
IN/OUT NAME DESC [in] name task name. [in] fn function to run. [in] arg argument of the function. [in] stacksize stack-size in bytes. -
Returns
0: success.
int aos_task_new_ext(aos_task_t *task, const char *name, void (*fn)(void *), void *arg,
int stack_size, int prio)
-
Description
Create a task.
-
Parameters
IN/OUT NAME DESC [in] task handle. [in] name task name. [in] fn task function. [in] arg argument of the function.. [in] stack_buf stack-buf: if stack_buf==NULL, provided by kernel. [in] stack_size stack-size in bytes. [in] prio priority value, the max is RHINO_CONFIG_USER_PRI_MAX(default 60). -
Returns
0: success.
void aos_task_exit(int code)
-
Description
Exit a task.
-
Parameters
IN/OUT NAME DESC [in] code not used now. -
Returns
None.
const char *aos_task_name(void)
-
Description
Get task name.
-
Parameters
None.
-
Returns
the name of the task
int aos_task_key_create(aos_task_key_t *key)
-
Description
Create a task key.
-
Parameters
IN/OUT NAME DESC [in] key pointer of key object. -
Returns
0: success, -EINVAL: error.
void aos_task_key_delete(aos_task_key_t key)
-
Description
Delete a task key.
-
Parameters
IN/OUT NAME DESC [in] key key object. -
Returns
None.
int aos_task_setspecific(aos_task_key_t key, void *vp)
-
Description
Associate a task-specific value with a key.
-
Parameters
IN/OUT NAME DESC [in] key key object. [in] vp pointer of a task-specific value. -
Returns
the check status, 0 is OK, -1 indicates invalid.
void *aos_task_getspecific(aos_task_key_t key)
-
Description
Get the value currently bound to the specified key.
-
Parameters
IN/OUT NAME DESC [in] key key object. -
Returns
None.
int aos_mutex_new(aos_mutex_t *mutex)
-
Description
Alloc a mutex.
-
Parameters
IN/OUT NAME DESC [in] mutex pointer of mutex object, mutex object must be alloced, hdl pointer in aos_mutex_t will refer a kernel obj internally. -
Returns
0: success.
void aos_mutex_free(aos_mutex_t *mutex)
-
Description
Free a mutex.
-
Parameters
IN/OUT NAME DESC [in] mutex mutex object, mem refered by hdl pointer in aos_mutex_t will be freed internally. -
Returns
None.
int aos_mutex_lock(aos_mutex_t *mutex, unsigned int timeout)
-
Description
Lock a mutex.
-
Parameters
IN/OUT NAME DESC [in] mutex mutex object, it contains kernel obj pointer which aos_mutex_new alloced. [in] timeout waiting until timeout in milliseconds. -
Returns
0: success.
int aos_mutex_unlock(aos_mutex_t *mutex)
-
Description
Unlock a mutex.
-
Parameters
IN/OUT NAME DESC [in] mutex mutex object, it contains kernel obj pointer which oc_mutex_new alloced. -
Returns
0: success.
int aos_mutex_is_valid(aos_mutex_t *mutex)
-
Description
This function will check if mutex is valid.
-
Parameters
IN/OUT NAME DESC [in] mutex pointer to the mutex. -
Returns
0: success.
int aos_sem_new(aos_sem_t *sem, int count)
-
Description
Alloc a semaphore.
-
Parameters
IN/OUT NAME DESC [out] sem pointer of semaphore object, semaphore object must be alloced,hdl pointer in aos_sem_t will refer a kernel obj internally. [in] count initial semaphore counter. -
Returns
0:success.
void aos_sem_free(aos_sem_t *sem)
-
Description
Destroy a semaphore.
-
Parameters
IN/OUT NAME DESC [in] sem pointer of semaphore object, mem refered by hdl pointer in aos_sem_t will be freed internally. -
Returns
None.
int aos_sem_wait(aos_sem_t *sem, unsigned int timeout)
-
Description
Acquire a semaphore.
-
Parameters
IN/OUT NAME DESC [in] sem semaphore object, it contains kernel obj pointer which aos_sem_new alloced. [in] timeout waiting until timeout in milliseconds. -
Returns
0: success.
void aos_sem_signal(aos_sem_t *sem)
-
Description
Release a semaphore.
-
Parameters
IN/OUT NAME DESC [in] sem semaphore object, it contains kernel obj pointer which aos_sem_new alloced. -
Returns
None.
int aos_sem_is_valid(aos_sem_t *sem)
-
Description
This function will check if semaphore is valid.
-
Parameters
IN/OUT NAME DESC [in] sem pointer to the semaphore. -
Returns
0: success.
void aos_sem_signal_all(aos_sem_t *sem)
-
Description
Release all semaphore.
-
Parameters
IN/OUT NAME DESC [in] sem semaphore object, it contains kernel obj pointer which aos_sem_new alloced. -
Returns
None.
int aos_queue_new(aos_queue_t *queue, void *buf, unsigned int size, int max_msg)
-
Description
This function will create a queue.
-
Parameters
IN/OUT NAME DESC [in] queue pointer to the queue(the space is provided by user). [in] buf buf of the queue(provided by user). [in] size the bytes of the buf. [in] max_msg the max size of the msg. -
Returns
0: success.
void aos_queue_free(aos_queue_t *queue)
-
Description
This function will delete a queue.
-
Parameters
IN/OUT NAME DESC [in] queue pointer to the queue. -
Returns
None.
int aos_queue_send(aos_queue_t *queue, void *msg, unsigned int size)
-
Description
This function will send a msg to the front of a queue.
-
Parameters
IN/OUT NAME DESC [in] queue pointer to the queue. [in] msg msg to send. [in] size size of the msg. -
Returns
0: success.
int aos_queue_recv(aos_queue_t *queue, unsigned int ms, void *msg,unsigned int *size)
-
Description
This function will receive msg from a queue.
-
Parameters
IN/OUT NAME DESC [in] queue pointer to the queue. [in] ms ms to wait before receive. [out] msg buf to save msg. [out] size size of the msg. -
Returns
0: success.
int aos_queue_is_valid(aos_queue_t *queue)
-
Description
This function will check if queue is valid.
-
Parameters
IN/OUT NAME DESC [in] queue pointer to the queue. -
Returns
0: success.
void *aos_queue_buf_ptr(aos_queue_t *queue)
-
Description
This function will return buf ptr if queue is inited.
-
Parameters
IN/OUT NAME DESC [in] queue pointer to the queue. -
Returns
NULL: error.
int aos_sched_disable(void)
-
Description
This function will disable kernel sched.
-
Parameters
None.
-
Returns
the operation status, 0 is OK, others is error.
int aos_sched_enable(void)
-
Description
This function will enable kernel sched.
-
Parameters
None.
-
Returns
0: success.
int aos_timer_new(aos_timer_t *timer, void (*fn)(void *, void *),
void *arg, int ms, int repeat)
-
Description
This function will create a timer.
-
Parameters
IN/OUT NAME DESC [in] timer pointer to the timer. [in] fn callbak of the timer. [in] arg the argument of the callback. [in] ms ms of the normal timer triger. [in] repeat repeat or not when the timer is created. -
Returns
0: success.
void aos_timer_free(aos_timer_t *timer)
-
Description
This function will delete a timer.
-
Parameters
IN/OUT NAME DESC [in] timer pointer to a timer. -
Returns
None.
int aos_timer_start(aos_timer_t *timer)
-
Description
This function will start a timer.
-
Parameters
IN/OUT NAME DESC [in] timer pointer to the timer. -
Returns
0: success.
int aos_timer_stop(aos_timer_t *timer)
-
Description
This function will stop a timer.
-
Parameters
IN/OUT NAME DESC [in] timer pointer to the timer. -
Returns
0: success.
int aos_timer_change(aos_timer_t *timer, int ms)
-
Description
This function will change attributes of a timer.
-
Parameters
IN/OUT NAME DESC [in] timer pointer to the timer. [in] ms ms of the timer triger. -
Returns
0: success.
int aos_workqueue_create(aos_workqueue_t *workqueue, int pri, int stack_size)
-
Description
This function will creat a workqueue.
-
Parameters
IN/OUT NAME DESC [in] workqueue the workqueue to be created. [in] pri the priority of the worker. [in] stack_size the size of the worker-stack. -
Returns
0: success.
void aos_workqueue_del(aos_workqueue_t *workqueue)
-
Description
This function will delete a workqueue.
-
Parameters
IN/OUT NAME DESC [in] workqueue the workqueue to be deleted. -
Returns
None.
int aos_work_init(aos_work_t *work, void (*fn)(void *), void *arg, int dly)
-
Description
This function will initialize a work.
-
Parameters
IN/OUT NAME DESC [in] work the work to be initialized. [in] fn the call back function to run. [in] arg the paraments of the function. [in] dly ms to delay before run. -
Returns
0: success.
void aos_work_destroy(aos_work_t *work)
-
Description
This function will destroy a work.
-
Parameters
IN/OUT NAME DESC [in] work the work to be destroied. -
Returns
None.
int aos_work_run(aos_workqueue_t *workqueue, aos_work_t *work)
-
Description
This function will run a work on a workqueue.
-
Parameters
IN/OUT NAME DESC [in] workqueue the workqueue to run work. [in] work the work to run. -
Returns
0: success.
int aos_work_sched(aos_work_t *work)
-
Description
This function will run a work on the default workqueue.
-
Parameters
IN/OUT NAME DESC [in] work the work to run. -
Returns
0: success.
int aos_work_cancel(aos_work_t *work)
-
Description
This function will cancel a work on the default workqueue.
-
Parameters
IN/OUT NAME DESC [in] work the work to cancel. -
Returns
0: success.
void *aos_realloc(void *mem, unsigned int size)
-
Description
Realloc memory.
-
Parameters
IN/OUT NAME DESC [in] mem current memory address point. [in] size new size of the mem to remalloc. -
Returns
NULL: error.
void *aos_malloc(unsigned int size)
-
Description
Alloc memory.
-
Parameters
IN/OUT NAME DESC [in] size size of the mem to malloc. -
Returns
NULL: error.
void *aos_zalloc(unsigned int size)
-
Description
Alloc memory and clear to zero.
-
Parameters
IN/OUT NAME DESC [in] size size of the mem to malloc. -
Returns
NULL: error.
void aos_alloc_trace(void *addr, size_t allocator)
-
Description
Trace alloced mems.
-
Parameters
IN/OUT NAME DESC [in] addr pointer of the mem alloced by malloc. [in] allocator buildin_address. -
Returns
None.
void aos_free(void *mem)
-
Description
Free memory.
-
Parameters
IN/OUT NAME DESC [in] ptr address point of the mem. -
Returns
None.
long long aos_now(void)
-
Description
Get current time in nano seconds.
-
Parameters
None.
-
Returns
elapsed time in nano seconds from system starting.
long long aos_now_ms(void)
-
Description
Get current time in mini seconds.
-
Parameters
None.
-
Returns
elapsed time in mini seconds from system starting.
void aos_msleep(int ms)
-
Description
Msleep.
-
Parameters
IN/OUT NAME DESC [in] ms sleep time in milliseconds. -
Returns
None.
| Home | Tutorial | Hardware | Porting Guide | Utilities | API Reference | Technical Docs | Certification |
Crafted with ❤️ by AliOS Things Team.