• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  ****************************************************************************************
3  *
4  * @file    app_gpiote.h
5  * @author  BLE Driver Team
6  * @brief   Header file containing functions prototypes of GPIO Interrupt app library.
7  *
8  ****************************************************************************************
9  * @attention
10   #####Copyright (c) 2019 GOODIX
11   All rights reserved.
12 
13     Redistribution and use in source and binary forms, with or without
14     modification, are permitted provided that the following conditions are met:
15   * Redistributions of source code must retain the above copyright
16     notice, this list of conditions and the following disclaimer.
17   * Redistributions in binary form must reproduce the above copyright
18     notice, this list of conditions and the following disclaimer in the
19     documentation and/or other materials provided with the distribution.
20   * Neither the name of GOODIX nor the names of its contributors may be used
21     to endorse or promote products derived from this software without
22     specific prior written permission.
23 
24   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34   POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39   * @{
40   */
41 
42 /** @addtogroup APP_DRIVER APP DRIVER
43  *  @{
44  */
45 
46 /** @defgroup APP_GPIO_INTERRUPT GPIO INTERRUPT
47   * @brief GPIO INTERRUPT APP module driver.
48   * @{
49   */
50 
51 
52 #ifndef _APP_GPIOTE_H_
53 #define _APP_GPIOTE_H_
54 
55 #include "app_io.h"
56 #include "app_drv_error.h"
57 
58 /** @addtogroup APP_GPIO_INTERRUPT_STRUCTURES Structures
59   * @{
60   */
61 
62 /**
63   * @brief GPIO Interrupt event Structure definition
64   */
65 typedef struct {
66     app_io_type_t           type;       /**< Type of event. */
67     uint32_t                pin;        /**< Specifies the IO pins to be configured. */
68     app_ctx_type_t          ctx_type;   /**< Type of handler context. */
69 } app_gpiote_evt_t;
70 
71 /**
72   * @brief GPIOTE input event handler type.
73   */
74 typedef void (*app_gpiote_event_handler_t)(app_gpiote_evt_t *p_evt);
75 
76 /**
77   * @brief GPIOTE callback type.
78   */
79 typedef void (*app_io_callback_t)(app_gpiote_evt_t *p_evt);
80 
81 /**
82   * @brief GPIOTE Interrupt parameters structure definition
83   */
84 typedef struct {
85     app_io_type_t           type;           /**< Specifies IO type */
86     uint32_t                pin;            /**< Specifies the IO pins to be configured. */
87     app_io_mode_t           mode;           /**< Specifies the IO mode for the selected pins. */
88     app_io_pull_t           pull;           /**< Specifies the Pull-up or Pull-Down activation for the selected pins. */
89     app_handle_mode_t       handle_mode;    /**< Specifies the IO wakeup mode. */
90     app_io_callback_t       io_evt_cb;      /**< IO callback function. */
91 } app_gpiote_param_t;
92 
93 /** @} */
94 
95 /* Exported functions --------------------------------------------------------*/
96 /** @addtogroup APP_GPIOTE_DRIVER_FUNCTIONS Functions
97   * @{
98   */
99 
100 /**
101  ****************************************************************************************
102  * @brief  Initialize the APP GPIO Interrupt DRIVER according to the specified parameters
103  *         in the app_gpiote_param_t and app_gpiote_event_handler_t.
104  *
105  * @param[in]  p_params: Pointer to app_gpiote_param_t parameter which contains the
106  *                       configuration information for the specified GPIO.
107  * @param[in]  table_cnt: Used GPIO number.
108  *
109  * @return Result of initialization.
110  ****************************************************************************************
111  */
112 uint16_t app_gpiote_init(const app_gpiote_param_t *p_params, uint8_t table_cnt);
113 
114 /**
115  ****************************************************************************************
116  * @brief  De-initialize the APP GPIO Interrupt DRIVER peripheral.
117  *
118  ****************************************************************************************
119  */
120 void app_gpiote_deinit(void);
121 
122 /**
123  ****************************************************************************************
124  * @brief  Config the APP GPIO Interrupt DRIVER according to the specified parameters
125  *         in the app_gpiote_param_t.
126  *
127  * @param[in]  p_config: Pointer to app_gpiote_param_t parameter which contains the
128  *                       configuration information for the specified GPIO.
129  *
130  * @return Result of initialization.
131  ****************************************************************************************
132  */
133 uint16_t app_gpiote_config(const app_gpiote_param_t *p_config);
134 
135 
136 /** @} */
137 
138 #endif
139 
140 /** @} */
141 /** @} */
142 /** @} */
143