| M480 BSP V3.05.001 The Board Support Package for M480 Series

Macros | Functions
GPIO Exported Functions
Standard Driver » GPIO Driver

## Macros
#define | GPIO_CLR_INT_FLAG(port, u32PinMask)
| Clear GPIO Pin Interrupt Flag. More...
#define | GPIO_DISABLE_DEBOUNCE(port, u32PinMask)
| Disable Pin De-bounce Function. More...
#define | GPIO_ENABLE_DEBOUNCE(port, u32PinMask)
| Enable Pin De-bounce Function. More...
#define | GPIO_DISABLE_DIGITAL_PATH(port, u32PinMask)
| Disable I/O Digital Input Path. More...
#define | GPIO_ENABLE_DIGITAL_PATH(port, u32PinMask)
| Enable I/O Digital Input Path. More...
#define | GPIO_DISABLE_DOUT_MASK(port, u32PinMask)
| Disable I/O DOUT mask. More...
#define | GPIO_ENABLE_DOUT_MASK(port, u32PinMask)
| Enable I/O DOUT mask. More...
#define | GPIO_GET_INT_FLAG(port, u32PinMask)
| Get GPIO Pin Interrupt Flag. More...
#define | GPIO_SET_DEBOUNCE_TIME(u32ClkSrc, u32ClkSel)
| Set De-bounce Sampling Cycle Time. More...
#define | GPIO_GET_IN_DATA(port)
| Get GPIO Port IN Data. More...
#define | GPIO_SET_OUT_DATA(port, u32Data)
| Set GPIO Port OUT Data. More...
#define | GPIO_TOGGLE(u32Pin)
| Toggle Specified GPIO pin. More...
#define | GPIO_EnableEINT
| Enable External GPIO interrupt. More...
#define | GPIO_DisableEINT
| Disable External GPIO interrupt. More...

## Functions
void | GPIO_SetMode (GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
| Set GPIO operation mode. More...
void | GPIO_EnableInt (GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
| Enable GPIO interrupt. More...
void | GPIO_DisableInt (GPIO_T *port, uint32_t u32Pin)
| Disable GPIO interrupt. More...
void | GPIO_SetSlewCtl (GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
| Set GPIO slew rate control. More...
void | GPIO_SetPullCtl (GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
| Set GPIO Pull-up and Pull-down control. More...

## Detailed Description

## Macro Definition Documentation

## ◆ GPIO_CLR_INT_FLAG

#define GPIO_CLR_INT_FLAG | ( |  | port,
|  |  | u32PinMask
| ) |  |

Clear GPIO Pin Interrupt Flag.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Clear the interrupt status of specified GPIO pin.

Definition at line 257 of file gpio.h.

## ◆ GPIO_DISABLE_DEBOUNCE

#define GPIO_DISABLE_DEBOUNCE | ( |  | port,
|  |  | u32PinMask
| ) |  |

Disable Pin De-bounce Function.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Disable the interrupt de-bounce function of specified GPIO pin.

Definition at line 273 of file gpio.h.

## ◆ GPIO_DISABLE_DIGITAL_PATH

#define GPIO_DISABLE_DIGITAL_PATH | ( |  | port,
|  |  | u32PinMask
| ) |  |

Disable I/O Digital Input Path.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Disable I/O digital input path of specified GPIO pin.

Definition at line 304 of file gpio.h.

## ◆ GPIO_DISABLE_DOUT_MASK

#define GPIO_DISABLE_DOUT_MASK | ( |  | port,
|  |  | u32PinMask
| ) |  |

Disable I/O DOUT mask.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Disable I/O DOUT mask of specified GPIO pin.

Definition at line 336 of file gpio.h.

## ◆ GPIO_DisableEINT

#define GPIO_DisableEINT

Disable External GPIO interrupt.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32Pin | The pin of specified GPIO port. It could be 0 ~ 15 for PA, PB, PC, PD, PF and PH GPIO port. It could be 0 ~ 13 for PE GPIO port. It could be 0 ~ 11 for PG GPIO port.

Returns
  None

This function is used to enable specified GPIO pin interrupt.

Definition at line 474 of file gpio.h.

## ◆ GPIO_ENABLE_DEBOUNCE

