1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 #pragma once 16 #include <common/bk_include.h> 17 #include <driver/hal/hal_gpio_types.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * @brief GPIO APIs 25 * @addtogroup bk_api_gpio GPIO API group 26 * @{ 27 */ 28 29 /** 30 * @brief GPIO defines 31 * @defgroup bk_api_gpio_defs macos 32 * @ingroup bk_api_gpio 33 * @{ 34 */ 35 #define BK_ERR_GPIO_CHAN_ID (BK_ERR_GPIO_BASE - 1) /**< gpio channel number is invalid */ 36 #define BK_ERR_GPIO_INVALID_MODE (BK_ERR_GPIO_BASE - 2) /**< gpio mode is invalid */ 37 #define BK_ERR_GPIO_NOT_INPUT_MODE (BK_ERR_GPIO_BASE - 3) /**< gpio is not in input mode */ 38 #define BK_ERR_GPIO_SET_INVALID_FUNC_MODE (BK_ERR_GPIO_BASE - 4) /**< gpio perial mode is invalid or was be set as 2nd func*/ 39 #define BK_ERR_GPIO_INVALID_INT_TYPE (BK_ERR_GPIO_BASE - 5) /**< gpio int type is invalid*/ 40 #define BK_ERR_GPIOS_MAP_NONE (BK_ERR_GPIO_BASE - 6) /**< gpio map device is none*/ 41 #define BK_ERR_GPIO_NOT_OUTPUT_MODE (BK_ERR_GPIO_BASE - 7) /**< gpio is not in output mode */ 42 #define BK_ERR_GPIO_BITS_NUM (BK_ERR_GPIO_BASE - 8) /**< gpio map bit num is error */ 43 #define BK_ERR_GPIO_INTERNAL_USED (BK_ERR_GPIO_BASE - 9) /**< gpio map was be map to a device */ 44 #define BK_ERR_GPIO_MAP_PWMS_CHAN (BK_ERR_GPIO_BASE - 10) /**< gpio map to pwm pwms' channel is invalid*/ 45 #define BK_ERR_GPIO_INVALID_ID (BK_ERR_GPIO_BASE - 11) /**< gpio id is invalid */ 46 #define BK_ERR_GPIO_WAKESOURCE_OVER_MAX_CNT (BK_ERR_GPIO_BASE - 12) /**< too much GPIO is register to wakeup source */ 47 48 /** 49 * @brief GPIO interrupt service routine 50 */ 51 typedef void (*gpio_isr_t)(gpio_id_t gpio_id); 52 53 /** 54 * @} 55 */ 56 57 /** 58 * @} 59 */ 60 61 #ifdef __cplusplus 62 } 63 #endif 64