|
|
/* ---------------------------------------------------------------------------
|
|
|
* Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
|
|
|
* Description: Software Timer Manager HeadFile
|
|
|
* Author: Huawei LiteOS Team
|
|
|
* Create: 2013-01-01
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
* conditions and the following disclaimer.
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
* provided with the distribution.
|
|
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
|
|
* to endorse or promote products derived from this software without specific prior written
|
|
|
* permission.
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
* --------------------------------------------------------------------------- */
|
|
|
|
|
|
/**
|
|
|
* @defgroup los_swtmr Software timer
|
|
|
* @ingroup kernel
|
|
|
*/
|
|
|
|
|
|
#ifndef _LOS_SWTMR_H
|
|
|
#define _LOS_SWTMR_H
|
|
|
|
|
|
#include "los_base.h"
|
|
|
#include "los_task.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif /* __cplusplus */
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The timeout handling function is NULL.
|
|
|
*
|
|
|
* Value: 0x02000300.
|
|
|
*
|
|
|
* Solution: Define the timeout handling function.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x00)/**/
|
|
|
/*错误代码LOS_ERRNO_SWTMR_PTR_NULL表示软件定时器的超时处理函数为空。这意味着当定时器到期时,没有要执行的函数*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The expiration time is 0.
|
|
|
*
|
|
|
* Value: 0x02000301.
|
|
|
*
|
|
|
* Solution: Re-define the expiration time./*要解决此错误,您需要为软件定时器定义一个超时处理函数。该函数将在定时器到期时被调用,并执行所需的操作。
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x01)
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: Invalid software timer mode.
|
|
|
*
|
|
|
* Value: 0x02000302.
|
|
|
*
|
|
|
* Solution: Check the mode value. The value range is [0,3]./*要解决此错误,您需要重新定义定时器的到期时间。确保到期时间大于0,并且与您的需求相符。
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x02)
|
|
|
/*错误代码LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED表示定时器的到期时间为0。这意味着定时器的到期时间设置不合适*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The passed-in software timer ID is NULL.
|
|
|
*
|
|
|
* Value: 0x02000303.
|
|
|
*
|
|
|
* Solution: Define the software timer ID before passing it in.要解决此错误,您需要在传入函数之前定义软件定时器ID。确保为软件定时器分配一个有效的ID,并在使用该ID时进行传入。
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_RET_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x03)
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The number of software timers exceeds the configured permitted maximum number.
|
|
|
*
|
|
|
* Value: 0x02000304.
|
|
|
*
|
|
|
* Solution: Re-configure the permitted maximum number of software timers, or wait for a software timer to become
|
|
|
* available.要解决此错误,您可以重新配置允许的最大软件定时器数量
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_MAXSIZE LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x04)/
|
|
|
/*错误代码LOS_ERRNO_SWTMR_MAXSIZE表示软件定时器的数量超过了配置的允许最大数量。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: Invalid software timer ID.
|
|
|
*
|
|
|
* Value: 0x02000305.
|
|
|
*
|
|
|
* Solution: Pass in a valid software timer ID.解决方案:传入有效的软件计时器ID
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x05)
|
|
|
/*错误代码LOS_ERRNO_SWTMR_ID_INVALID表示软件计时器ID无效。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The software timer is not created.
|
|
|
*
|
|
|
* Value: 0x02000306.
|
|
|
*
|
|
|
* Solution: Create a software timer.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x06)
|
|
|
/*错误代码LOS_ERRNO_SWTMR_NOT_CREATED表示软件计时器未创建*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: Insufficient memory for software timer linked list creation.
|
|
|
*
|
|
|
* Value: 0x02000307.
|
|
|
*
|
|
|
* Solution: Allocate bigger memory partition to software timer linked list creation.
|
|
|
* 解决方案:为软件定时器链表创建分配更大的内存分区
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x07)
|
|
|
/*错误代码LOS_ERRNO_SWTMR_NO_MEMORY内存不足,无法创建软件计时器链表*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: Invalid configured number of software timers.
|
|
|
*
|
|
|
* Value: 0x02000308.
|
|
|
*
|
|
|
* Solution: Re-configure the number of software timers.解决方案:重新配置软件计时器的数量。
|
|
|
* @deprecated This error code is obsolete since LiteOS 5.0.0.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_MAXSIZE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x08)
|
|
|
/*软件计时器错误代码:配置的软件计时器数量无效*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The software timer is being used during an interrupt.
|
|
|
*
|
|
|
* Value: 0x02000309.
|
|
|
*
|
|
|
* Solution: Change the source code and do not use the software timer during an interrupt.
|
|
|
* 解决方案:更改源代码,在中断期间不要使用软件计时器
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_HWI_ACTIVE LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x09)
|
|
|
/*软件计时器错误代码:软件计时器在中断期间使用*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: Insufficient memory allocated by membox.
|
|
|
*
|
|
|
* Value: 0x0200030a.
|
|
|
*
|
|
|
* Solution: Expand the memory allocated by membox.解决方案:扩展membox分配的内存
|
|
|
* @deprecated This error code is obsolete since LiteOS 5.0.0.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0a)
|
|
|
/*软件计时器错误代码:membox分配的内存不足*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The software timer queue fails to be created.
|
|
|
*
|
|
|
* Value: 0x0200030b.
|
|
|
*
|
|
|
* Solution: Check whether more memory can be allocated to the queue to be created.解决方案:检查是否可以为要创建的队列分配更多内存
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0b)
|
|
|
/*软件计时器错误代码:无法创建软件计时器队列。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The software timer task fails to be created.
|
|
|
*
|
|
|
* Value: 0x0200030c.
|
|
|
*
|
|
|
* Solution: Check whether the memory is sufficient and re-create the task.解决方案:检查内存是否足够,然后重新创建任务。
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_TASK_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0c)
|
|
|
/*软件计时器错误代码:无法创建软件计时器任务。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The software timer is not started.
|
|
|
*
|
|
|
* Value: 0x0200030d.
|
|
|
*
|
|
|
* Solution: Start the software timer.解决方案:启动软件计时器
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_NOT_STARTED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0d)
|
|
|
/*软件计时器错误代码:软件计时器未启动*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: Invalid software timer state.
|
|
|
*
|
|
|
* Value: 0x0200030e.
|
|
|
*
|
|
|
* Solution: Check the software timer state.解决方案:检查软件计时器状态
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_STATUS_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0e)
|
|
|
/*软件计时器错误代码:软件计时器状态无效*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: This error code is not in use temporarily.
|
|
|
*
|
|
|
* Value: 0x0200030f
|
|
|
* @deprecated This error code is obsolete since LiteOS 5.0.0.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_SORTLIST_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0f)
|
|
|
/*软件计时器错误代码:此错误代码暂时未使用*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The passed-in number of remaining Ticks configured on the software timer is NULL.
|
|
|
*
|
|
|
* Value: 0x02000310.
|
|
|
*
|
|
|
* Solution: Define a variable of the number of remaining Ticks before passing in the number of remaining Ticks.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_TICK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x10)
|
|
|
/*软件计时器错误代码:软件计时器上配置的传入的剩余Tick数为NULL*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer error code: The software sortlink fails to be created.
|
|
|
*
|
|
|
* Value: 0x02000311.
|
|
|
*
|
|
|
* Solution: Check whether the memory is sufficient and re-create the sortlink.
|
|
|
*/
|
|
|
#define LOS_ERRNO_SWTMR_SORTLINK_CREATE_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x11)
|
|
|
/*软件计时器错误代码:无法创建软件排序链接。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* Software timer mode
|
|
|
*/
|
|
|
enum enSwTmrType {
|
|
|
LOS_SWTMR_MODE_ONCE, /**< One-off software timer, the value is 0. */
|
|
|
LOS_SWTMR_MODE_PERIOD, /**< Periodic software timer, the value is 1. */
|
|
|
LOS_SWTMR_MODE_NO_SELFDELETE, /**< One-off software timer, but not self-delete, the value is 2. */
|
|
|
LOS_SWTMR_MODE_OPP /**< After the one-off timer finishes timing, the
|
|
|
periodic software timer is enabled. The value
|
|
|
is 3. This mode is not supported temporarily. */
|
|
|
};
|
|
|
/*这段代码定义了软件定时器的模式,使用了一个枚举类型enSwTmrType来表示。其中包含以下几种模式:
|
|
|
LOS_SWTMR_MODE_ONCE:一次性软件定时器,值为0。
|
|
|
LOS_SWTMR_MODE_PERIOD:周期性软件定时器,值为1。
|
|
|
LOS_SWTMR_MODE_NO_SELFDELETE:一次性软件定时器,但不会自我删除,值为2。
|
|
|
LOS_SWTMR_MODE_OPP:在一次性定时器完成定时后,启用周期性软件定时器。该模式的值为3。目前暂不支持该模式*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* @brief Define the type of a callback function that handles software timer timeout.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to define the type of a callback function that handles software timer timeout,
|
|
|
* so that it can be called when software timer timeout.
|
|
|
*
|
|
|
* @attention
|
|
|
* None.
|
|
|
*
|
|
|
* @param arg [IN] the parameter of the callback function that handles software timer timeout.
|
|
|
*
|
|
|
* @retval None.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
*/
|
|
|
typedef VOID (*SWTMR_PROC_FUNC)(UINTPTR arg);
|
|
|
/*这段代码定义了一个回调函数类型SWTMR_PROC_FUNC,用于处理软件定时器超时事件。该回调函数在软件定时器超时时被调用*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* @brief Start a software timer.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to start a software timer that has a specified ID.
|
|
|
* @attention
|
|
|
* The specific timer must be created first.
|
|
|
*
|
|
|
* @param swtmrId [IN] Software timer ID created by LOS_SwtmrCreate. The value of ID should be in
|
|
|
* [0, LOSCFG_BASE_CORE_SWTMR_LIMIT - 1].
|
|
|
*
|
|
|
* @retval #LOS_ERRNO_SWTMR_ID_INVALID Invalid software timer ID.
|
|
|
* @retval #LOS_ERRNO_SWTMR_NOT_CREATED The software timer is not created.
|
|
|
* @retval #LOS_ERRNO_SWTMR_STATUS_INVALID Invalid software timer state.
|
|
|
* @retval #LOS_OK The software timer is successfully started.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_SwtmrStop | LOS_SwtmrCreate
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
*/
|
|
|
extern UINT32 LOS_SwtmrStart(UINT16 swtmrId);
|
|
|
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrStart的声明。它用于启动一个指定ID的软件定时器。
|
|
|
函数的返回值可能有以下几种情况:
|
|
|
LOS_ERRNO_SWTMR_ID_INVALID:无效的软件定时器ID。
|
|
|
LOS_ERRNO_SWTMR_NOT_CREATED:软件定时器未创建。
|
|
|
LOS_ERRNO_SWTMR_STATUS_INVALID:无效的软件定时器状态。
|
|
|
LOS_OK:成功启动软件定时器。*/
|
|
|
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* @brief Stop a software timer.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to stop a software timer that has a specified ID.
|
|
|
* @attention
|
|
|
* The specific timer should be created and started firstly.
|
|
|
*
|
|
|
* @param swtmrId [IN] Software timer ID created by LOS_SwtmrCreate. The value of ID should be in
|
|
|
* [0, LOSCFG_BASE_CORE_SWTMR_LIMIT - 1].
|
|
|
*
|
|
|
* @retval #LOS_ERRNO_SWTMR_ID_INVALID Invalid software timer ID.
|
|
|
* @retval #LOS_ERRNO_SWTMR_NOT_CREATED The software timer is not created.
|
|
|
* @retval #LOS_ERRNO_SWTMR_NOT_STARTED The software timer is not started.
|
|
|
* @retval #LOS_ERRNO_SWTMR_STATUS_INVALID Invalid software timer state.
|
|
|
* @retval #LOS_OK The software timer is successfully stopped.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_SwtmrStart | LOS_SwtmrCreate
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
*/
|
|
|
extern UINT32 LOS_SwtmrStop(UINT16 swtmrId);
|
|
|
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrStop的声明。它用于停止一个指定ID的软件定时器
|
|
|
函数的返回值可能有以下几种情况:
|
|
|
LOS_ERRNO_SWTMR_ID_INVALID:无效的软件定时器ID。
|
|
|
LOS_ERRNO_SWTMR_NOT_CREATED:未创建软件定时器。
|
|
|
LOS_ERRNO_SWTMR_NOT_STARTED:软件定时器未启动。
|
|
|
LOS_ERRNO_SWTMR_STATUS_INVALID:无效的软件定时器状态。
|
|
|
LOS_OK:成功停止软件定时器。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* @brief Obtain the number of remaining Ticks configured on a software timer.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to obtain the number of remaining Ticks configured on the software timer of which the ID is
|
|
|
* specified by usSwTmrID.
|
|
|
* @attention
|
|
|
* The specific timer should be created and started successfully, error happens otherwise.
|
|
|
*
|
|
|
* @param swtmrId [IN] Software timer ID created by LOS_SwtmrCreate. The value of ID should be in
|
|
|
* [0, LOSCFG_BASE_CORE_SWTMR_LIMIT - 1].
|
|
|
* @param tick [OUT] Number of remaining Ticks configured on the software timer.
|
|
|
*
|
|
|
* @retval #LOS_ERRNO_SWTMR_ID_INVALID Invalid software timer ID.
|
|
|
* @retval #LOS_ERRNO_SWTMR_TICK_PTR_NULL The input parameter tick is a NULL pointer.
|
|
|
* @retval #LOS_ERRNO_SWTMR_NOT_CREATED The software timer is not created.
|
|
|
* @retval #LOS_ERRNO_SWTMR_NOT_STARTED The software timer is not started.
|
|
|
* @retval #LOS_ERRNO_SWTMR_STATUS_INVALID Invalid software timer state.
|
|
|
* @retval #LOS_OK The number of remaining Ticks is successfully obtained.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_SwtmrCreate
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
*/
|
|
|
extern UINT32 LOS_SwtmrTimeGet(UINT16 swtmrId, UINT32 *tick);
|
|
|
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrTimeGet的声明。它用于获取指定ID的软件定时器配置的剩余Ticks数
|
|
|
函数的返回值可能有以下几种情况:
|
|
|
LOS_ERRNO_SWTMR_ID_INVALID:无效的软件定时器ID。
|
|
|
LOS_ERRNO_SWTMR_TICK_PTR_NULL:输入参数tick为NULL指针。
|
|
|
LOS_ERRNO_SWTMR_NOT_CREATED:未创建软件定时器。
|
|
|
LOS_ERRNO_SWTMR_NOT_STARTED:软件定时器未启动。
|
|
|
LOS_ERRNO_SWTMR_STATUS_INVALID:无效的软件定时器状态。
|
|
|
LOS_OK:成功获取剩余Ticks数。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* @brief Create a software timer.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to create a software timer that has specified timing duration, timeout handling function,
|
|
|
* and trigger mode, and to return a handle by which the software timer can be referenced.
|
|
|
* @attention
|
|
|
* <ul>
|
|
|
* <li>Do not use the delay interface in the callback function that handles software timer timeout.</li>
|
|
|
* <li>There are LOSCFG_BASE_CORE_SWTMR_LIMIT timers available, change it's value when necessary.</li>
|
|
|
* </ul>
|
|
|
*
|
|
|
* @param interval [IN] Timing duration of the software timer to be created (unit: tick).
|
|
|
* @param mode [IN] Software timer mode. Pass in one of the modes specified by enSwTmrType. There are three
|
|
|
* types of modes, one-off, periodic, and continuously periodic after one-off, of which
|
|
|
* the third mode is not supported temporarily.
|
|
|
* @param handler [IN] Callback function that handles software timer timeout.
|
|
|
* @param swtmrId [OUT] Software timer ID created by LOS_SwtmrCreate.
|
|
|
* @param arg [IN] Parameter passed in when the callback function that handles software timer timeout is
|
|
|
* called.
|
|
|
*
|
|
|
* @retval #LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED The software timer timeout interval is 0.
|
|
|
* @retval #LOS_ERRNO_SWTMR_MODE_INVALID Invalid software timer mode.
|
|
|
* @retval #LOS_ERRNO_SWTMR_PTR_NULL The callback function that handles software timer timeout is NULL.
|
|
|
* @retval #LOS_ERRNO_SWTMR_RET_PTR_NULL The passed-in software timer ID is NULL.
|
|
|
* @retval #LOS_ERRNO_SWTMR_MAXSIZE The number of software timers exceeds the configured permitted
|
|
|
* maximum number.
|
|
|
* @retval #LOS_OK The software timer is successfully created.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_SwtmrDelete
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
*/
|
|
|
extern UINT32 LOS_SwtmrCreate(UINT32 interval, UINT8 mode, SWTMR_PROC_FUNC handler, UINT16 *swtmrId, UINTPTR arg);
|
|
|
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrCreate的声明。它用于创建一个具有指定定时时长、超时处理函数和触发模式的软件定时器,并返回一个引用该软件定时器的句柄
|
|
|
函数的返回值可能有以下几种情况:
|
|
|
LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED:软件定时器超时间隔为0。
|
|
|
LOS_ERRNO_SWTMR_MODE_INVALID:无效的软件定时器触发模式。
|
|
|
LOS_ERRNO_SWTMR_PTR_NULL:处理软件定时器超时的回调函数为NULL。
|
|
|
LOS_ERRNO_SWTMR_RET_PTR_NULL:传入的软件定时器ID为NULL。
|
|
|
LOS_ERRNO_SWTMR_MAXSIZE:软件定时器数量超过配置的最大数量。
|
|
|
LOS_OK:成功创建软件定时器。*/
|
|
|
/**
|
|
|
* @ingroup los_swtmr
|
|
|
* @brief Delete a software timer.
|
|
|
*
|
|
|
* @par Description:
|
|
|
* This API is used to delete a software timer.
|
|
|
* @attention
|
|
|
* The specific timer should be created and then stopped firstly.
|
|
|
*
|
|
|
* @param swtmrId [IN] Software timer ID created by LOS_SwtmrCreate. The value of ID should be in
|
|
|
* [0, LOSCFG_BASE_CORE_SWTMR_LIMIT - 1].
|
|
|
*
|
|
|
* @retval #LOS_ERRNO_SWTMR_ID_INVALID Invalid software timer ID.
|
|
|
* @retval #LOS_ERRNO_SWTMR_NOT_CREATED The software timer is not created.
|
|
|
* @retval #LOS_ERRNO_SWTMR_STATUS_INVALID Invalid software timer state.
|
|
|
* @retval #LOS_OK The software timer is successfully deleted.
|
|
|
* @par Dependency:
|
|
|
* <ul><li>los_swtmr.h: the header file that contains the API declaration.</li></ul>
|
|
|
* @see LOS_SwtmrCreate
|
|
|
* @since Huawei LiteOS V100R001C00
|
|
|
*/
|
|
|
extern UINT32 LOS_SwtmrDelete(UINT16 swtmrId);
|
|
|
/*这段代码是一个软件定时器模块中的函数LOS_SwtmrDelete的声明。它用于删除一个软件定时器。
|
|
|
函数的返回值可能有以下几种情况:
|
|
|
LOS_ERRNO_SWTMR_ID_INVALID:无效的软件定时器ID。
|
|
|
LOS_ERRNO_SWTMR_NOT_CREATED:该软件定时器未被创建。
|
|
|
LOS_ERRNO_SWTMR_STATUS_INVALID:无效的软件定时器状态。
|
|
|
LOS_OK:成功删除软件定时器。*/
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif /* __cplusplus */
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
#endif /* _LOS_SWTMR_H */
|