ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_gpio.c
1 /*
2  *****************************************************************************
3  @file: adi_gpio.c
4  @brief: GPIO device driver implementation.
5  -----------------------------------------------------------------------------
6 
7 Copyright (c) 2016-2018 Analog Devices, Inc.
8 
9 All rights reserved.
10 
11 Redistribution and use in source and binary forms, with or without modification,
12 are permitted provided that the following conditions are met:
13  - Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15  - Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18  - Modified versions of the software must be conspicuously marked as such.
19  - This software is licensed solely and exclusively for use with processors
20  manufactured by or for Analog Devices, Inc.
21  - This software may not be combined or merged with other code in any manner
22  that would cause the software to become subject to terms and conditions
23  which differ from those listed here.
24  - Neither the name of Analog Devices, Inc. nor the names of its
25  contributors may be used to endorse or promote products derived
26  from this software without specific prior written permission.
27  - The use of this software may or may not infringe the patent rights of one
28  or more patent holders. This license does not release you from the
29  requirement that you obtain separate licenses from these patent holders
30  to use this software.
31 
32 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY
33 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
34 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
35 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
37 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
38 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
39 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
40 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 
44 */
45 /*****************************************************************************/
46 
47 #include <stddef.h>
48 #include <string.h>
49 #include <assert.h>
50 #include <drivers/gpio/adi_gpio.h>
51 #include <rtos_map/adi_rtos_map.h>
52 #include "adi_gpio_def.h"
53 
54 #ifdef __ICCARM__
55 /*
56 * IAR MISRA C 2004 error suppressions.
57 *
58 * Pm123 (rule 8.5): there shall be no definition of objects or functions in a header file
59 * This isn't a header as such.
60 *
61 * Pm073 (rule 14.7): a function should have a single point of exit
62 * Pm143 (rule 14.7): a function should have a single point of exit at the end of the function
63 * Multiple returns are used for error handling.
64 *
65 * Pm140 (rule 11.3): a cast should not be performed between a pointer type and an integral type
66 * The rule makes an exception for memory-mapped register accesses.
67 */
68 #pragma diag_suppress=Pm123,Pm073,Pm143,Pm140
69 #endif /* __ICCARM__ */
70 
71 /* Debug function declarations */
72 #ifdef ADI_DEBUG
73 static bool ArePinsValid (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins);
74 #endif /* ADI_DEBUG */
75 
76 
77 static void CommonInterruptHandler (const ADI_GPIO_IRQ_INDEX index, const IRQn_Type eIrq);
78 void GPIO_A_Int_Handler(void);
79 void GPIO_B_Int_Handler(void);
80 
81 /*========== D A T A ==========*/
82 static ADI_GPIO_DRIVER adi_gpio_Device =
83 {
84  {
85  pADI_GPIO0, /* port 0 base address */
86  pADI_GPIO1, /* port 1 base address */
87  pADI_GPIO2, /* port 2 base address */
88 #if defined(__ADUCM4x50__)
89  pADI_GPIO3, /* port 3 base address */
90 #endif /* __ADUCM4x50__ */
91  },
92 
93  NULL
94 };
173  void* const pMemory,
174  uint32_t const MemorySize
175 )
176 {
177 
178 #ifdef ADI_DEBUG
179  /* Verify the given memory pointer */
180  if(NULL == pMemory)
181  {
183  }
184  /* Check if the memory size is sufficient to operate the driver */
185  if(MemorySize < ADI_GPIO_MEMORY_SIZE)
186  {
188  }
189  assert(ADI_GPIO_MEMORY_SIZE == sizeof(ADI_GPIO_DEV_DATA));
190 #endif
191 
192  /* Only initialize on 1st init call, i.e., preserve callbacks on multiple inits */
193  if (NULL == adi_gpio_Device.pData)
194  {
195  uint32_t i;
196 
197  adi_gpio_Device.pData = (ADI_GPIO_DEV_DATA*)pMemory;
198 
199  /* Initialize the callback table */
200  for (i = 0u; i < ADI_GPIO_NUM_INTERRUPTS; i++)
201  {
202  adi_gpio_Device.pData->CallbackTable[i].pfCallback = NULL;
203  adi_gpio_Device.pData->CallbackTable[i].pCBParam = NULL;
204  }
205 
206  /* Enable the group interrupts */
207  NVIC_EnableIRQ(SYS_GPIO_INTA_IRQn);
208  NVIC_EnableIRQ(SYS_GPIO_INTB_IRQn);
209  }
210 
211  return (ADI_GPIO_SUCCESS);
212 }
213 
214 
227 {
228 
229 #ifdef ADI_DEBUG
230  /* IF (not initialized) */
231  if (NULL == adi_gpio_Device.pData)
232  {
233  /* return error if not initialized */
234  return (ADI_GPIO_NOT_INITIALIZED);
235  }
236 #endif
237 
238  /* Disable the group interrupts */
239  NVIC_DisableIRQ(SYS_GPIO_INTA_IRQn);
240  NVIC_DisableIRQ(SYS_GPIO_INTB_IRQn);
241 
242  /* Clear the data pointer */
243  adi_gpio_Device.pData = NULL;
244 
245  return (ADI_GPIO_SUCCESS);
246 }
247 
248 
270 {
271  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
272  ADI_INT_STATUS_ALLOC();
273 #ifdef ADI_DEBUG
274  /* make sure we're initialized */
275  if (NULL == adi_gpio_Device.pData)
276  {
277  return (ADI_GPIO_NOT_INITIALIZED);
278  }
279 
280  /* validate the pins */
281  if (!ArePinsValid(Port, Pins))
282  {
283  return (ADI_GPIO_INVALID_PINS);
284  }
285 #endif
286 
287  pPort = adi_gpio_Device.pReg[Port];
288 
289  ADI_ENTER_CRITICAL_REGION();
290  switch (eIrq)
291  {
292  case SYS_GPIO_INTA_IRQn:
293  pPort->IENA = Pins;
294  break;
295  case SYS_GPIO_INTB_IRQn:
296  pPort->IENB = Pins;
297  break;
298  default:
299  break; /* This shall never reach */
300  }
301  ADI_EXIT_CRITICAL_REGION();
302 
303  return (ADI_GPIO_SUCCESS);
304 }
305 
306 
307 
328 {
329  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
330  uint16_t value = 0u;
331 
332 #ifdef ADI_DEBUG
333  /* make sure we're initialized */
334  if (NULL == adi_gpio_Device.pData)
335  {
336  return (ADI_GPIO_NOT_INITIALIZED);
337  }
338 
339  /* validate the eIrq */
340  if((eIrq != ADI_GPIO_INTA_IRQ) && (eIrq != ADI_GPIO_INTB_IRQ))
341  {
343  }
344 
345  /* The Port should be valid, as it will be typechecked by the compiler at
346  * build time. However, adding a check here for completeness. */
347  if((uint16_t)Port >= (uint16_t)(ADI_GPIO_NUM_PORTS))
348  {
349  return (ADI_GPIO_INVALID_PORT);
350  }
351 #endif
352 
353  pPort = adi_gpio_Device.pReg[Port];
354 
355  switch (eIrq)
356  {
357  case ADI_GPIO_INTA_IRQ:
358  value = pPort->IENA;
359  break;
360  case ADI_GPIO_INTB_IRQ:
361  value = pPort->IENB;
362  break;
363  default:
364  break; /* This shall never reach */
365  }
366 
367  *pValue = value;
368  return (ADI_GPIO_SUCCESS);
369 }
370 
392 {
393  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
394 
395 #ifdef ADI_DEBUG
396  /* make sure we're initialized */
397  if (NULL == adi_gpio_Device.pData)
398  {
399  return (ADI_GPIO_NOT_INITIALIZED);
400  }
401 
402  /* validate the pins */
403  if (!ArePinsValid(Port, Pins))
404  {
405  return (ADI_GPIO_INVALID_PINS);
406  }
407 #endif
408 
409  pPort = adi_gpio_Device.pReg[Port];
410 
411  pPort->POL = Pins;
412 
413  return (ADI_GPIO_SUCCESS);
414 }
415 
437 {
438  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
439 
440 #ifdef ADI_DEBUG
441  /* make sure we're initialized */
442  if (NULL == adi_gpio_Device.pData)
443  {
444  return (ADI_GPIO_NOT_INITIALIZED);
445  }
446 
447  /* The Port should be valid, as it will be typechecked by the compiler at
448  * build time. However, adding a check here for completeness. */
449  if((uint16_t)Port >= (uint16_t)(ADI_GPIO_NUM_PORTS))
450  {
451  return (ADI_GPIO_INVALID_PORT);
452  }
453 #endif
454 
455  pPort = adi_gpio_Device.pReg[Port];
456 
457  *pValue = (pPort->POL);
458 
459  return (ADI_GPIO_SUCCESS);
460 }
461 
487 {
488  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
489 
490 #ifdef ADI_DEBUG
491  /* make sure we're initialized */
492  if (NULL == adi_gpio_Device.pData)
493  {
494  return (ADI_GPIO_NOT_INITIALIZED);
495  }
496 
497  /* The Port should be valid, as it will be typechecked by the compiler at
498  * build time. However, adding a check here for completeness. */
499  if((uint16_t)Port >= (uint16_t)(ADI_GPIO_NUM_PORTS))
500  {
501  return (ADI_GPIO_INVALID_PORT);
502  }
503 
504  /* validate the pins */
505  if (!ArePinsValid(Port, Pins))
506  {
507  return (ADI_GPIO_INVALID_PINS);
508  }
509 #endif
510 
511  pPort = adi_gpio_Device.pReg[Port];
512 
513  if (bLowToHigh) {
514  pPort->POL |= Pins; /* set polarity the bits set in Pins to low to high */
515  }else{
516  pPort->POL &= ~Pins; /* set polarity the bits set in Pins to high to low */
517  }
518 
519  return (ADI_GPIO_SUCCESS);
520 }
521 
522 
549 ADI_GPIO_RESULT adi_gpio_OutputEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
550 {
551 
552  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
553  ADI_INT_STATUS_ALLOC();
554 
555 #ifdef ADI_DEBUG
556  /* make sure we're initialized */
557  if (NULL == adi_gpio_Device.pData)
558  {
559  return (ADI_GPIO_NOT_INITIALIZED);
560  }
561 
562  /* validate the pins */
563  if (!ArePinsValid(Port, Pins))
564  {
565  return (ADI_GPIO_INVALID_PINS);
566  }
567 #endif
568 
569  pPort = adi_gpio_Device.pReg[Port];
570 
571  ADI_ENTER_CRITICAL_REGION();
572  if (bFlag)
573  {
574  /* enable output */
575  pPort->OEN |= Pins;
576  } else
577  {
578  /* disable output */
579  pPort->OEN &= (uint16_t)~Pins;
580  }
581  ADI_EXIT_CRITICAL_REGION();
582 
583  return (ADI_GPIO_SUCCESS);
584 }
585 
586 
612 ADI_GPIO_RESULT adi_gpio_InputEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
613 {
614 
615  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
616  ADI_INT_STATUS_ALLOC();
617 
618 #ifdef ADI_DEBUG
619  /* make sure we're initialized */
620  if (NULL == adi_gpio_Device.pData) {
621  return (ADI_GPIO_NOT_INITIALIZED);
622  }
623 
624  /* validate the pins */
625  if (!ArePinsValid(Port, Pins)) {
626  return (ADI_GPIO_INVALID_PINS);
627  }
628 #endif
629 
630  pPort = adi_gpio_Device.pReg[Port];
631 
632  ADI_ENTER_CRITICAL_REGION();
633  if (bFlag)
634  {
635  /* enable input */
636  pPort->IEN |= Pins;
637  } else
638  {
639  /* disable input */
640  pPort->IEN &= (uint16_t)~Pins;
641  }
642  ADI_EXIT_CRITICAL_REGION();
643 
644  return (ADI_GPIO_SUCCESS);
645 }
646 
665 {
666 
667  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
668 
669 #ifdef ADI_DEBUG
670  /* make sure we're initialized */
671  if (NULL == adi_gpio_Device.pData)
672  {
673  return (ADI_GPIO_NOT_INITIALIZED);
674  }
675 
676  /* The Port should be valid, as it will be typechecked by the compiler at
677  * build time. However, adding a check here for completeness. */
678  if((uint16_t)Port >= (uint16_t)(ADI_GPIO_NUM_PORTS))
679  {
680  return (ADI_GPIO_INVALID_PORT);
681  }
682 #endif
683 
684  pPort = adi_gpio_Device.pReg[Port];
685 
686  *pValue = (pPort->OEN);
687 
688  return (ADI_GPIO_SUCCESS);
689 }
690 
716 ADI_GPIO_RESULT adi_gpio_PullUpEnable(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, const bool bFlag)
717 {
718 
719  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
720  ADI_INT_STATUS_ALLOC();
721 
722 #ifdef ADI_DEBUG
723  /* make sure we're initialized */
724  if (NULL == adi_gpio_Device.pData)
725  {
726  return (ADI_GPIO_NOT_INITIALIZED);
727  }
728 
729  /* validate the pins */
730  if (!ArePinsValid(Port, Pins))
731  {
732  return (ADI_GPIO_INVALID_PINS);
733  }
734 #endif
735 
736  pPort = adi_gpio_Device.pReg[Port];
737 
738  ADI_ENTER_CRITICAL_REGION();
739  if (bFlag)
740  {
741  pPort->PE |= Pins;
742  } else
743  {
744  pPort->PE &= (uint16_t)(~Pins);
745  }
746  ADI_EXIT_CRITICAL_REGION();
747 
748  return (ADI_GPIO_SUCCESS);
749 }
750 
777 {
778 
779  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
780  ADI_INT_STATUS_ALLOC();
781 
782 #ifdef ADI_DEBUG
783  /* make sure we're initialized */
784  if (NULL == adi_gpio_Device.pData)
785  {
786  return (ADI_GPIO_NOT_INITIALIZED);
787  }
788 
789  /* validate the pins */
790  if (!ArePinsValid(Port, Pins))
791  {
792  return (ADI_GPIO_INVALID_PINS);
793  }
794 #endif
795 
796  pPort = adi_gpio_Device.pReg[Port];
797 
798  ADI_ENTER_CRITICAL_REGION();
799  if (bFlag)
800  {
801  pPort->DS |= Pins;
802  } else
803  {
804  pPort->DS &= (uint16_t)(~Pins);
805  }
806  ADI_EXIT_CRITICAL_REGION();
807 
808  return (ADI_GPIO_SUCCESS);
809 }
810 
836 {
837 
838  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
839 
840 #ifdef ADI_DEBUG
841  /* make sure we're initialized */
842  if (NULL == adi_gpio_Device.pData)
843  {
844  return (ADI_GPIO_NOT_INITIALIZED);
845  }
846 
847  /* validate the pins */
848  if (!ArePinsValid(Port, Pins))
849  {
850  return (ADI_GPIO_INVALID_PINS);
851  }
852 #endif
853 
854  pPort = adi_gpio_Device.pReg[Port];
855 
856  /* set the given GPIOs high */
857  pPort->SET = Pins;
858 
859  return (ADI_GPIO_SUCCESS);
860 }
861 
862 
888 {
889 
890  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
891 
892 #ifdef ADI_DEBUG
893  /* make sure we're initialized */
894  if (NULL == adi_gpio_Device.pData)
895  {
896  return (ADI_GPIO_NOT_INITIALIZED);
897  }
898 
899  /* validate the pins */
900  if (!ArePinsValid(Port, Pins))
901  {
902  return (ADI_GPIO_INVALID_PINS);
903  }
904 #endif
905 
906  pPort = adi_gpio_Device.pReg[Port];
907 
908  /* set the given GPIOs low */
909  pPort->CLR = Pins;
910 
911  return (ADI_GPIO_SUCCESS);
912 }
913 
914 
943 {
944 
945  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
946 
947 #ifdef ADI_DEBUG
948  /* make sure we're initialized */
949  if (NULL == adi_gpio_Device.pData)
950  {
951  return (ADI_GPIO_NOT_INITIALIZED);
952  }
953 
954  /* validate the pins */
955  if (!ArePinsValid(Port, Pins))
956  {
957  return (ADI_GPIO_INVALID_PINS);
958  }
959 #endif
960 
961  pPort = adi_gpio_Device.pReg[Port];
962 
963  /* toggle the given GPIOs */
964  pPort->TGL = Pins;
965 
966  return (ADI_GPIO_SUCCESS);
967 }
968 
969 
993 {
994 
995  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
996 
997 #ifdef ADI_DEBUG
998  /* make sure we're initialized */
999  if (NULL == adi_gpio_Device.pData)
1000  {
1001  return (ADI_GPIO_NOT_INITIALIZED);
1002  }
1003 
1004  /* validate the pins */
1005  if (!ArePinsValid(Port, Pins))
1006  {
1007  return (ADI_GPIO_INVALID_PINS);
1008  }
1009 #endif
1010 
1011  pPort = adi_gpio_Device.pReg[Port];
1012 
1013  /* set the GPIOs as directed */
1014  pPort->OUT = Pins;
1015 
1016  return (ADI_GPIO_SUCCESS);
1017 }
1018 
1019 
1063 ADI_GPIO_RESULT adi_gpio_GetData (const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins, uint16_t* const pValue)
1064 {
1065 
1066  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
1067 
1068 #ifdef ADI_DEBUG
1069  /* make sure we're initialized */
1070  if (NULL == adi_gpio_Device.pData)
1071  {
1072  return (ADI_GPIO_NOT_INITIALIZED);
1073  }
1074 
1075  /* validate the pins */
1076  if (!ArePinsValid(Port, Pins))
1077  {
1078  return (ADI_GPIO_INVALID_PINS);
1079  }
1080 #endif
1081 
1082  pPort = adi_gpio_Device.pReg[Port];
1083 
1084  /* return the status of the GPIOs */
1085  *pValue = (pPort->IN) & Pins;
1086 
1087  return (ADI_GPIO_SUCCESS);
1088 }
1089 
1107 {
1108 
1109  ADI_GPIO_TypeDef *pPort; /* pointer to port registers */
1110 
1111 #ifdef ADI_DEBUG
1112  /* make sure we're initialized */
1113  if (NULL == adi_gpio_Device.pData)
1114  {
1115  return (ADI_GPIO_NOT_INITIALIZED);
1116  }
1117 
1118  /* The Port should be valid, as it will be typechecked by the compiler at
1119  * build time. However, adding a check here for completeness. */
1120  if((uint16_t)Port >= (uint16_t)(ADI_GPIO_NUM_PORTS))
1121  {
1122  return (ADI_GPIO_INVALID_PORT);
1123  }
1124 #endif
1125 
1126  pPort = adi_gpio_Device.pReg[Port];
1127 
1128  /* return the status of the oputput register */
1129  *pValue = (pPort->OUT);
1130 
1131  return (ADI_GPIO_SUCCESS);
1132 }
1133 
1160 ADI_GPIO_RESULT adi_gpio_RegisterCallback (const ADI_GPIO_IRQ eIrq, ADI_CALLBACK const pfCallback, void *const pCBParam )
1161 {
1162  uint16_t index = 0u;
1163  ADI_INT_STATUS_ALLOC();
1164 
1165 #ifdef ADI_DEBUG
1166  /* make sure we're initialized */
1167  if (NULL == adi_gpio_Device.pData)
1168  {
1169  return (ADI_GPIO_NOT_INITIALIZED);
1170  }
1171 #endif
1172 
1173  index = (uint16_t)eIrq - (uint16_t)SYS_GPIO_INTA_IRQn + ADI_GPIO_IRQ_GROUPA_INDEX;
1174 
1175  ADI_ENTER_CRITICAL_REGION();
1176 
1177  adi_gpio_Device.pData->CallbackTable[index].pfCallback = pfCallback;
1178  adi_gpio_Device.pData->CallbackTable[index].pCBParam = pCBParam;
1179 
1180  ADI_EXIT_CRITICAL_REGION();
1181 
1182  /* return the status */
1183  return (ADI_GPIO_SUCCESS);
1184 }
1185 
1186 
1187 
1191 /* All of the following is excluded from the doxygen output... */
1192 
1193 /* Common group (A/B) interrupt handler */
1194 static void CommonInterruptHandler(const ADI_GPIO_IRQ_INDEX index, const IRQn_Type eIrq)
1195 {
1196  ADI_GPIO_PORT Port;
1197  ADI_GPIO_TypeDef *pPort;
1198  ADI_GPIO_DATA Pins;
1199  ADI_GPIO_DATA nIntEnabledPins;
1200 
1201  ADI_GPIO_CALLBACK_INFO *pCallbackInfo = &adi_gpio_Device.pData->CallbackTable[index];
1202 
1203  /* Loop over all the ports. */
1204  for(Port=ADI_GPIO_PORT0; Port<ADI_GPIO_NUM_PORTS; Port++)
1205  {
1206  pPort = adi_gpio_Device.pReg[Port];
1207 
1208  /* Is the interrupt is for GROUP A */
1209  if(SYS_GPIO_INTA_IRQn == eIrq)
1210  {
1211  nIntEnabledPins = pPort->IENA;
1212  }
1213  else /* Is the interrupt is for GROUP B */
1214  {
1215  nIntEnabledPins = pPort->IENB;
1216  }
1217 
1218  /* Clear only required interrupts */
1219  Pins = ((pPort->INT) & nIntEnabledPins);
1220  pPort->INT = Pins;
1221 
1222  /* params list is: application-registered cbParam, Port number, and interrupt status */
1223  if((pCallbackInfo->pfCallback != NULL) && (Pins != 0u))
1224  {
1225  pCallbackInfo->pfCallback (pCallbackInfo->pCBParam, (uint32_t)Port, &Pins);
1226  }
1227  }
1228 }
1229 
1230 /* Interrupt A handler */
1231 void GPIO_A_Int_Handler(void)
1232 {
1233  ISR_PROLOG()
1234  CommonInterruptHandler(ADI_GPIO_IRQ_GROUPA_INDEX, SYS_GPIO_INTA_IRQn);
1235  ISR_EPILOG()
1236 }
1237 
1238 /* Interrupt B handler */
1239 void GPIO_B_Int_Handler (void)
1240 {
1241  ISR_PROLOG()
1242  CommonInterruptHandler(ADI_GPIO_IRQ_GROUPB_INDEX, SYS_GPIO_INTB_IRQn);
1243  ISR_EPILOG()
1244 }
1245 
1246 #ifdef ADI_DEBUG
1247 
1248 
1260 static bool ArePinsValid(const ADI_GPIO_PORT Port, const ADI_GPIO_DATA Pins)
1261 {
1262  uint32_t PinValid = 0u;
1263 
1264  /* test for a valid pin */
1265  switch (Port)
1266  {
1267  case ADI_GPIO_PORT0:
1268  PinValid = ~ADI_GPIO_PORT0_PIN_AVL & Pins;
1269  break;
1270 
1271  case ADI_GPIO_PORT1:
1272  PinValid = ~ADI_GPIO_PORT1_PIN_AVL & Pins;
1273  break;
1274 
1275  case ADI_GPIO_PORT2:
1276  PinValid = ~ADI_GPIO_PORT2_PIN_AVL & Pins;
1277  break;
1278 #if defined(__ADUCM4x50__)
1279  case ADI_GPIO_PORT3:
1280  PinValid = ~ADI_GPIO_PORT3_PIN_AVL & Pins;
1281  break;
1282 #endif /* __ADUCM4x50__ */
1283  default:
1284  break;
1285  }
1286 
1287  if (PinValid == 0u)
1288  {
1289  return true;
1290  }
1291  else
1292  {
1293  return false;
1294  }
1295 }
1296 #endif /* ADI_DEBUG */
1297 
1300 /*
1301 ** EOF
1302 */
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:664
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:486
#define ADI_GPIO_PORT1_PIN_AVL
Definition: adi_gpio.h:148
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:992
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:1063
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:835
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:887
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:612
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:716
ADI_GPIO_PORT
Definition: adi_gpio.h:118
ADI_GPIO_RESULT
Definition: adi_gpio.h:85
#define ADI_GPIO_MEMORY_SIZE
Definition: adi_gpio.h:78
ADI_GPIO_RESULT adi_gpio_Init(void *const pMemory, uint32_t const MemorySize)
Initializes the GPIO functions.
Definition: adi_gpio.c:172
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:942
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:776
ADI_GPIO_RESULT adi_gpio_GetGroupInterruptPins(const ADI_GPIO_PORT Port, const ADI_GPIO_IRQ eIrq, ADI_GPIO_DATA *const pValue)
Get a port&#39;s pin interrupt Group A/B mask register.
Definition: adi_gpio.c:327
#define ADI_GPIO_PORT2_PIN_AVL
Definition: adi_gpio.h:149
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:1106
ADI_GPIO_IRQ
Definition: adi_gpio.h:111
ADI_GPIO_RESULT adi_gpio_UnInit(void)
Un-initialize the GPIO driver.
Definition: adi_gpio.c:226
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:549
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:391
#define ADI_GPIO_PORT0_PIN_AVL
Definition: adi_gpio.h:147
ADI_GPIO_RESULT adi_gpio_GetGroupInterruptPolarity(const ADI_GPIO_PORT Port, ADI_GPIO_DATA *const pValue)
Get a port&#39;s pin interrupt polarity register.
Definition: adi_gpio.c:436
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:269
uint16_t ADI_GPIO_DATA
Definition: adi_gpio.h:81
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:1160