From 69fb3e1a7b1b8183afca3e17f21386411e229b77 Mon Sep 17 00:00:00 2001 From: LiteOS2021 Date: Thu, 17 Feb 2022 13:54:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(doc=5Fkernel):=20posix=E3=80=81cmsis?= =?UTF-8?q?=E5=92=8Ckernel=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit posix、cmsis和kernel相关接口文档更新 Signed-off-by: LiteOS2021 --- .../kernel/kernel-mini-appx-lib-cmsis.md | 12 +- .../kernel/kernel-mini-appx-lib-posix.md | 125 +++++++++++++++++- .../kernel-mini-basic-interrupt-guide.md | 59 +++++++-- .../kernel/kernel-mini-basic-task-guide.md | 8 ++ .../kernel/kernel-mini-basic-time-guide.md | 19 ++- zh-cn/device-dev/faqs/faqs-kernel.md | 2 +- .../kernel/kernel-mini-appx-lib-cmsis.md | 12 +- .../kernel/kernel-mini-appx-lib-posix.md | 125 +++++++++++++++++- .../kernel-mini-basic-interrupt-guide.md | 59 +++++++-- .../kernel/kernel-mini-basic-task-guide.md | 8 ++ .../kernel/kernel-mini-basic-time-guide.md | 19 ++- 11 files changed, 409 insertions(+), 39 deletions(-) diff --git a/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md b/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md index 46081c4d328..089fa4d647d 100644 --- a/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md +++ b/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md @@ -92,7 +92,7 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API

osThreadDetach

-

Detaches a thread (thread storage can be reclaimed when the thread terminates). (not implemented yet)

+

Detaches a thread (thread storage can be reclaimed when the thread terminates).

osThreadEnumerate

@@ -142,7 +142,7 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API

osThreadJoin

-

Waits for the specified thread to terminate. (not implemented yet)

+

Waits for the specified thread to terminate.

osThreadNew

@@ -179,22 +179,22 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API

osThreadFlagsSet

-

Sets the specified thread flags for a thread. (not implemented yet)

+

Sets the specified thread flags for a thread.

osThreadFlagsClear

-

Clears the specified thread flags of the thread that is running. (not implemented yet)

+

Clears the specified thread flags of the thread that is running.

osThreadFlagsGet

-

Obtains the current thread flags of the thread that is running. (not implemented yet)

+

Obtains the current thread flags of the thread that is running.

osThreadFlagsWait

-

Waits for one or more thread flags of the currently running thread to emit a signal. (not implemented yet)

+

Waits for one or more thread flags of the currently running thread to emit a signal.

Event flag

diff --git a/en/device-dev/kernel/kernel-mini-appx-lib-posix.md b/en/device-dev/kernel/kernel-mini-appx-lib-posix.md index 6290211b98c..c50dfe3c223 100644 --- a/en/device-dev/kernel/kernel-mini-appx-lib-posix.md +++ b/en/device-dev/kernel/kernel-mini-appx-lib-posix.md @@ -21,7 +21,7 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs -

process

+

process

#include <stdlib.h>

@@ -58,6 +58,34 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Waits for the condition.

+

#include <pthread.h>

+ +

int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *shared);

+ +

Gets condition variable properties, currently only PTHREAD_PROCESS_PRIVATE condition variable properties are supported.

+ + +

#include <pthread.h>

+ +

int pthread_condattr_setpshared(pthread_condattr_t *attr, int shared);

+ +

Set the condition variable properties.

+ + +

#include <pthread.h>

+ +

int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock);

+ +

Get thread clock.

+ + +

#include <pthread.h>

+ +

int pthread_condattr_destroy(pthread_condattr_t *attr);

+ +

Destroy the condition variable attribute.

+ +

#include <pthread.h>

int pthread_condattr_init(pthread_condattr_t *attr);

@@ -109,6 +137,62 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

#include <pthread.h>

+

int pthread_setschedprio(pthread_t thread, int prio);

+ +

Set the thread priority.

+ + +

#include <pthread.h>

+ +

int pthread_once(pthread_once_t *onceControl, void (*initRoutine)(void));

+ +

One-off operation task.

+ + +

