/* * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved. * * 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" #include "los_sortlink_pri.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) /** * @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]. */ #define LOS_ERRNO_SWTMR_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x02) /** * @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. */ #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) /** * @ingroup los_swtmr * Software timer error code: Invalid software timer ID. * * Value: 0x02000305 * * Solution: Pass in a valid software timer ID. */ #define LOS_ERRNO_SWTMR_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x05) /** * @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) /** * @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) /** * @ingroup los_swtmr * Software timer error code: Invalid configured number of software timers. * * Value: 0x02000308 * * Solution: Re-configure the number of software timers. */ #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. */ #define LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM LOS_ERRNO_OS_ERROR(LOS_MOD_SWTMR, 0x0a) /** * @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 * This error code is not in use temporarily. */ #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) /** * @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 */ LOS_SWTMR_MODE_PERIOD, /**< Periodic software timer */ LOS_SWTMR_MODE_NO_SELFDELETE, /**< One-off software timer, but not self-delete */ LOS_SWTMR_MODE_OPP /**< After the one-off timer finishes timing, the periodic software timer is enabled. This mode is not supported temporarily. */ }; /** * @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 *