/* --------------------------------------------------------------------------- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: Driver Framework Header File * Create: 2021-06-08 * 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 drivers Drivers * @defgroup dpal_driverbase Driverbase * @ingroup drivers * */ #ifndef DPAL_DRIVERBASE_H #define DPAL_DRIVERBASE_H #include "string.h" #include "dpal_typedef.h" #include "dpal_driver.h" #include "dpal.h" #define DEVICE_LOCK(dev) (void)dpal_mux_pend((dev)->mutex, DPAL_WAIT_FOREVER) #define DEVICE_UNLOCK(dev) (void)dpal_mux_post((dev)->mutex) #define DRIVER_LOCK(drv) (void)dpal_mux_pend((drv)->mutex, DPAL_WAIT_FOREVER) #define DRIVER_UNLOCK(drv) (void)dpal_mux_post((drv)->mutex) #define PM_LOCK(lock) (void)dpal_mux_pend((lock), DPAL_WAIT_FOREVER) #define PM_UNLOCK(lock) (void)dpal_mux_post((lock)) #define DRIVER_BASE_LOCK(lock) (void)dpal_mux_pend((lock), DPAL_WAIT_FOREVER) #define DRIVER_BASE_UNLOCK(lock) (void)dpal_mux_post((lock)) /* errno */ /** * @ingroup los_driverbase * Task error code: Invalid input. * * Value: 0x02004110 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_INPUT_INVALID DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x10) /** * @ingroup los_driverbase * Task error code: Mutex failed. * * Value: 0x02004111 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_MUX_FAIL DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x11) /** * @ingroup los_driverbase * Task error code: Do match function failed. * * Value: 0x02004120 * * Solution: This error code is not in use temporarily. */ #define DPAL_ERRNO_DRIVER_DRIVER_MATCH_FAIL DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x20) /** * @ingroup los_driverbase * Task error code: Do probe function failed. * * Value: 0x02004121 * * Solution: This error code is not in use temporarily. */ #define DPAL_ERRNO_DRIVER_DRIVER_PROBE_FAIL DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x21) /** * @ingroup los_driverbase * Task error code: driver register twice. * * Value: 0x02004122 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_DRIVER_REGISTERED DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x22) /** * @ingroup los_driverbase * Task error code: Invalid input. * * Value: 0x02004123 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_DRIVER_NOTFOUND DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x23) /** * @ingroup los_driverbase * Task error code: Device already attach to driver. * * Value: 0x02004130 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_DEVICE_BOUNDED DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x30) /** * @ingroup los_driverbase * Task error code: Invalid input. * * Value: 0x02004131 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_DEVICE_INITIALFAIL DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x31) /** * @ingroup los_driverbase * Task error code: Device register twice. * * Value: 0x02004132 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_DEVICE_REGISTERED DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x32) /** * @ingroup los_driverbase * Task error code: Device busy. * * Value: 0x02004133 * * Solution: Check the Input. */ #define DPAL_ERRNO_DRIVER_DEVICE_BUSY DPAL_ERRNO_OS_ERROR(DPAL_MOD_DRIVER, 0x33) /* driver api */ /** * @ingroup los_driverbase * @brief register a new driver to the system. * * @par Description: *