#include <pthread.h>

+ +

int pthread_setcancelstate(int state, int *oldState);

+ +

Switch of the thread Cancel function.

+ + +

#include <pthread.h>

+ +

int pthread_setcanceltype(int type, int *oldType);

+ +

Set the thread cancel type.

+ + +

#include <pthread.h>

+ +

int pthread_cancel(pthread_t thread);

+ +

To cancel a thread, you can only set the PTHREAD_CANCEL_ASYNCHRONOUS state and then call pthread_cancel to cancel the thread.

+ + +

#include <pthread.h>

+ +

void pthread_testcancel(void);

+ +

Cancel a thread.

+ + +

#include <pthread.h>

+ +

int pthread_equal(pthread_t thread1, pthread_t thread2);

+ +

Check whether it is the same thread.

+ + +

#include <pthread.h>

+ +

int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *outType);

+ +

Gets the mutex type attribute.

+ + +

#include <pthread.h>

+

int pthread_mutex_init(pthread_mutex_t *__restrict m, const pthread_mutexattr_t *__restrict a);

Initializes a mutex.

@@ -121,6 +205,13 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Locks a mutex.

+

#include <pthread.h>

+ +

int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTimeout);

+ +

Attempts to lock a mutex(at the given time).

+ +

#include <pthread.h>

int pthread_mutex_trylock(pthread_mutex_t *m);

@@ -163,6 +254,20 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Sets the stack size for a thread attribute object.

+

#include <pthread.h>

+ +

int pthread_attr_setstack(pthread_attr_t *attr, void *stackAddr, size_t stackSize);

+ +

Set the stack properties of the thread properties object. (not implemented yet)

+ + +

#include <pthread.h>

+ +

int pthread_attr_getstack(const pthread_attr_t *attr, void **stackAddr, size_t *stackSize);

+ +

Get stack of thread property objects. (not implemented yet)

+ +

#include <pthread.h>

int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);

@@ -335,7 +440,7 @@ name="p157951148105019">#include <fcntl.h&

Obtains the file system information of a file in the specified path.

-

time

+

time

#include <sys/time.h>

@@ -393,6 +498,13 @@ name="p157951148105019">#include <fcntl.h&

Obtains the thread time.

+

#include <sys/times.h>

+ +

int timer_getoverrun(timer_t timerID);

+ +

Gets the softtimer timeout count.

+ +

#include <unistd.h>

int usleep(useconds_t usec);

@@ -1005,7 +1117,7 @@ name="p157951148105019">#include <fcntl.h&

Releases the memory space to which the PTR pointer points.

-

IPC

+

IPC

#include <semaphore.h>

@@ -1021,6 +1133,13 @@ name="p157951148105019">#include <fcntl.h&

Destroys a specified anonymous semaphore.

+

#include <semaphore.h>

+ +

int sem_trywait(sem_t *sem);

+ +

try to request a semaphore.

+ +

#include <semaphore.h>

int sem_init(sem_t *sem, int pshared, unsigned int value);

diff --git a/en/device-dev/kernel/kernel-mini-basic-interrupt-guide.md b/en/device-dev/kernel/kernel-mini-basic-interrupt-guide.md index e92a43816c4..41b4142e86b 100644 --- a/en/device-dev/kernel/kernel-mini-basic-interrupt-guide.md +++ b/en/device-dev/kernel/kernel-mini-basic-interrupt-guide.md @@ -19,12 +19,12 @@ The following table describes APIs available for the OpenHarmony LiteOS-M interr

Creating or deleting interrupts

-

HalHwiCreate

+

LOS_HwiCreate

Creates an interrupt and registers the interrupt ID, interrupt triggering mode, interrupt priority, and interrupt handler. When an interrupt is triggered, the interrupt handler will be called.

-

HalHwiDelete

+

LOS_HwiDelete

Deletes an interrupt based on the specified interrupt ID.

@@ -46,14 +46,47 @@ The following table describes APIs available for the OpenHarmony LiteOS-M interr

Restores the interrupt status before the LOS_IntLock and LOS_IntUnLock operations are performed.

+

Enabling and disabling a specified interrupt

+ +

LOS_HwiDisable

