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 2017 NXP
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without modification,
7  * are permitted (subject to the limitations in the disclaimer below) provided
8  * that the following conditions are met:
9  *
10  * o Redistributions of source code must retain the above copyright notice, this list
11  * of conditions and the following disclaimer.
12  *
13  * o Redistributions in binary form must reproduce the above copyright notice, this
14  * list of conditions and the following disclaimer in the documentation and/or
15  * other materials provided with the distribution.
16  *
17  * o Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /**
35  * @file gpio_driver.h
36  * @brief The gpio_driver.h file containes the Generic Irq implmentation for the i.MXRT1050 gpio.
37 */
38 
39 #ifndef __DRIVER_GPIO_H__
40 #define __DRIVER_GPIO_H__
41 
42 #include "Driver_Common.h"
43 #include "Driver_GPIO.h"
44 #include "fsl_common.h"
45 #include "fsl_gpio.h"
46 
47 #define PIN_SET 1U
48 #define PIN_CLR 0U
49 
50 /**
51 \brief GPIO PORT NAMES.
52 */
53 typedef enum port_number
54 {
55  GPIO1_NUM = 0,
56  GPIO2_NUM = 1,
57  GPIO3_NUM = 2,
58  GPIO4_NUM = 3,
59  GPIO5_NUM = 4,
62 
63 /*!
64  * @brief The GPIO Pin Configuration i.MX SDK.
65  */
66 typedef struct gpioConfigiMXSDK
67 {
68  gpio_pin_config_t pinConfig; /*!< General pin charactertics.*/
69  gpio_interrupt_mode_t interruptMode; /*!< Interrupt mode for a pin.*/
71 
72 /*!
73  * @brief The GPIO pin handle for i.MX SDK.
74  */
75 typedef struct gpioHandleiMXSDK
76 {
77  GPIO_Type *base; /*!< Base address of the GPIO Port.*/
78  uint32_t pinNumber; /*!< pin number start from 0 -31.*/
79  uint32_t mask; /*!< mask value for a pin.*/
80  IRQn_Type irq; /*!< IRQ Number for the port.*/
81  port_number_t portNumber; /*!< Port Number for the port.*/
82  uint8_t pinStatus; /*!< pin status.*/
84 
85 /*!
86  * @brief The gpio isr object.
87  */
88 typedef struct gpioIsrObj
89 {
90  void *pUserData; /*!< Pointer to a UserData.*/
91  gpio_isr_handler_t isrHandle; /*!< pointer to isrHandle.*/
92 } gpioIsrObj_t;
93 
94 /*!
95  * @brief Macro to create a Gpio handle
96  */
97 #define MAKE_GPIO_HANDLE(Base, PinNumber, Irq) \
98  static gpioHandleKSDK_t PortName##PinNumber = {.base = Base, \
99  .pinNumber = PinNumber, \
100  .irq = Irq};
102 
103 #endif // __DRIVER_GPIO_H__
gpio_pin_config_t pinConfig
Definition: gpio_driver.h:68
enum port_number port_number_t
GPIO PORT NAMES.
void(* gpio_isr_handler_t)(void *apUserData)
Definition: Driver_GPIO.h:60
The GPIO Pin Configuration i.MX SDK.
Definition: gpio_driver.h:66
The GPIO pin handle for i.MX SDK.
Definition: gpio_driver.h:75
gpio_interrupt_mode_t interruptMode
Definition: gpio_driver.h:69
struct gpioHandleiMXSDK gpioHandleiMXSDK_t
The GPIO pin handle for i.MX SDK.
port_number
GPIO PORT NAMES.
Definition: gpio_driver.h:53
The gpio isr object.
Definition: gpio_driver.h:88
uint8_t pinStatus
Definition: gpio_driver.h:82
void * pUserData
Definition: gpio_driver.h:90
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:64
gpio_isr_handler_t isrHandle
Definition: gpio_driver.h:91
uint32_t pinNumber
Definition: gpio_driver.h:78
port_number_t portNumber
Definition: gpio_driver.h:81
GPIO_Type * base
Definition: gpio_driver.h:77
IRQn_Type irq
Definition: gpio_driver.h:80
The Driver_GPIO.h file contains the definitions for GPIO Driver direction.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:203
struct gpioConfigiMXSDK gpioConfigiMXSDK_t
The GPIO Pin Configuration i.MX SDK.
struct gpioIsrObj gpioIsrObj_t
The gpio isr object.