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) 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-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 */
39 
40 #ifndef __DRIVER_GPIO_H__
41 #define __DRIVER_GPIO_H__
42 
43 #include "Driver_Common.h"
44 #include "Driver_GPIO.h"
45 #include "fsl_common.h"
46 #include "fsl_gpio.h"
47 #include "fsl_port.h"
48 
49 /**
50 \brief GPIO PORT NAMES.
51 */
52 typedef enum port_number
53 {
54  PORTA_NUM = 0,
55  PORTB_NUM = 1,
56  PORTC_NUM = 2,
57  PORTD_NUM = 3,
58  PORTE_NUM = 4,
61 
62 /*!
63  * @brief The GPIO Configuration KSDK.
64  */
65 typedef struct gpioConfigKSDK
66 {
67  gpio_pin_config_t pinConfig; /*!< General pin charactertics.*/
68  port_pin_config_t portPinConfig; /*!< port pin configuration.*/
69  port_interrupt_t interruptMode; /*!< Interrupt mode for a pin.*/
71 
72 /*!
73  * @brief The GPIO pin handle for KSDK.
74  */
75 typedef struct gpioHandleKSDK
76 {
77  GPIO_Type *base; /*!< Base address of the GPIO Port.*/
78  PORT_Type *portBase; /*!< Base address of the GPIO Port.*/
79  uint32_t pinNumber; /*!< pin number start from 0 -31.*/
80  uint32_t mask; /*!< mask value for a pin.*/
81  IRQn_Type irq; /*!< IRQ Number for the port.*/
82  clock_ip_name_t clockName; /*!< Clock Name for the port.*/
83  port_number_t portNumber; /*!< Port Number for the port.*/
85 
86 /*!
87  * @brief The gpio isr object.
88  */
89 typedef struct gpioIsrObj
90 {
91  void *pUserData; /*!< Pointer to a UserData.*/
92  gpio_isr_handler_t isrHandle; /*!< pointer to isrHandle.*/
93 } gpioIsrObj_t;
94 
95 /*!
96  * @brief Macro to create a Gpio handle
97  */
98 #define MAKE_GPIO_HANDLE(PortName, Base, PortBase, PinNumber, Irq, ClockName, PortNumber) \
99  static gpioHandleKSDK_t PortName##PinNumber = {.base = Base, \
100  .portBase = PortBase, \
101  .pinNumber = PinNumber, \
102  .mask = 1 << (PinNumber), \
103  .irq = Irq, \
104  .clockName = ClockName, \
105  .portNumber = PortNumber};
106 
107 #define GPIO_PIN_ID(PortName, PinNumber) &(PortName##PinNumber)
109 
110 #endif // __DRIVER_GPIO_H__
The GPIO pin handle for KSDK.
Definition: gpio_driver.h:75
port_interrupt_t interruptMode
Definition: gpio_driver.h:69
The GPIO Configuration KSDK.
Definition: gpio_driver.h:65
enum port_number port_number_t
GPIO PORT NAMES.
void(* gpio_isr_handler_t)(void *apUserData)
Definition: Driver_GPIO.h:60
IRQn_Type irq
Definition: gpio_driver.h:81
struct gpioHandleKSDK gpioHandleKSDK_t
The GPIO pin handle for KSDK.
port_number
GPIO PORT NAMES.
Definition: gpio_driver.h:53
gpio_pin_config_t pinConfig
Definition: gpio_driver.h:67
The gpio isr object.
Definition: gpio_driver.h:88
clock_ip_name_t clockName
Definition: gpio_driver.h:82
uint32_t pinNumber
Definition: gpio_driver.h:79
port_number_t portNumber
Definition: gpio_driver.h:83
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:64
port_pin_config_t portPinConfig
Definition: gpio_driver.h:68
PORT_Type * portBase
Definition: gpio_driver.h:78
uint32_t mask
Definition: gpio_driver.h:80
struct gpioConfigKSDK gpioConfigKSDK_t
The GPIO Configuration KSDK.
GPIO_Type * base
Definition: gpio_driver.h:77
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.