+ +

Disables an interrupt by configuring the register to prevent the CPU from responding to the interrupt.

+ + +

LOS_HwiEnable

+ +

Enables an interrupt by configuring the register to allow the CPU to respond to the interrupt.

+ + +

Setting interrupt priorities

+ +

LOS_HwiSetPriority

+ +

Sets the interrupt priority.

+ + +

Triggering interrupts

+ +

LOS_HwiTrigger

+ +

Triggers an interrupt by writing data into the related register of the interrupt controller to simulate an external interrupt.

+ + +

Clearing the status of the interrupt register

+ +

LOS_HwiClear

+ +

Clears the status bit of the interrupt register corresponding to the interrupt number. This API depends on the interrupt controller version and is optional.

+ + ## How to Develop -1. Create an interrupt by calling **HalHwiCreate**. -2. Call **TestHwiTrigger** to trigger the specified interrupt. \(This API is defined in the test suite. It simulates an external interrupt by writing the related register of the interrupt controller. Skip this step for common peripheral devices.\) -3. Call **HalHwiDelete** to delete the specified interrupt. Use this API based on actual requirements. +1. Create an interrupt by calling **LOS_HwiCreate**. +2. Trgger an interrupt by calling **LOS_HwiTrigger**. +3. Call **LOS_HwiDelete** to delete the specified interrupt. Use this API based on actual requirements. >![](../public_sys-resources/icon-note.gif) **NOTE:** >- Configure the maximum number of interrupts supported and the number of configurable interrupt priorities based on the specific hardware. @@ -90,7 +123,7 @@ static UINT32 Example_Interrupt(VOID) HWI_ARG_T arg = 0; /* Create an interrupt. */ - ret = HalHwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); + ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); if(ret == LOS_OK){ printf("Hwi create success!\n"); } else { @@ -98,11 +131,17 @@ static UINT32 Example_Interrupt(VOID) return LOS_NOK; } - /* Delay 50 ticks. When a hardware interrupt occurs, the HwiUsrIrq function will be called.*/ - LOS_TaskDelay(50); + /* Trigger an interrupt. */ + ret = LOS_HwiTrigger(HWI_NUM_TEST); + if(ret == LOS_OK){ + printf("Hwi trigger success!\n"); + } else { + printf("Hwi trigger failed!\n"); + return LOS_NOK; + } /* Delete an interrupt./ - ret = HalHwiDelete(HWI_NUM_TEST); + ret = LOS_HwiDelete(HWI_NUM_TEST); if(ret == LOS_OK){ printf("Hwi delete success!\n"); } else { @@ -119,6 +158,8 @@ The development is successful if the return result is as follows: ``` Hwi create success! +in the func HwiUsrIrq +Hwi trigger success! Hwi delete success! ``` diff --git a/en/device-dev/kernel/kernel-mini-basic-task-guide.md b/en/device-dev/kernel/kernel-mini-basic-task-guide.md index 8b7cee64870..152d6341712 100644 --- a/en/device-dev/kernel/kernel-mini-basic-task-guide.md +++ b/en/device-dev/kernel/kernel-mini-basic-task-guide.md @@ -144,6 +144,14 @@ The following table describes APIs available for the OpenHarmony LiteOS-M task m

Obtains task switching information. The macro LOSCFG_BASE_CORE_EXC_TSK_SWITCH must be enabled.

+

Task stack resource reclamation +

+ +

LOS_TaskResRecycle

+ +

Reclaims all possible task stack resources.

+ + diff --git a/en/device-dev/kernel/kernel-mini-basic-time-guide.md b/en/device-dev/kernel/kernel-mini-basic-time-guide.md index 3041a875764..e816ed7e721 100644 --- a/en/device-dev/kernel/kernel-mini-basic-time-guide.md +++ b/en/device-dev/kernel/kernel-mini-basic-time-guide.md @@ -39,7 +39,7 @@ The following table describes APIs available for the OpenHarmony LiteOS-M time m

Converts cycles into microseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.

-

Time statistics

+

Time statistics

LOS_SysClockGet

@@ -56,6 +56,23 @@ The following table describes APIs available for the OpenHarmony LiteOS-M time m

