PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Port Interrupt Functions
PDL API Reference » GPIO (General Purpose Input Output) » Functions

## General Description

## Functions
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptStatus (GPIO_PRT_Type *base, uint32_t pinNum)
| Returns the current unmasked interrupt state of the pin. More...
__STATIC_INLINE void | Cy_GPIO_ClearInterrupt (GPIO_PRT_Type *base, uint32_t pinNum)
| Clears the triggered pin interrupt. More...
__STATIC_INLINE void | Cy_GPIO_SetInterruptMask (GPIO_PRT_Type *base, uint32_t pinNum, uint32_t value)
| Configures the pin interrupt to be forwarded to the CPU NVIC. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptMask (GPIO_PRT_Type *base, uint32_t pinNum)
| Returns the state of the pin interrupt mask. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptStatusMasked (GPIO_PRT_Type *base, uint32_t pinNum)
| Return the pin's current interrupt state after being masked. More...
__STATIC_INLINE void | Cy_GPIO_SetSwInterrupt (GPIO_PRT_Type *base, uint32_t pinNum)
| Force a pin interrupt to trigger. More...
__STATIC_INLINE void | Cy_GPIO_SetInterruptEdge (GPIO_PRT_Type *base, uint32_t pinNum, uint32_t value)
| Configures the type of edge that will trigger a pin interrupt. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptEdge (GPIO_PRT_Type *base, uint32_t pinNum)
| Returns the current pin interrupt edge type. More...
__STATIC_INLINE void | Cy_GPIO_SetFilter (GPIO_PRT_Type *base, uint32_t value)
| Configures which pin on the port connects to the port-specific glitch filter. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetFilter (GPIO_PRT_Type *base)
| Returns which pin is currently configured to connect to the port-specific glitch filter. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptCause0 (void)
| Returns the interrupt status for ports 0 to 31. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptCause1 (void)
| Returns the interrupt status for ports 32 to 63. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptCause2 (void)
| Returns the interrupt status for ports 64 to 95. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetInterruptCause3 (void)
| Returns the interrupt status for ports 96 to 127. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetSecureInterruptCause0 (void)
| Returns the interrupt status for ports 0 to 31. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetSecureInterruptCause1 (void)
| Returns the interrupt status for ports 32 to 63. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetSecureInterruptCause2 (void)
| Returns the interrupt status for ports 64 to 95. More...
__STATIC_INLINE uint32_t | Cy_GPIO_GetSecureInterruptCause3 (void)
| Returns the interrupt status for ports 96 to 127. More...
__STATIC_INLINE void | Cy_GPIO_SetVddModeSel (cy_en_gpio_vdd_mode_t mode)
| Update voltage mode to 1.8V or 3.3V. More...

## Function Documentation

## ◆ Cy_GPIO_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptStatus | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum
| ) |  |

Returns the current unmasked interrupt state of the pin.

The core processor's NVIC is triggered by the masked interrupt bits. This function allows reading the unmasked interrupt state. Whether the bit positions actually trigger the interrupt are defined by the interrupt mask bits.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register Bit position 8 is the routed pin through the port glitch filter.

Returns
  0 = Pin interrupt condition not detected 1 = Pin interrupt condition detected

Function Usage
  /* Scenario: Clear stale (unmasked) port interrupts before reconfiguration */
  if(1UL == Cy_GPIO_GetInterruptStatus(P0_0_PORT, P0_0_NUM))
  {
  /* Clear the P0.0 interrupt */
  Cy_GPIO_ClearInterrupt(P0_0_PORT, P0_0_NUM);
  }
  Cy_GPIO_GetInterruptStatus
  __STATIC_INLINE uint32_t Cy_GPIO_GetInterruptStatus(GPIO_PRT_Type *base, uint32_t pinNum)
  Returns the current unmasked interrupt state of the pin.
  Definition: cy_gpio.h:2008
  Cy_GPIO_ClearInterrupt
  __STATIC_INLINE void Cy_GPIO_ClearInterrupt(GPIO_PRT_Type *base, uint32_t pinNum)
  Clears the triggered pin interrupt.
  Definition: cy_gpio.h:2032

## ◆ Cy_GPIO_ClearInterrupt()

__STATIC_INLINE void Cy_GPIO_ClearInterrupt | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum
| ) |  |

Clears the triggered pin interrupt.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register Bit position 8 is the routed pin through the port glitch filter.

Function Usage
  /* Scenario: Inside the interrupt service routine of port 0 interrupt */
  /* Clear the P0.0 interrupt */
  Cy_GPIO_ClearInterrupt(P0_0_PORT, P0_0_NUM);