#define GPIO_ENABLE_DEBOUNCE | ( |  | port,
|  |  | u32PinMask
| ) |  |

Enable Pin De-bounce Function.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Enable the interrupt de-bounce function of specified GPIO pin.

Definition at line 288 of file gpio.h.

## ◆ GPIO_ENABLE_DIGITAL_PATH

#define GPIO_ENABLE_DIGITAL_PATH | ( |  | port,
|  |  | u32PinMask
| ) |  |

Enable I/O Digital Input Path.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Enable I/O digital input path of specified GPIO pin.

Definition at line 320 of file gpio.h.

## ◆ GPIO_ENABLE_DOUT_MASK

#define GPIO_ENABLE_DOUT_MASK | ( |  | port,
|  |  | u32PinMask
| ) |  |

Enable I/O DOUT mask.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Returns
  None

Enable I/O DOUT mask of specified GPIO pin.

Definition at line 352 of file gpio.h.

## ◆ GPIO_EnableEINT

#define GPIO_EnableEINT

Enable External GPIO interrupt.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32Pin | The pin of specified GPIO port. It could be 0 ~ 15 for PA, PB, PC, PD, PF and PH GPIO port. It could be 0 ~ 13 for PE GPIO port. It could be 0 ~ 11 for PG GPIO port.
  [in] | u32IntAttribs | The interrupt attribute of specified GPIO pin. It could be GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.

Returns
  None

This function is used to enable specified GPIO pin interrupt.

Definition at line 458 of file gpio.h.

## ◆ GPIO_GET_IN_DATA

#define GPIO_GET_IN_DATA | ( |  | port | ) |

Get GPIO Port IN Data.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.

Returns
  The specified port data

Get the PIN register of specified GPIO port.

Definition at line 414 of file gpio.h.

## ◆ GPIO_GET_INT_FLAG

#define GPIO_GET_INT_FLAG | ( |  | port,
|  |  | u32PinMask
| ) |  |

Get GPIO Pin Interrupt Flag.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.

Return values

  0 | No interrupt at specified GPIO pin
  1 | The specified GPIO pin generate an interrupt

Get the interrupt status of specified GPIO pin.

Definition at line 369 of file gpio.h.

## ◆ GPIO_SET_DEBOUNCE_TIME

#define GPIO_SET_DEBOUNCE_TIME | ( |  | u32ClkSrc,
|  |  | u32ClkSel
| ) |  |

Set De-bounce Sampling Cycle Time.

Parameters

  [in] | u32ClkSrc | The de-bounce counter clock source. It could be GPIO_DBCTL_DBCLKSRC_HCLK or GPIO_DBCTL_DBCLKSRC_LIRC.
  [in] | u32ClkSel | The de-bounce sampling cycle selection. It could be GPIO_DBCTL_DBCLKSEL_1 GPIO_DBCTL_DBCLKSEL_2 GPIO_DBCTL_DBCLKSEL_4 GPIO_DBCTL_DBCLKSEL_8 GPIO_DBCTL_DBCLKSEL_16 GPIO_DBCTL_DBCLKSEL_32 GPIO_DBCTL_DBCLKSEL_64 GPIO_DBCTL_DBCLKSEL_128 GPIO_DBCTL_DBCLKSEL_256 GPIO_DBCTL_DBCLKSEL_512 GPIO_DBCTL_DBCLKSEL_1024 GPIO_DBCTL_DBCLKSEL_2048 GPIO_DBCTL_DBCLKSEL_4096 GPIO_DBCTL_DBCLKSEL_8192 GPIO_DBCTL_DBCLKSEL_16384 GPIO_DBCTL_DBCLKSEL_32768

Returns
  None

Set the interrupt de-bounce sampling cycle time based on the debounce counter clock source.
Example: _GPIO_SET_DEBOUNCE_TIME(GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_4).
It's meaning the De-debounce counter clock source is internal 10 KHz and sampling cycle selection is 4.
Then the target de-bounce sampling cycle time is (4)*(1/(10*1000)) s = 4*0.0001 s = 400 us, and system will sampling interrupt input once per 00 us.

Definition at line 402 of file gpio.h.