Obtains the number of cycles for each tick.

+

LOS_CurrNanosec

+ +

Gets the number of nanoseconds since the system was started.

+ + +

Delay management

+ +

LOS_Udelay

+ +

Busy waiting in μs. Resources can be preempted by another task with a higher priority.

+ + +

LOS_Mdelay

+ +

Busy waiting in ms. Resources can be preempted by another task with a higher priority.

+ + diff --git a/zh-cn/device-dev/faqs/faqs-kernel.md b/zh-cn/device-dev/faqs/faqs-kernel.md index 42b541cfc09..28c3fe078d0 100644 --- a/zh-cn/device-dev/faqs/faqs-kernel.md +++ b/zh-cn/device-dev/faqs/faqs-kernel.md @@ -52,7 +52,7 @@ Hi3516开源板使用FAT文件系统,不允许该操作。 ### LiteOS内核已支持哪几款芯片架构 -LiteOS-M已支持risc-v、Cortex-m3\\m4\\m7\\m33、arm9,待支持c-sky、xtensa;LiteOS-A已支持armv7-a,待支持armv8-a,请关注开源社区更新。 +LiteOS-M已支持risc-v、Cortex-m3\\m4\\m7\\m33、arm9、c-sky、xtensa;LiteOS-A已支持armv7-a,待支持armv8-a,请关注开源社区更新。 ## 三方组件 diff --git a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md index fb77b086298..2a5af2ac247 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md +++ b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md @@ -99,7 +99,7 @@ CMSIS-RTOS v2提供下面几种功能,接口详细信息可以查看API参考

osThreadDetach

-

分离线程(线程终止时可以回收线程存储)。(暂未实现)

+

分离线程(线程终止时可以回收线程存储)。

osThreadEnumerate

@@ -149,7 +149,7 @@ CMSIS-RTOS v2提供下面几种功能,接口详细信息可以查看API参考

osThreadJoin

-

等待指定线程终止。(暂未实现)

+

等待指定线程终止。

osThreadNew

@@ -186,22 +186,22 @@ CMSIS-RTOS v2提供下面几种功能,接口详细信息可以查看API参考

osThreadFlagsSet

-

设置线程的指定线程标志。(暂未实现)

+

设置线程的指定线程标志。

osThreadFlagsClear

-

清除当前正在运行的线程的指定线程标志。(暂未实现)

+

清除当前正在运行的线程的指定线程标志。

osThreadFlagsGet

-

获取当前正在运行的线程的当前线程标志。(暂未实现)

+

获取当前正在运行的线程的当前线程标志。

osThreadFlagsWait

-

等待当前正在运行的线程的一个或多个线程标志发出信号。(暂未实现)

+

等待当前正在运行的线程的一个或多个线程标志发出信号。

事件标志

diff --git a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md index 43b959bb94f..2e75fd5fa9b 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md +++ b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md @@ -28,7 +28,7 @@ OpenHarmony内核使用**musl libc**库以及自研接口,支持部分标准PO -

process

+

process

#include <stdlib.h>

@@ -60,6 +60,34 @@ OpenHarmony内核使用**musl libc**库以及自研接口,支持部分标准PO

#include <pthread.h>

+

int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *shared);

+ +

获取条件变量属性,目前只支持获取PTHREAD_PROCESS_PRIVATE条件变量属性

+ + +

#include <pthread.h>

+ +

int pthread_condattr_setpshared(pthread_condattr_t *attr, int shared);

+ +

设置条件变量属性

+ + +

#include <pthread.h>

+ +

int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock);

+ +

获取线程时钟

+ + +

#include <pthread.h>

+ +

int pthread_condattr_destroy(pthread_condattr_t *attr);

+ +

删除存储并使属性对象无效

+ + +

#include <pthread.h>

+

int pthread_cond_timedwait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime);

等待条件

@@ -116,6 +144,62 @@ OpenHarmony内核使用**musl libc**库以及自研接口,支持部分标准PO

#include <pthread.h>

+

int pthread_setschedprio(pthread_t thread, int prio);

+ +

设置线程优先级

+ + +

#include <pthread.h>

+ +

