ISSDK  1.7
IoT Sensing Software Development Kit
gpio_driver.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2017, Freescale Semiconductor, Inc.
4  * Copyright 2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36  * @file gpio_driver.h
37  * @brief The gpio_driver.h file containes the Generic Irq implmentation for the gpio.
38  * The type and variable names have been kept aligned to Kinetis family for compatibility of examples.
39 */
40 
41 #ifndef __DRIVER_GPIO_H__
42 #define __DRIVER_GPIO_H__
43 
44 #include "Driver_Common.h"
45 #include "Driver_GPIO.h"
46 #include "fsl_common.h"
47 #include "fsl_gpio.h"
48 #include "fsl_gint.h"
49 
50 typedef enum _gint_interrupt
51 {
52  kGINT_InterruptLogic_0 = 0x0U, /*!< Interrupt on Logic 0 (Falling Edge or Level Low). */
53  kGINT_InterruptLogic_1 = 0x1U, /*!< Interrupt on Logic 1 (Rising Edge or Level High). */
55 
56 /*!
57  * @brief The GPIO Configuration KSDK.
58  */
59 typedef struct gpioConfigKSDK
60 {
61  gpio_pin_config_t pinConfig; /*!< General pin charactertics.*/
62  gint_trig_t interruptMode; /*!< Interrupt mode for a pin.*/
63  gint_interrupt_t interruptPolarity; /*!< Interrupt Polarity 0/1 for a pin.*/
65 
66 /*!
67  * @brief The GPIO pin handle for KSDK.
68  */
69 typedef struct gpioHandleKSDK
70 {
71  GPIO_Type *base; /*!< Base address of the GPIO Port.*/
72  uint32_t pinNumber; /*!< pin number start from 0 -31.*/
73  uint32_t mask; /*!< mask value for a pin.*/
74  clock_ip_name_t clockName; /*!< Clock Name for the port.*/
75  gint_port_t portNumber; /*!< Port Number for the port.*/
77 
78 /*!
79  * @brief The gpio isr object.
80  */
81 typedef struct gpioIsrObj
82 {
83  void *pUserData; /*!< Pointer to a UserData.*/
84  gpio_isr_handler_t isrHandle; /*!< pointer to isrHandle.*/
85 } gpioIsrObj_t;
86 
87 /*!
88  * @brief Macro to create a Gpio handle
89  */
90 #define MAKE_GPIO_HANDLE(PortName, Base, PinNumber, ClockName, PortNumber) \
91  static gpioHandleKSDK_t PortName##PinNumber = {.base = Base, \
92  .pinNumber = PinNumber, \
93  .mask = 1 << (PinNumber), \
94  .clockName = ClockName, \
95  .portNumber = PortNumber};
96 
97 #define GPIO_PIN_ID(PortName, PinNumber) &(PortName##PinNumber)
99 
100 #endif // __DRIVER_GPIO_H__
enum _gint_interrupt gint_interrupt_t
The GPIO pin handle for KSDK.
Definition: gpio_driver.h:75
The GPIO Configuration KSDK.
Definition: gpio_driver.h:65
void(* gpio_isr_handler_t)(void *apUserData)
Definition: Driver_GPIO.h:60
gint_trig_t interruptMode
Definition: gpio_driver.h:62
struct gpioHandleKSDK gpioHandleKSDK_t
The GPIO pin handle for KSDK.
gpio_pin_config_t pinConfig
Definition: gpio_driver.h:67
The gpio isr object.
Definition: gpio_driver.h:88
_gint_interrupt
Definition: gpio_driver.h:50
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:64
gint_interrupt_t interruptPolarity
Definition: gpio_driver.h:63
struct gpioConfigKSDK gpioConfigKSDK_t
The GPIO Configuration KSDK.
gint_port_t portNumber
Definition: gpio_driver.h:75
The Driver_GPIO.h file contains the definitions for GPIO Driver direction.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:203
struct gpioIsrObj gpioIsrObj_t
The gpio isr object.