## ◆ Cy_GPIO_SetInterruptMask()

__STATIC_INLINE void Cy_GPIO_SetInterruptMask | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum,
|  | uint32_t | value
| ) |  |

Configures the pin interrupt to be forwarded to the CPU NVIC.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register. Bit position 8 is the routed pin through the port glitch filter.
  value | 0 = Pin interrupt not forwarded to CPU interrupt controller 1 = Pin interrupt masked and forwarded to CPU interrupt controller

Note
  This function modifies a port register in a read-modify-write operation. It is not thread safe as the resource is shared among multiple pins on a port.

Function Usage
  /* Scenario: Need port interrupt to trigger on P0.0 */
  /* Get the interrupt mask of P0.0 */
  if(0UL == Cy_GPIO_GetInterruptMask(P0_0_PORT, P0_0_NUM))
  {
  /* Set the interrupt mask of P0.0 */
  Cy_GPIO_SetInterruptMask(P0_0_PORT, P0_0_NUM, 1UL);
  }
  Cy_GPIO_GetInterruptMask
  __STATIC_INLINE uint32_t Cy_GPIO_GetInterruptMask(GPIO_PRT_Type *base, uint32_t pinNum)
  Returns the state of the pin interrupt mask.
  Definition: cy_gpio.h:2108
  Cy_GPIO_SetInterruptMask
  __STATIC_INLINE void Cy_GPIO_SetInterruptMask(GPIO_PRT_Type *base, uint32_t pinNum, uint32_t value)
  Configures the pin interrupt to be forwarded to the CPU NVIC.
  Definition: cy_gpio.h:2071

## ◆ Cy_GPIO_GetInterruptMask()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptMask | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum
| ) |  |

Returns the state of the pin interrupt mask.

This mask is used to determine whether the pin is configured to be forwarded to the CPU NVIC.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register. Bit position 8 is the routed pin through the port glitch filter.

Returns
  0 = Pin interrupt not forwarded to CPU interrupt controller 1 = Pin interrupt masked and forwarded to CPU interrupt controller

Function Usage
  /* Scenario: Need port interrupt to trigger on P0.0 */
  /* Get the interrupt mask of P0.0 */
  if(0UL == Cy_GPIO_GetInterruptMask(P0_0_PORT, P0_0_NUM))
  {
  /* Set the interrupt mask of P0.0 */
  Cy_GPIO_SetInterruptMask(P0_0_PORT, P0_0_NUM, 1UL);
  }

## ◆ Cy_GPIO_GetInterruptStatusMasked()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptStatusMasked | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum
| ) |  |

Return the pin's current interrupt state after being masked.

The core processor's NVIC is triggered by the masked interrupt bits. This function allows reading this masked interrupt state. Note that the bits that are not masked will not be forwarded to the NVIC.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register. Bit position 8 is the routed pin through the port glitch filter.

Returns
  0 = Pin interrupt not detected or not forwarded to CPU interrupt controller 1 = Pin interrupt detected and forwarded to CPU interrupt controller

Function Usage
  /* Scenario: Inside the interrupt service routine of port 0 interrupt */
  if(1UL == Cy_GPIO_GetInterruptStatusMasked(P0_0_PORT, P0_0_NUM))
  {
  /* Clear the P0.0 interrupt */
  Cy_GPIO_ClearInterrupt(P0_0_PORT, P0_0_NUM);
  }
  Cy_GPIO_GetInterruptStatusMasked
  __STATIC_INLINE uint32_t Cy_GPIO_GetInterruptStatusMasked(GPIO_PRT_Type *base, uint32_t pinNum)
  Return the pin's current interrupt state after being masked.
  Definition: cy_gpio.h:2141

## ◆ Cy_GPIO_SetSwInterrupt()

__STATIC_INLINE void Cy_GPIO_SetSwInterrupt | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum
| ) |  |

Force a pin interrupt to trigger.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register. Bit position 8 is the routed pin through the port glitch filter.

Function Usage
  /* Scenario: Test that the port interrupt triggers */
  /* Set the P0.0 interrupt through software */
  Cy_GPIO_SetSwInterrupt(P0_0_PORT, P0_0_NUM);
  Cy_GPIO_SetSwInterrupt
  __STATIC_INLINE void Cy_GPIO_SetSwInterrupt(GPIO_PRT_Type *base, uint32_t pinNum)
  Force a pin interrupt to trigger.
  Definition: cy_gpio.h:2167

## ◆ Cy_GPIO_SetInterruptEdge()