int pthread_once(pthread_once_t *onceControl, void (*initRoutine)(void));

+ +

一次性操作任务

+ + +

#include <pthread.h>

+ +

int pthread_setcancelstate(int state, int *oldState);

+ +

线程cancel功能开关

+ + +

#include <pthread.h>

+ +

int pthread_setcanceltype(int type, int *oldType);

+ +

设置线程cancel类型

+ + +

#include <pthread.h>

+ +

int pthread_cancel(pthread_t thread);

+ +

取消线程,目前仅支持先设置PTHREAD_CANCEL_ASYNCHRONOUS状态,再调用pthread_cancel取消线程

+ + +

#include <pthread.h>

+ +

void pthread_testcancel(void);

+ +

cancel线程

+ + +

#include <pthread.h>

+ +

int pthread_equal(pthread_t thread1, pthread_t thread2);

+ +

判断是否为同一线程

+ + +

#include <pthread.h>

+ +

int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *outType);

+ +

获取互斥锁的类型属性

+ + +

#include <pthread.h>

+

int pthread_mutex_init(pthread_mutex_t *__restrict m, const pthread_mutexattr_t *__restrict a);

初始化互斥锁

@@ -128,6 +212,13 @@ OpenHarmony内核使用**musl libc**库以及自研接口,支持部分标准PO

互斥锁加锁操作

+

#include <pthread.h>

+ +

int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTimeout);

+ +

申请互斥锁(只在设定时间内阻塞)

+ +

#include <pthread.h>

int pthread_mutex_trylock(pthread_mutex_t *m);

@@ -170,6 +261,20 @@ OpenHarmony内核使用**musl libc**库以及自研接口,支持部分标准PO

设置线程属性对象的堆栈大小

+

#include <pthread.h>

+ +

int pthread_attr_setstack(pthread_attr_t *attr, void *stackAddr, size_t stackSize);

+ +

设置线程属性对象的堆栈属性(暂未实现)

+ + +

#include <pthread.h>

+ +

int pthread_attr_getstack(const pthread_attr_t *attr, void **stackAddr, size_t *stackSize);

+ +

获取线程属性对象的堆栈(暂未实现)

+ +

#include <pthread.h>

int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);

@@ -342,7 +447,7 @@ name="p157951148105019">#include <fcntl.h&

获取指定路径下文件的文件系统信息

-

time

+

time

#include <sys/time.h>

@@ -400,6 +505,13 @@ name="p157951148105019">#include <fcntl.h&

获取线程时间

+

#include <sys/times.h>

+ +

int timer_getoverrun(timer_t timerID);

+ +

获取定时器超时次数

+ +

#include <unistd.h>

int usleep(useconds_t usec);

@@ -1012,7 +1124,7 @@ name="p157951148105019">#include <fcntl.h&

释放ptr所指向的内存空间

-

IPC

+

IPC

#include <semaphore.h>

@@ -1028,6 +1140,13 @@ name="p157951148105019">#include <fcntl.h&

销毁指定的无名信号量

+

#include <semaphore.h>

+ +

int sem_trywait(sem_t *sem);

+ +

尝试申请一个信号量

+ +

#include <semaphore.h>

int sem_init(sem_t *sem, int pshared, unsigned int value);

diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt-guide.md b/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt-guide.md index 83841bb53c7..8aa8a1699e2 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt-guide.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt-guide.md @@ -25,12 +25,12 @@ OpenHarmony LiteOS-M内核的中断模块提供下面几种功能,接口详细

创建、删除中断

-

HalHwiCreate

+

LOS_HwiCreate

中断创建,注册中断号、中断触发模式、中断优先级、中断处理程序。中断被触发时,会调用该中断处理程序。

-

HalHwiDelete

+

LOS_HwiDelete

根据指定的中断号,删除中断。

@@ -52,14 +52,47 @@ OpenHarmony LiteOS-M内核的中断模块提供下面几种功能,接口详细

恢复到使用LOS_IntLock、LOS_IntUnLock操作之前的中断状态。

+

使能和屏蔽指定中断

+ +

LOS_HwiDisable

+ +

中断屏蔽(通过设置寄存器,禁止CPU响应该中断)