## ◆ GPIO_SET_OUT_DATA

#define GPIO_SET_OUT_DATA | ( |  | port,
|  |  | u32Data
| ) |  |

Set GPIO Port OUT Data.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32Data | GPIO port data.

Returns
  None

Set the Data into specified GPIO port.

Definition at line 427 of file gpio.h.

## ◆ GPIO_TOGGLE

#define GPIO_TOGGLE | ( |  | u32Pin | ) |

Toggle Specified GPIO pin.

Parameters

  [in] | u32Pin | Pxy

Returns
  None

Toggle the specified GPIO pint.

Definition at line 439 of file gpio.h.

## Function Documentation

## ◆ GPIO_DisableInt()

void GPIO_DisableInt | ( | GPIO_T * | port,
|  | uint32_t | u32Pin
| ) |  |

Disable GPIO interrupt.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32Pin | The pin of specified GPIO port. It could be 0 ~ 15 for PA, PB, PC, PD, PF and PH GPIO port. It could be 0 ~ 13 for PE GPIO port. It could be 0 ~ 11 for PG GPIO port.

Returns
  None

This function is used to disable specified GPIO pin interrupt.

Definition at line 87 of file gpio.c.

## ◆ GPIO_EnableInt()

void GPIO_EnableInt | ( | GPIO_T * | port,
|  | uint32_t | u32Pin,
|  | uint32_t | u32IntAttribs
| ) |  |

Enable GPIO interrupt.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32Pin | The pin of specified GPIO port. It could be 0 ~ 15 for PA, PB, PC, PD, PF and PH GPIO port. It could be 0 ~ 13 for PE GPIO port. It could be 0 ~ 11 for PG GPIO port.
  [in] | u32IntAttribs | The interrupt attribute of specified GPIO pin. It could be GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.

Returns
  None

This function is used to enable specified GPIO pin interrupt.

Definition at line 67 of file gpio.c.

## ◆ GPIO_SetMode()

void GPIO_SetMode | ( | GPIO_T * | port,
|  | uint32_t | u32PinMask,
|  | uint32_t | u32Mode
| ) |  |

Set GPIO operation mode.

Parameters

  [in] | port | GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH.
  [in] | u32PinMask | The single or multiple pins of specified GPIO port. It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. It could be BIT0 ~ BIT13 for PE GPIO port. It could be BIT0 ~ BIT11 for PG GPIO port.
  [in] | u32Mode | Operation mode. It could be GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_OPEN_DRAIN, GPIO_MODE_QUASI.

Returns
  None

This function is used to set specified GPIO operation mode.

Definition at line 39 of file gpio.c.

## ◆ GPIO_SetPullCtl()

void GPIO_SetPullCtl | ( | GPIO_T * | port,
|  | uint32_t | u32PinMask,
|  | uint32_t | u32Mode
| ) |  |

Set GPIO Pull-up and Pull-down control.

Parameters

  [in] | port | GPIO port. It could be PA, PB, ... or GPH
  [in] | u32PinMask | The pin of specified GPIO port. It could be 0 ~ 15.
  [in] | u32Mode | The pin mode of specified GPIO pin. It could be GPIO_PUSEL_DISABLE GPIO_PUSEL_PULL_UP GPIO_PUSEL_PULL_DOWN

Returns
  None

Set the pin mode of specified GPIO pin.

Definition at line 133 of file gpio.c.

## ◆ GPIO_SetSlewCtl()

void GPIO_SetSlewCtl | ( | GPIO_T * | port,
|  | uint32_t | u32PinMask,
|  | uint32_t | u32Mode
| ) |  |

Set GPIO slew rate control.

Parameters

  [in] | port | GPIO port. It could be PA, PB, ... or GPH
  [in] | u32PinMask | The single or multiple pins of specified GPIO port.
  [in] | u32Mode | Slew rate mode. GPIO_SLEWCTL_NORMAL (maximum 40 MHz at 2.7V) GPIO_SLEWCTL_HIGH (maximum 80 MHz at 2.7V) GPIO_SLEWCTL_FAST (maximum 100 MHz at 2.7V)

Returns
  None

This function is used to set specified GPIO operation mode.

Definition at line 106 of file gpio.c.