ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_gpio.h
1 
13 #ifndef ADI_GPIO_H
14 #define ADI_GPIO_H
15 
16 #include <adi_processor.h>
17 #include <adi_callback.h>
18 
19 #ifdef __ICCARM__
20 /* IAR MISRA C 2004 error suppressions.
21  *
22  * Pm008 (rule 2.4): sections of code should not be 'commented out'.
23  * Allow code example in doxygen comment.
24  * Pm011 (rule 6.3): The basic types of char, int, long, float cannot be used.
25  * bool is used in the APIs as it is not affending the rule. Disabling this as IAR treats it as an error.
26  */
27 #pragma diag_suppress=Pm008,Pm011
28 #endif /* __ICCARM__ */
29 
34 #ifdef __ICCARM__
35 #pragma diag_default=Pm008
36 #endif /* __ICCARM__ */
37 
38 /* C++ linkage */
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42 
46 #define ADI_GPIO_MEMORY_SIZE (16u)
47 
48 /* typedefs for 16-bit Ports */
49 typedef uint16_t ADI_GPIO_DATA;
53 typedef enum
54 {
67 
68 
70 typedef enum {
77 
79 typedef enum {
80  ADI_GPIO_INTA_IRQ = SYS_GPIO_INTA_IRQn,
81  ADI_GPIO_INTB_IRQ = SYS_GPIO_INTB_IRQn,
82 } ADI_GPIO_IRQ;
83 
84 
86 typedef enum {
90 #if defined(__ADUCM4x50__)
92 #endif /* __ADUCM4x50__ */
95 
96 /* 16-bit port pin defs */
97 #define ADI_GPIO_PIN_0 ((ADI_GPIO_DATA)(0x0001))
98 #define ADI_GPIO_PIN_1 ((ADI_GPIO_DATA)(0x0002))
99 #define ADI_GPIO_PIN_2 ((ADI_GPIO_DATA)(0x0004))
100 #define ADI_GPIO_PIN_3 ((ADI_GPIO_DATA)(0x0008))
101 #define ADI_GPIO_PIN_4 ((ADI_GPIO_DATA)(0x0010))
102 #define ADI_GPIO_PIN_5 ((ADI_GPIO_DATA)(0x0020))
103 #define ADI_GPIO_PIN_6 ((ADI_GPIO_DATA)(0x0040))
104 #define ADI_GPIO_PIN_7 ((ADI_GPIO_DATA)(0x0080))
105 #define ADI_GPIO_PIN_8 ((ADI_GPIO_DATA)(0x0100))
106 #define ADI_GPIO_PIN_9 ((ADI_GPIO_DATA)(0x0200))
107 #define ADI_GPIO_PIN_10 ((ADI_GPIO_DATA)(0x0400))
108 #define ADI_GPIO_PIN_11 ((ADI_GPIO_DATA)(0x0800))
109 #define ADI_GPIO_PIN_12 ((ADI_GPIO_DATA)(0x1000))
110 #define ADI_GPIO_PIN_13 ((ADI_GPIO_DATA)(0x2000))
111 #define ADI_GPIO_PIN_14 ((ADI_GPIO_DATA)(0x4000))
112 #define ADI_GPIO_PIN_15 ((ADI_GPIO_DATA)(0x8000))
114 /* GPIO port pins availability mask */
115 #define ADI_GPIO_PORT0_PIN_AVL (0xFFFFu)
116 #define ADI_GPIO_PORT1_PIN_AVL (0xFFFFu)
117 #define ADI_GPIO_PORT2_PIN_AVL (0xFFFFu)
119 #if defined(__ADUCM4x50__)
120 #define ADI_GPIO_PORT3_PIN_AVL (0x000Fu)
121 #endif /* __ADUCM4x50__ */
122 
123 /* GPIO API functions */
124 ADI_GPIO_RESULT adi_gpio_Init (void* const pMemory, uint32_t const MemorySize);
126 ADI_GPIO_RESULT adi_gpio_RegisterCallback (const ADI_GPIO_IRQ eIrq, ADI_CALLBACK const pfCallback, void *const pCBParam );
131 ADI_GPIO_RESULT adi_gpio_GroupInterruptPolarityEnable (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag);
132 ADI_GPIO_RESULT adi_gpio_OutputEnable (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag);
134 ADI_GPIO_RESULT adi_gpio_InputEnable (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag);
135 ADI_GPIO_RESULT adi_gpio_PullUpEnable (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag);
136 ADI_GPIO_RESULT adi_gpio_DriveStrengthEnable (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag);
141 ADI_GPIO_RESULT adi_gpio_GetData (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, uint16_t* const pValue);
143 #if defined (__ICCARM__)
144 #pragma diag_default=Pm011
145 #endif
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
153 #endif /* ADI_GPIO_V1_H */
ADI_GPIO_RESULT adi_gpio_GetOutputEnable(const ADI_GPIO_PORT Port, ADI_GPIO_DATA *const pValue)
Gets the Output Driver Status for GPIO Pin(s)
Definition: adi_gpio.c:630
ADI_GPIO_IRQ_TRIGGER_CONDITION
Definition: adi_gpio.h:70
ADI_GPIO_RESULT adi_gpio_GroupInterruptPolarityEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
Determine if the interrupts are generated on the rising or falling edge of the corresponding GPIO pin...
Definition: adi_gpio.c:452
ADI_GPIO_RESULT adi_gpio_SetData(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins)
Sets the logic level of all GPIO pins on the given port to a given logic level.
Definition: adi_gpio.c:958
ADI_GPIO_RESULT adi_gpio_GetData(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, uint16_t *const pValue)
Gets/Senses the input level of all GPIO Pins on the given port.
Definition: adi_gpio.c:1029
ADI_GPIO_RESULT adi_gpio_SetHigh(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins)
Sets the Given GPIO pin(s) to a Logical High Level.
Definition: adi_gpio.c:801
ADI_GPIO_RESULT adi_gpio_SetLow(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins)
Sets the Given GPIO pin(s) to a Logical Low Level.
Definition: adi_gpio.c:853
ADI_GPIO_RESULT adi_gpio_InputEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
Enables/Disables the Input Drivers for GPIO Pin(s)
Definition: adi_gpio.c:578
ADI_GPIO_RESULT adi_gpio_PullUpEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
Enables/Disables the Pull-Up for GPIO Pin(s)
Definition: adi_gpio.c:682
ADI_GPIO_PORT
Definition: adi_gpio.h:86
ADI_GPIO_RESULT
Definition: adi_gpio.h:53
ADI_GPIO_RESULT adi_gpio_Init(void *const pMemory, uint32_t const MemorySize)
Initializes the GPIO functions.
Definition: adi_gpio.c:138
ADI_GPIO_RESULT adi_gpio_Toggle(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins)
Toggles the Logical Level of the Given GPIO pin(s)
Definition: adi_gpio.c:908
ADI_GPIO_RESULT adi_gpio_DriveStrengthEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
Enables/Disables increased Drive Strength capability for GPIO Pin(s)
Definition: adi_gpio.c:742
ADI_GPIO_RESULT adi_gpio_GetGroupInterruptPins(const ADI_GPIO_PORT Port, const ADI_GPIO_IRQ eIrq, ADI_GPIO_DATA *const pValue)
Get a port's pin interrupt Group A/B mask register.
Definition: adi_gpio.c:293
ADI_GPIO_RESULT adi_gpio_GetOutputData(const ADI_GPIO_PORT Port, ADI_GPIO_DATA *const pValue)
Gets the Output Level of all GPIO Pins on a given port.
Definition: adi_gpio.c:1072
ADI_GPIO_IRQ
Definition: adi_gpio.h:79
ADI_GPIO_RESULT adi_gpio_UnInit(void)
Un-initialize the GPIO driver.
Definition: adi_gpio.c:192
ADI_GPIO_RESULT adi_gpio_OutputEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
Enables/Disables the Output Drivers for GPIO Pin(s)
Definition: adi_gpio.c:515
ADI_GPIO_RESULT adi_gpio_SetGroupInterruptPolarity(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins)
Set/clear the interrupt polarity for the given pins.
Definition: adi_gpio.c:357
ADI_GPIO_RESULT adi_gpio_GetGroupInterruptPolarity(const ADI_GPIO_PORT Port, ADI_GPIO_DATA *const pValue)
Get a port's pin interrupt polarity register.
Definition: adi_gpio.c:402
ADI_GPIO_RESULT adi_gpio_SetGroupInterruptPins(const ADI_GPIO_PORT Port, const ADI_GPIO_IRQ eIrq, const ADI_GPIO_DATA Pins)
Group the pins for the given group interrupt.
Definition: adi_gpio.c:235
uint16_t ADI_GPIO_DATA
Definition: adi_gpio.h:49
ADI_GPIO_RESULT adi_gpio_RegisterCallback(const ADI_GPIO_IRQ eIrq, ADI_CALLBACK const pfCallback, void *const pCBParam)
Register or unregister an application callback function for group (A/B) interrupts.
Definition: adi_gpio.c:1126