+ + +

LOS_HwiEnable

+ +

中断使能(通过设置寄存器,允许CPU响应该中断)

+ + +

设置中断优先级

+ +

LOS_HwiSetPriority

+ +

设置中断优先级

+ + +

触发中断

+ +

LOS_HwiTrigger

+ +

触发中断(通过写中断控制器的相关寄存器模拟外部中断)

+ + +

清除中断寄存器状态

+ +

LOS_HwiClear

+ +

清除中断号对应的中断寄存器的状态位,此接口依赖中断控制器版本,非必需

+ + ## 开发流程 -1. 调用中断创建接口HalHwiCreate创建中断。 -2. 调用TestHwiTrigger接口触发指定中断(该接口在测试套中定义,通过写中断控制器的相关寄存器模拟外部中断,一般的外设设备,不需要执行这一步)。 -3. 调用HalHwiDelete接口删除指定中断,此接口根据实际情况使用,判断是否需要删除中断。 +1. 调用中断创建接口LOS_HwiCreate创建中断。 +2. 调用中断触发接口LOS_HwiTrigger触发中断。 +3. 调用LOS_HwiDelete接口删除指定中断,此接口根据实际情况使用,判断是否需要删除中断。 >![](../public_sys-resources/icon-note.gif) **说明:** >- 根据具体硬件,配置支持的最大中断数及可设置的中断优先级个数。 @@ -96,7 +129,7 @@ static UINT32 Example_Interrupt(VOID) HWI_ARG_T arg = 0; /*创建中断*/ - ret = HalHwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); + ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); if(ret == LOS_OK){ printf("Hwi create success!\n"); } else { @@ -104,11 +137,17 @@ static UINT32 Example_Interrupt(VOID) return LOS_NOK; } - /* 延时50个Ticks, 当有硬件中断发生时,会调用函数HwiUsrIrq*/ - LOS_TaskDelay(50); + /*触发中断*/ + ret = LOS_HwiTrigger(HWI_NUM_TEST); + if(ret == LOS_OK){ + printf("Hwi trigger success!\n"); + } else { + printf("Hwi trigger failed!\n"); + return LOS_NOK; + } /*删除中断*/ - ret = HalHwiDelete(HWI_NUM_TEST); + ret = LOS_HwiDelete(HWI_NUM_TEST); if(ret == LOS_OK){ printf("Hwi delete success!\n"); } else { @@ -125,6 +164,8 @@ static UINT32 Example_Interrupt(VOID) ``` Hwi create success! +in the func HwiUsrIrq +Hwi trigger success! Hwi delete success! ``` diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-task-guide.md b/zh-cn/device-dev/kernel/kernel-mini-basic-task-guide.md index 29b1538d8b4..41296ef46c3 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-task-guide.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-task-guide.md @@ -160,6 +160,14 @@ OpenHarmony LiteOS-M内核的任务管理模块提供下面几种功能,接口

获取任务切换信息,需要开启宏LOSCFG_BASE_CORE_EXC_TSK_SWITCH。

+

回收任务栈资源

+ +

LOS_TaskResRecycle

+ +

回收所有待回收的任务栈资源 +

+ + diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-time-guide.md b/zh-cn/device-dev/kernel/kernel-mini-basic-time-guide.md index f987de07807..fc177b2bd8a 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-time-guide.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-time-guide.md @@ -47,7 +47,7 @@ OpenHarmony LiteOS-M内核的时间管理提供下面几种功能,接口详细

Cycle数目转化为微秒,使用2个UINT32类型的数值分别表示结果数值的高、低32位。

-

时间统计

+

时间统计

LOS_SysClockGet

@@ -64,6 +64,23 @@ OpenHarmony LiteOS-M内核的时间管理提供下面几种功能,接口详细

获取每个Tick多少Cycle数

+

LOS_CurrNanosec

+ +

获取自系统启动以来的纳秒数

+ + +

延时管理

+ +

LOS_UDelay

+ +

以us为单位的忙等,但可以被优先级更高的任务抢占

+ + +

LOS_MDelay

+ +

以ms为单位的忙等,但可以被优先级更高的任务抢占

+ + -- Gitee