ISSDK  1.8
IoT Sensing Software Development Kit
gpio_driver.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file gpio_driver.h
11  * @brief The gpio_driver.h file containes the Generic Irq implmentation for the gpio.
12 */
13 
14 #ifndef __DRIVER_GPIO_H__
15 #define __DRIVER_GPIO_H__
16 
17 #include "Driver_Common.h"
18 #include "Driver_GPIO.h"
19 #include "fsl_common.h"
20 #include "fsl_iocon.h"
21 #include "fsl_gpio.h"
22 
23 /**
24 \brief GPIO PORT NAMES.
25 */
26 typedef enum port_number
27 {
28  PORTA_NUM = 0,
29  PORTB_NUM = 1,
32 
33 typedef enum _gpio_interrupt
34 {
35  kGPIO_InterruptLogic_0 = 0x0U, /*!< Interrupt on Logic 0 (Level Low). */
36  kGPIO_InterruptLogic_1 = 0x1U, /*!< Interrupt on Logic 1 (Level High). */
37  kGPIO_InterruptRisingEdge = 0x2U, /*!< Interrupt on Rising Edge. */
38  kGPIO_InterruptFallingEdge = 0x3U, /*!< Interrupt on Falling Edge. */
40 
41 /*!
42  * @brief The GPIO Configuration KSDK.
43  */
44 typedef struct gpioConfigKSDK
45 {
46  gpio_pin_config_t pinConfig; /*!< General pin charactertics.*/
47  uint32_t modeFunc; /*!< OR'ed values of type IOCON_* */
48  gpio_interrupt_t interruptMode; /*!< Interrupt Mode for a pin.*/
50 
51 /*!
52  * @brief The GPIO pin handle for KSDK.
53  */
54 typedef struct gpioHandleKSDK
55 {
56  GPIO_Type *base; /*!< Base address of the GPIO Port.*/
57  uint32_t pinNumber; /*!< pin number start from 0 -31.*/
58  uint32_t mask; /*!< mask value for a pin.*/
59  IRQn_Type irq; /*!< IRQ Number for the port.*/
60  clock_ip_name_t clockName; /*!< Clock Name for the port.*/
61  port_number_t portNumber; /*!< Port Number for the port.*/
63 
64 /*!
65  * @brief The gpio isr object.
66  */
67 typedef struct gpioIsrObj
68 {
69  void *pUserData; /*!< Pointer to a UserData.*/
70  gpio_isr_handler_t isrHandle; /*!< pointer to isrHandle.*/
71 } gpioIsrObj_t;
72 
73 /*!
74  * @brief Macro to create a Gpio handle
75  */
76 #define MAKE_GPIO_HANDLE(PortName, Base, PinNumber, Irq, ClockName, PortNumber) \
77  static gpioHandleKSDK_t PortName##PinNumber = {.base = Base, \
78  .pinNumber = PinNumber, \
79  .mask = 1 << (PinNumber), \
80  .irq = Irq, \
81  .clockName = ClockName, \
82  .portNumber = PortNumber};
83 
84 #define GPIO_PIN_ID(PortName, PinNumber) &(PortName##PinNumber)
86 
87 #endif // __DRIVER_GPIO_H__
_gpio_interrupt
Definition: gpio_driver.h:33
struct gpioIsrObj gpioIsrObj_t
The gpio isr object.
The GPIO Configuration KSDK.
Definition: gpio_driver.h:39
port_number
GPIO PORT NAMES.
Definition: gpio_driver.h:27
struct gpioHandleKSDK gpioHandleKSDK_t
The GPIO pin handle for KSDK.
uint32_t modeFunc
Definition: gpio_driver.h:47
The gpio isr object.
Definition: gpio_driver.h:62
void(* gpio_isr_handler_t)(void *apUserData)
Definition: Driver_GPIO.h:34
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:38
enum _gpio_interrupt gpio_interrupt_t
gpio_interrupt_t interruptMode
Definition: gpio_driver.h:48
The Driver_GPIO.h file contains the definitions for GPIO Driver direction.
The GPIO pin handle for KSDK.
Definition: gpio_driver.h:49
gpio_pin_config_t pinConfig
Definition: gpio_driver.h:41
struct gpioConfigKSDK gpioConfigKSDK_t
The GPIO Configuration KSDK.
enum port_number port_number_t
GPIO PORT NAMES.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:177