|
- /**
- * \brief This function determines the status of interrupt on a specified
- * pin.
- *
- * \param baseAdd The memory address of the GPIO instance being used.
- * \param pinNumber The serial number of the GPIO pin to be accessed.
- * The 144 GPIO pins have serial numbers from 1 to 144.
- * \return This returns a value which expresses the status of an interrupt
- * raised over the specified pin.
- * 1> GPIO_INT_NOPEND, if no interrupts are left to be serviced.
- * 2> GPIO_INT_PEND, if the interrupt raised over that pin is yet
- * to be cleared and serviced.
- *
- * \note If an interrupt over a pin is found to be pending, then the
- * application can call GPIOPinIntClear() to clear the interrupt
- * status.
- *
- *
- */
- unsigned int GPIOPinIntStatus(unsigned int baseAdd, unsigned int pinNumber)
- {
- unsigned int intStatus = GPIO_INT_NOPEND;
- unsigned int regNumber = 0;
- unsigned int pinOffset = 0;
- /*
- ** Each register contains settings for each pin of two banks. The 32 bits
- ** represent 16 pins each from the banks. Thus the register number must be
- ** calculated based on 32 pins boundary.
- */
- regNumber = (pinNumber - 1)/32;
-
- /*
- ** In every register the least significant bits starts with a GPIO number on
- ** a boundary of 32. Thus the pin offset must be calculated based on 32
- ** pins boundary. Ex: 'pinNumber' of 1 corresponds to bit 0 in
- ** 'register_name01'.
- */
- pinOffset = (pinNumber - 1) % 32;
- if(HWREG(baseAdd + GPIO_INTSTAT(regNumber)) & (1 << pinOffset))
- {
- intStatus = GPIO_INT_PEND;
- }
-
- return intStatus;
- }
复制代码 |
|