1 /*!
2  * \file      gpio-ioe.h
3  *
4  * \brief     IO expander driver implementation (based on the sx1509)
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013-2017 Semtech
16  *
17  * \endcode
18  *
19  * \author    Miguel Luis ( Semtech )
20  *
21  * \author    Gregory Cristian ( Semtech )
22  */
23 #ifndef __GPIO_IOE_H__
24 #define __GPIO_IOE_H__
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 #include <stdint.h>
32 #include "gpio.h"
33 
34 /*!
35  * \brief Initializes the given GPIO object
36  *
37  * \param [IN] obj    Pointer to the GPIO object
38  * \param [IN] pin    Pin name ( please look in pinName-board.h file )
39  * \param [IN] mode   Pin mode [PIN_INPUT, PIN_OUTPUT,
40  *                              PIN_ALTERNATE_FCT, PIN_ANALOGIC]
41  * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN]
42  * \param [IN] type   Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN]
43  * \param [IN] value  Default output value at initialization
44  */
45 void GpioIoeInit( Gpio_t *obj, PinNames pin, PinModes mode, PinConfigs config, PinTypes type, uint32_t value );
46 
47 /*!
48  * \brief Sets a user defined object pointer
49  *
50  * \param [IN] context User defined data object pointer to pass back
51  *                     on IRQ handler callback
52  */
53 void GpioIoeSetContext( Gpio_t *obj, void* context );
54 
55 /*!
56  * \brief GPIO IRQ Initialization
57  *
58  * \param [IN] obj         Pointer to the GPIO object
59  * \param [IN] irqMode     IRQ mode [NO_IRQ, IRQ_RISING_EDGE,
60  *                                   IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE]
61  * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY
62  *                                       IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY
63  *                                       IRQ_VERY_HIGH_PRIORITY]
64  * \param [IN] irqHandler  Callback function pointer
65  */
66 void GpioIoeSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler );
67 
68 /*!
69  * \brief Removes the interrupt from the object
70  *
71  * \param [IN] obj Pointer to the GPIO object
72  */
73 void GpioIoeRemoveInterrupt( Gpio_t *obj );
74 
75 /*!
76  * \brief Writes the given value to the GPIO output
77  *
78  * \param [IN] obj   Pointer to the GPIO object
79  * \param [IN] value New GPIO output value
80  */
81 void GpioIoeWrite( Gpio_t *obj, uint32_t value );
82 
83 /*!
84  * \brief Toggle the value to the GPIO output
85  *
86  * \param [IN] obj   Pointer to the GPIO object
87  */
88 void GpioIoeToggle( Gpio_t *obj );
89 
90 /*!
91  * \brief Reads the current GPIO input value
92  *
93  * \param [IN] obj Pointer to the GPIO object
94  * \retval value   Current GPIO input value
95  */
96 uint32_t GpioIoeRead( Gpio_t *obj );
97 
98 /*!
99  * \brief GpioIoeInterruptHandler callback function.
100  */
101 void GpioIoeInterruptHandler( void );
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif // __GPIO_IOE_H__
108