50 #include <drivers/gpio/adi_gpio.h> 51 #include <rtos_map/adi_rtos_map.h> 52 #include "adi_gpio_def.h" 68 #pragma diag_suppress=Pm123,Pm073,Pm143,Pm140 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);
82 static ADI_GPIO_DRIVER adi_gpio_Device =
88 #if defined(__ADUCM4x50__) 174 uint32_t
const MemorySize
193 if (NULL == adi_gpio_Device.pData)
197 adi_gpio_Device.pData = (ADI_GPIO_DEV_DATA*)pMemory;
200 for (i = 0u; i < ADI_GPIO_NUM_INTERRUPTS; i++)
202 adi_gpio_Device.pData->CallbackTable[i].pfCallback = NULL;
203 adi_gpio_Device.pData->CallbackTable[i].pCBParam = NULL;
207 NVIC_EnableIRQ(SYS_GPIO_INTA_IRQn);
208 NVIC_EnableIRQ(SYS_GPIO_INTB_IRQn);
231 if (NULL == adi_gpio_Device.pData)
239 NVIC_DisableIRQ(SYS_GPIO_INTA_IRQn);
240 NVIC_DisableIRQ(SYS_GPIO_INTB_IRQn);
243 adi_gpio_Device.pData = NULL;
271 ADI_GPIO_TypeDef *pPort;
272 ADI_INT_STATUS_ALLOC();
275 if (NULL == adi_gpio_Device.pData)
281 if (!ArePinsValid(Port, Pins))
287 pPort = adi_gpio_Device.pReg[Port];
289 ADI_ENTER_CRITICAL_REGION();
292 case SYS_GPIO_INTA_IRQn:
295 case SYS_GPIO_INTB_IRQn:
301 ADI_EXIT_CRITICAL_REGION();
329 ADI_GPIO_TypeDef *pPort;
334 if (NULL == adi_gpio_Device.pData)
353 pPort = adi_gpio_Device.pReg[Port];
393 ADI_GPIO_TypeDef *pPort;
397 if (NULL == adi_gpio_Device.pData)
403 if (!ArePinsValid(Port, Pins))
409 pPort = adi_gpio_Device.pReg[Port];
438 ADI_GPIO_TypeDef *pPort;
442 if (NULL == adi_gpio_Device.pData)
455 pPort = adi_gpio_Device.pReg[Port];
457 *pValue = (pPort->POL);
488 ADI_GPIO_TypeDef *pPort;
492 if (NULL == adi_gpio_Device.pData)
505 if (!ArePinsValid(Port, Pins))
511 pPort = adi_gpio_Device.pReg[Port];
552 ADI_GPIO_TypeDef *pPort;
553 ADI_INT_STATUS_ALLOC();
557 if (NULL == adi_gpio_Device.pData)
563 if (!ArePinsValid(Port, Pins))
569 pPort = adi_gpio_Device.pReg[Port];
571 ADI_ENTER_CRITICAL_REGION();
579 pPort->OEN &= (uint16_t)~Pins;
581 ADI_EXIT_CRITICAL_REGION();
615 ADI_GPIO_TypeDef *pPort;
616 ADI_INT_STATUS_ALLOC();
620 if (NULL == adi_gpio_Device.pData) {
625 if (!ArePinsValid(Port, Pins)) {
630 pPort = adi_gpio_Device.pReg[Port];
632 ADI_ENTER_CRITICAL_REGION();
640 pPort->IEN &= (uint16_t)~Pins;
642 ADI_EXIT_CRITICAL_REGION();
667 ADI_GPIO_TypeDef *pPort;
671 if (NULL == adi_gpio_Device.pData)
684 pPort = adi_gpio_Device.pReg[Port];
686 *pValue = (pPort->OEN);
719 ADI_GPIO_TypeDef *pPort;
720 ADI_INT_STATUS_ALLOC();
724 if (NULL == adi_gpio_Device.pData)
730 if (!ArePinsValid(Port, Pins))
736 pPort = adi_gpio_Device.pReg[Port];
738 ADI_ENTER_CRITICAL_REGION();
744 pPort->PE &= (uint16_t)(~Pins);
746 ADI_EXIT_CRITICAL_REGION();
779 ADI_GPIO_TypeDef *pPort;
780 ADI_INT_STATUS_ALLOC();
784 if (NULL == adi_gpio_Device.pData)
790 if (!ArePinsValid(Port, Pins))
796 pPort = adi_gpio_Device.pReg[Port];
798 ADI_ENTER_CRITICAL_REGION();
804 pPort->DS &= (uint16_t)(~Pins);
806 ADI_EXIT_CRITICAL_REGION();
838 ADI_GPIO_TypeDef *pPort;
842 if (NULL == adi_gpio_Device.pData)
848 if (!ArePinsValid(Port, Pins))
854 pPort = adi_gpio_Device.pReg[Port];
890 ADI_GPIO_TypeDef *pPort;
894 if (NULL == adi_gpio_Device.pData)
900 if (!ArePinsValid(Port, Pins))
906 pPort = adi_gpio_Device.pReg[Port];
945 ADI_GPIO_TypeDef *pPort;
949 if (NULL == adi_gpio_Device.pData)
955 if (!ArePinsValid(Port, Pins))
961 pPort = adi_gpio_Device.pReg[Port];
995 ADI_GPIO_TypeDef *pPort;
999 if (NULL == adi_gpio_Device.pData)
1005 if (!ArePinsValid(Port, Pins))
1011 pPort = adi_gpio_Device.pReg[Port];
1066 ADI_GPIO_TypeDef *pPort;
1070 if (NULL == adi_gpio_Device.pData)
1076 if (!ArePinsValid(Port, Pins))
1082 pPort = adi_gpio_Device.pReg[Port];
1085 *pValue = (pPort->IN) & Pins;
1109 ADI_GPIO_TypeDef *pPort;
1113 if (NULL == adi_gpio_Device.pData)
1126 pPort = adi_gpio_Device.pReg[Port];
1129 *pValue = (pPort->OUT);
1162 uint16_t index = 0u;
1163 ADI_INT_STATUS_ALLOC();
1167 if (NULL == adi_gpio_Device.pData)
1173 index = (uint16_t)eIrq - (uint16_t)SYS_GPIO_INTA_IRQn + ADI_GPIO_IRQ_GROUPA_INDEX;
1175 ADI_ENTER_CRITICAL_REGION();
1177 adi_gpio_Device.pData->CallbackTable[index].pfCallback = pfCallback;
1178 adi_gpio_Device.pData->CallbackTable[index].pCBParam = pCBParam;
1180 ADI_EXIT_CRITICAL_REGION();
1194 static void CommonInterruptHandler(
const ADI_GPIO_IRQ_INDEX index,
const IRQn_Type eIrq)
1197 ADI_GPIO_TypeDef *pPort;
1201 ADI_GPIO_CALLBACK_INFO *pCallbackInfo = &adi_gpio_Device.pData->CallbackTable[index];
1206 pPort = adi_gpio_Device.pReg[Port];
1209 if(SYS_GPIO_INTA_IRQn == eIrq)
1211 nIntEnabledPins = pPort->IENA;
1215 nIntEnabledPins = pPort->IENB;
1219 Pins = ((pPort->INT) & nIntEnabledPins);
1223 if((pCallbackInfo->pfCallback != NULL) && (Pins != 0u))
1225 pCallbackInfo->pfCallback (pCallbackInfo->pCBParam, (uint32_t)Port, &Pins);
1231 void GPIO_A_Int_Handler(
void)
1234 CommonInterruptHandler(ADI_GPIO_IRQ_GROUPA_INDEX, SYS_GPIO_INTA_IRQn);
1239 void GPIO_B_Int_Handler (
void)
1242 CommonInterruptHandler(ADI_GPIO_IRQ_GROUPB_INDEX, SYS_GPIO_INTB_IRQn);
1262 uint32_t PinValid = 0u;
1278 #if defined(__ADUCM4x50__) 1279 case ADI_GPIO_PORT3:
1280 PinValid = ~ADI_GPIO_PORT3_PIN_AVL & Pins;
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)
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...
#define ADI_GPIO_PORT1_PIN_AVL
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.
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.
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.
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.
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)
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)
#define ADI_GPIO_MEMORY_SIZE
ADI_GPIO_RESULT adi_gpio_Init(void *const pMemory, uint32_t const MemorySize)
Initializes the GPIO functions.
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)
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)
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.
#define ADI_GPIO_PORT2_PIN_AVL
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.
ADI_GPIO_RESULT adi_gpio_UnInit(void)
Un-initialize the GPIO driver.
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)
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.
#define ADI_GPIO_PORT0_PIN_AVL
ADI_GPIO_RESULT adi_gpio_GetGroupInterruptPolarity(const ADI_GPIO_PORT Port, ADI_GPIO_DATA *const pValue)
Get a port's pin interrupt polarity register.
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.
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.