__STATIC_INLINE void Cy_GPIO_SetInterruptEdge | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum,
|  | uint32_t | value
| ) |  |

Configures the type of edge that will trigger a pin interrupt.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register. Bit position 8 is the routed pin through the port glitch filter.
  value | Pin interrupt mode. Options are detailed in Interrupt trigger type macros

Note
  This function modifies a port register in a read-modify-write operation. It is not thread safe as the resource is shared among multiple pins on a port.

Function Usage
  /* Scenario: Update the port interrupt trigger type to falling edge */
  /* Get the interrupt edge setting of P0.0 */
  if(CY_GPIO_INTR_RISING == Cy_GPIO_GetInterruptEdge(P0_0_PORT, P0_0_NUM))
  {
  /* Set the interrupt trigger type to falling edge for P0.0 */
  Cy_GPIO_SetInterruptEdge(P0_0_PORT, P0_0_NUM, CY_GPIO_INTR_FALLING);
  }
  Cy_GPIO_SetInterruptEdge
  __STATIC_INLINE void Cy_GPIO_SetInterruptEdge(GPIO_PRT_Type *base, uint32_t pinNum, uint32_t value)
  Configures the type of edge that will trigger a pin interrupt.
  Definition: cy_gpio.h:2200
  Cy_GPIO_GetInterruptEdge
  __STATIC_INLINE uint32_t Cy_GPIO_GetInterruptEdge(GPIO_PRT_Type *base, uint32_t pinNum)
  Returns the current pin interrupt edge type.
  Definition: cy_gpio.h:2235
  CY_GPIO_INTR_FALLING
  #define CY_GPIO_INTR_FALLING
  Falling-Edge interrupt.
  Definition: cy_gpio.h:578
  CY_GPIO_INTR_RISING
  #define CY_GPIO_INTR_RISING
  Rising-Edge interrupt.
  Definition: cy_gpio.h:577

## ◆ Cy_GPIO_GetInterruptEdge()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptEdge | ( | GPIO_PRT_Type * | base,
|  | uint32_t | pinNum
| ) |  |

Returns the current pin interrupt edge type.

Parameters

  base | Pointer to the pin's port register base address
  pinNum | Position of the pin bit-field within the port register. Bit position 8 is the routed pin through the port glitch filter.

Returns
  Pin interrupt mode. Options are detailed in Interrupt trigger type macros

Function Usage
  /* Scenario: Update the port interrupt trigger type to falling edge */
  /* Get the interrupt edge setting of P0.0 */
  if(CY_GPIO_INTR_RISING == Cy_GPIO_GetInterruptEdge(P0_0_PORT, P0_0_NUM))
  {
  /* Set the interrupt trigger type to falling edge for P0.0 */
  Cy_GPIO_SetInterruptEdge(P0_0_PORT, P0_0_NUM, CY_GPIO_INTR_FALLING);
  }

## ◆ Cy_GPIO_SetFilter()

__STATIC_INLINE void Cy_GPIO_SetFilter | ( | GPIO_PRT_Type * | base,
|  | uint32_t | value
| ) |  |

Configures which pin on the port connects to the port-specific glitch filter.

Each port contains a single 50ns glitch filter. Any of the pins on the port can be routed to this filter such that the input signal is filtered before reaching the edge-detect interrupt circuitry. The state of the filtered pin can also be read by calling the Cy_GPIO_Read() function.

Parameters

  base | Pointer to the pin's port register base address
  value | The number of the port pin to route to the port filter (0...7)

Note
  This function modifies a port register in a read-modify-write operation. It is not thread safe as the resource is shared among multiple pins on a port.
  The filtered pin does not have an associated HSIOM connection. Therefore it cannot be routed directly to other peripherals in hardware.

Function Usage
  /* Scenario: Utilize the glitch filter for input signal on P0.0 */
  /* Get the source of the port 0 glitch filter */
  if(P0_0_NUM != Cy_GPIO_GetFilter(P0_0_PORT))
  {
  /* Set the port 0 glitch filter source to be P0.0 */
  Cy_GPIO_SetFilter(P0_0_PORT, P0_0_NUM);
  }
  Cy_GPIO_SetFilter
  __STATIC_INLINE void Cy_GPIO_SetFilter(GPIO_PRT_Type *base, uint32_t value)
  Configures which pin on the port connects to the port-specific glitch filter.
  Definition: cy_gpio.h:2273
  Cy_GPIO_GetFilter
  __STATIC_INLINE uint32_t Cy_GPIO_GetFilter(GPIO_PRT_Type *base)
  Returns which pin is currently configured to connect to the port-specific glitch filter.
  Definition: cy_gpio.h:2306

