16 #include <drivers/gpio/adi_gpio.h> 17 #include <rtos_map/adi_rtos_map.h> 18 #include "adi_gpio_def.h" 34 #pragma diag_suppress=Pm123,Pm073,Pm143,Pm140 43 static void CommonInterruptHandler (
const ADI_GPIO_IRQ_INDEX index,
const IRQn_Type eIrq);
44 void GPIO_A_Int_Handler(
void);
45 void GPIO_B_Int_Handler(
void);
48 static ADI_GPIO_DRIVER adi_gpio_Device =
54 #if defined(__ADUCM4x50__) 140 uint32_t
const MemorySize
159 if (NULL == adi_gpio_Device.pData)
163 adi_gpio_Device.pData = (ADI_GPIO_DEV_DATA*)pMemory;
166 for (i = 0u; i < ADI_GPIO_NUM_INTERRUPTS; i++)
168 adi_gpio_Device.pData->CallbackTable[i].pfCallback = NULL;
169 adi_gpio_Device.pData->CallbackTable[i].pCBParam = NULL;
173 NVIC_EnableIRQ(SYS_GPIO_INTA_IRQn);
174 NVIC_EnableIRQ(SYS_GPIO_INTB_IRQn);
197 if (NULL == adi_gpio_Device.pData)
205 NVIC_DisableIRQ(SYS_GPIO_INTA_IRQn);
206 NVIC_DisableIRQ(SYS_GPIO_INTB_IRQn);
209 adi_gpio_Device.pData = NULL;
237 ADI_GPIO_TypeDef *pPort;
238 ADI_INT_STATUS_ALLOC();
241 if (NULL == adi_gpio_Device.pData)
247 if (!ArePinsValid(Port, Pins))
253 pPort = adi_gpio_Device.pReg[Port];
255 ADI_ENTER_CRITICAL_REGION();
258 case SYS_GPIO_INTA_IRQn:
261 case SYS_GPIO_INTB_IRQn:
267 ADI_EXIT_CRITICAL_REGION();
295 ADI_GPIO_TypeDef *pPort;
300 if (NULL == adi_gpio_Device.pData)
319 pPort = adi_gpio_Device.pReg[Port];
359 ADI_GPIO_TypeDef *pPort;
363 if (NULL == adi_gpio_Device.pData)
369 if (!ArePinsValid(Port, Pins))
375 pPort = adi_gpio_Device.pReg[Port];
404 ADI_GPIO_TypeDef *pPort;
408 if (NULL == adi_gpio_Device.pData)
421 pPort = adi_gpio_Device.pReg[Port];
423 *pValue = (pPort->POL);
454 ADI_GPIO_TypeDef *pPort;
458 if (NULL == adi_gpio_Device.pData)
471 if (!ArePinsValid(Port, Pins))
477 pPort = adi_gpio_Device.pReg[Port];
518 ADI_GPIO_TypeDef *pPort;
519 ADI_INT_STATUS_ALLOC();
523 if (NULL == adi_gpio_Device.pData)
529 if (!ArePinsValid(Port, Pins))
535 pPort = adi_gpio_Device.pReg[Port];
537 ADI_ENTER_CRITICAL_REGION();
545 pPort->OEN &= (uint16_t)~Pins;
547 ADI_EXIT_CRITICAL_REGION();
581 ADI_GPIO_TypeDef *pPort;
582 ADI_INT_STATUS_ALLOC();
586 if (NULL == adi_gpio_Device.pData) {
591 if (!ArePinsValid(Port, Pins)) {
596 pPort = adi_gpio_Device.pReg[Port];
598 ADI_ENTER_CRITICAL_REGION();
606 pPort->IEN &= (uint16_t)~Pins;
608 ADI_EXIT_CRITICAL_REGION();
633 ADI_GPIO_TypeDef *pPort;
637 if (NULL == adi_gpio_Device.pData)
650 pPort = adi_gpio_Device.pReg[Port];
652 *pValue = (pPort->OEN);
685 ADI_GPIO_TypeDef *pPort;
686 ADI_INT_STATUS_ALLOC();
690 if (NULL == adi_gpio_Device.pData)
696 if (!ArePinsValid(Port, Pins))
702 pPort = adi_gpio_Device.pReg[Port];
704 ADI_ENTER_CRITICAL_REGION();
710 pPort->PE &= (uint16_t)(~Pins);
712 ADI_EXIT_CRITICAL_REGION();
745 ADI_GPIO_TypeDef *pPort;
746 ADI_INT_STATUS_ALLOC();
750 if (NULL == adi_gpio_Device.pData)
756 if (!ArePinsValid(Port, Pins))
762 pPort = adi_gpio_Device.pReg[Port];
764 ADI_ENTER_CRITICAL_REGION();
770 pPort->DS &= (uint16_t)(~Pins);
772 ADI_EXIT_CRITICAL_REGION();
804 ADI_GPIO_TypeDef *pPort;
808 if (NULL == adi_gpio_Device.pData)
814 if (!ArePinsValid(Port, Pins))
820 pPort = adi_gpio_Device.pReg[Port];
856 ADI_GPIO_TypeDef *pPort;
860 if (NULL == adi_gpio_Device.pData)
866 if (!ArePinsValid(Port, Pins))
872 pPort = adi_gpio_Device.pReg[Port];
911 ADI_GPIO_TypeDef *pPort;
915 if (NULL == adi_gpio_Device.pData)
921 if (!ArePinsValid(Port, Pins))
927 pPort = adi_gpio_Device.pReg[Port];
961 ADI_GPIO_TypeDef *pPort;
965 if (NULL == adi_gpio_Device.pData)
971 if (!ArePinsValid(Port, Pins))
977 pPort = adi_gpio_Device.pReg[Port];
1032 ADI_GPIO_TypeDef *pPort;
1036 if (NULL == adi_gpio_Device.pData)
1042 if (!ArePinsValid(Port, Pins))
1048 pPort = adi_gpio_Device.pReg[Port];
1051 *pValue = (pPort->IN) & Pins;
1075 ADI_GPIO_TypeDef *pPort;
1079 if (NULL == adi_gpio_Device.pData)
1092 pPort = adi_gpio_Device.pReg[Port];
1095 *pValue = (pPort->OUT);
1128 uint16_t index = 0u;
1129 ADI_INT_STATUS_ALLOC();
1133 if (NULL == adi_gpio_Device.pData)
1139 index = (uint16_t)eIrq - (uint16_t)SYS_GPIO_INTA_IRQn + ADI_GPIO_IRQ_GROUPA_INDEX;
1141 ADI_ENTER_CRITICAL_REGION();
1143 adi_gpio_Device.pData->CallbackTable[index].pfCallback = pfCallback;
1144 adi_gpio_Device.pData->CallbackTable[index].pCBParam = pCBParam;
1146 ADI_EXIT_CRITICAL_REGION();
1160 static void CommonInterruptHandler(
const ADI_GPIO_IRQ_INDEX index,
const IRQn_Type eIrq)
1163 ADI_GPIO_TypeDef *pPort;
1167 ADI_GPIO_CALLBACK_INFO *pCallbackInfo = &adi_gpio_Device.pData->CallbackTable[index];
1172 pPort = adi_gpio_Device.pReg[Port];
1175 if(SYS_GPIO_INTA_IRQn == eIrq)
1177 nIntEnabledPins = pPort->IENA;
1181 nIntEnabledPins = pPort->IENB;
1185 Pins = ((pPort->INT) & nIntEnabledPins);
1189 if((pCallbackInfo->pfCallback != NULL) && (Pins != 0u))
1191 pCallbackInfo->pfCallback (pCallbackInfo->pCBParam, (uint32_t)Port, &Pins);
1197 void GPIO_A_Int_Handler(
void)
1200 CommonInterruptHandler(ADI_GPIO_IRQ_GROUPA_INDEX, SYS_GPIO_INTA_IRQn);
1205 void GPIO_B_Int_Handler (
void)
1208 CommonInterruptHandler(ADI_GPIO_IRQ_GROUPB_INDEX, SYS_GPIO_INTB_IRQn);
1228 uint32_t PinValid = 0u;
1244 #if defined(__ADUCM4x50__) 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)
#define ADI_GPIO_PORT3_PIN_AVL
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.