## ◆ Cy_GPIO_GetFilter()

__STATIC_INLINE uint32_t Cy_GPIO_GetFilter | ( | GPIO_PRT_Type * | base | ) |

Returns which pin is currently configured to connect to the port-specific glitch filter.

Each port contains a single 50ns glitch filter. Any of the pins on the port can be routed to this filter such that the input signal is filtered before reaching the edge-detect interrupt circuitry. The state of the filtered pin can also be read by calling the Cy_GPIO_Read() function.

Parameters

  base | Pointer to the pin's port register base address

Returns
  The number of the port pin routed to the port filter (0...7)

Function Usage
  /* Scenario: Utilize the glitch filter for input signal on P0.0 */
  /* Get the source of the port 0 glitch filter */
  if(P0_0_NUM != Cy_GPIO_GetFilter(P0_0_PORT))
  {
  /* Set the port 0 glitch filter source to be P0.0 */
  Cy_GPIO_SetFilter(P0_0_PORT, P0_0_NUM);
  }

## ◆ Cy_GPIO_GetInterruptCause0()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptCause0 | ( | void |  | ) |

Returns the interrupt status for ports 0 to 31.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Function Usage
  /* Scenario: Inside the interrupt service routine of "all port" interrupt */
  #define PORT0_INTR_MASK 0x00000001UL
  uint32_t intrSrc = Cy_GPIO_GetInterruptCause0();
  /* Check if the interrupt was from port 0 */
  if(PORT0_INTR_MASK == (intrSrc & PORT0_INTR_MASK))
  {
  if(1UL == Cy_GPIO_GetInterruptStatusMasked(P0_0_PORT, P0_0_NUM))
  {
  /* Clear the P0.0 interrupt */
  Cy_GPIO_ClearInterrupt(P0_0_PORT, P0_0_NUM);
  }
  }
  Cy_GPIO_GetInterruptCause0
  __STATIC_INLINE uint32_t Cy_GPIO_GetInterruptCause0(void)
  Returns the interrupt status for ports 0 to 31.
  Definition: cy_gpio.h:2325

## ◆ Cy_GPIO_GetInterruptCause1()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptCause1 | ( | void |  | ) |

Returns the interrupt status for ports 32 to 63.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Function Usage
  Refer to the Cy_GPIO_GetInterruptCause0() example.

## ◆ Cy_GPIO_GetInterruptCause2()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptCause2 | ( | void |  | ) |

Returns the interrupt status for ports 64 to 95.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Function Usage
  Refer to the Cy_GPIO_GetInterruptCause0() example.

## ◆ Cy_GPIO_GetInterruptCause3()

__STATIC_INLINE uint32_t Cy_GPIO_GetInterruptCause3 | ( | void |  | ) |

Returns the interrupt status for ports 96 to 127.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Function Usage
  Refer to the Cy_GPIO_GetInterruptCause0() example.

## ◆ Cy_GPIO_GetSecureInterruptCause0()

__STATIC_INLINE uint32_t Cy_GPIO_GetSecureInterruptCause0 | ( | void |  | ) |

Returns the interrupt status for ports 0 to 31.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Note
  This API is available for devices that support TrustZone.

Function Usage

## ◆ Cy_GPIO_GetSecureInterruptCause1()

__STATIC_INLINE uint32_t Cy_GPIO_GetSecureInterruptCause1 | ( | void |  | ) |

Returns the interrupt status for ports 32 to 63.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Note
  This API is available for devices that support TrustZone.

Function Usage

## ◆ Cy_GPIO_GetSecureInterruptCause2()

__STATIC_INLINE uint32_t Cy_GPIO_GetSecureInterruptCause2 | ( | void |  | ) |

Returns the interrupt status for ports 64 to 95.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Note
  This API is available for devices that support TrustZone.

Function Usage

## ◆ Cy_GPIO_GetSecureInterruptCause3()

__STATIC_INLINE uint32_t Cy_GPIO_GetSecureInterruptCause3 | ( | void |  | ) |

Returns the interrupt status for ports 96 to 127.

Returns
  0 = Interrupt not detected on port 1 = Interrupt detected on port

Note
  This API is available for devices that support TrustZone.

Function Usage

## ◆ Cy_GPIO_SetVddModeSel()

__STATIC_INLINE void Cy_GPIO_SetVddModeSel | ( | cy_en_gpio_vdd_mode_t | mode | ) |

Update voltage mode to 1.8V or 3.3V.

Parameters

  mode | Vdd mode selection enum cy_en_gpio_vdd_mode_t.