Skip to content

GPIO Datasheet

中文说明

Overview

The gpio(general purpose input/output) IP is a fully parameterised soft IP recording the SoC architecture and ASIC backend informations. The IP features an APB4 slave interface, fully compliant with the AMBA APB Protocol Specification v2.0.

Feature

  • 1~32 channels support
  • Input and output direction control
  • Pin multiplexer with two alternate ouput function
  • Three configurable modes
    • input pull-down with schmitt trigger
    • ouput push-pull
    • alternate function push-pull
  • Maskable input interrupt with multiple triggering modes
    • rise mode
    • fall mode
    • high-level mode
    • low-level mode
  • Static synchronous design
  • Full synthesizable

Interface

port nametypedescription
apb4interfaceapb4 slave interface
gpio ->interfacegpio interface
gpio.gpio_in_iinputgpio data input
gpio.gpio_out_ooutputgpio data output
gpio.gpio_dir_ooutputgpio direction output
gpio.gpio_alt_in_ooutputalter io data output
gpio.gpio_alt_0_out_iinputalter 0 channel data output
gpio.gpio_alt_0_dir_iinputalter 0 channel direction output
gpio.gpio_alt_1_out_iinputalter 1 channel data output
gpio.gpio_alt_1_dir_iinputalter 1 channel direction output
gpio.irq_ooutputgpio interrupt output

Register

nameoffsetlengthdescription
PADDIR0x04pad direction register
PADIN0x44pad data in register
PADOUT0x84pad data out register
INTEN0xC4interrupt enable register
INTTYPE00x104interrupt type0 register
INTTYPE10x144interrupt type1 register
INTSTAT0x184interrupt state register
IOCFG0x1C4io configuration register
PINMUX0x204pin mux register

PAD Direction Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWDIR

reset value: 0x0000_0000

  • DIR: pad direction
    • DIR[i] = 1'b0: Ith gpio input
    • DIR[i] = 1'b1: Ith gpio output

PAD Data In Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]ROIN

reset value: 0x0000_0000

  • IN: pad data in

PAD Data Out Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWOUT

reset value: 0x0000_0000

  • OUT: pad data out

Interrupt Enable Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWINTEN

reset value: 0x0000_0000

  • INTEN: interrupt enable
    • INTEN[i] = 1'b0: disable Ith gpio input interrupt
    • INTEN[i] = 1'b1: otherwise

Interrupt Type0 Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWINTTYPE0

reset value: 0x0000_0000

  • INTTYPE0: interrupt type0

Interrupt Type1 Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWINTTYPE1

reset value: 0x0000_0000

  • INTTYPE1: interrupt type1

  • INTTYPE1 INTTYPE0 = 2'b00: high level trigger

  • INTTYPE1 INTTYPE0 = 2'b01: low level trigger

  • INTTYPE1 INTTYPE0 = 2'b10: rise edge trigger

  • INTTYPE1 INTTYPE0 = 2'b11: fall level trigger

Interrupt State Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]ROINTSTAT

reset value: 0x0000_0000

  • INTSTAT: interrupt state

IO Config Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWIOCFG

reset value: 0x0000_0000

  • IOCFG: io control mode config
    • IOCFG[i] = 1'b0: software control mode
    • IOCFG[i] = 1'b1: alternate control mode

Pin Mux Register

bitaccessdescription
[31:GPIO_NUM]nonereserved
[GPIO_NUM-1:0]RWPINMUX

reset value: 0x0000_0000

  • PINMUX: alternate io channel select
    • PINMUX[i] = 1'b0: alternate 0 channel io select
    • PINMUX[i] = 1'b1: alternate 1 channel io select

Program Guide

These registers can be accessed by 4-byte aligned read and write. C-like pseudocode output operation:

c
// software control
gpio.IOCFG[i]  = (uint32_t)0      // set to software control mode
gpio.PADDIR[i] = (uint32_t)0      // set Ith gpio ouput mode
gpio.PADOUT[i] = DATA_1_bit       // set Ith gpio output data
// alternate control
gpio.IOCFG[i]  = (uint32_t)1      // set to alternate io control mode
gpio.PINMUX[i] = (uint32_t)[0, 1] // set the alternate channel io
...                               // specific IP function config...

input operation:

c
gpio.IOCFG       = (uint32_t)0    // set to software control mode
gpio.PADDIR[i]   = (uint32_t)1    // set Ith gpio ouput mode
gpio.INTEN[i]    = (uint32_t)1    // enable Ith gpio irq
gpio.INTTYPE0[i] = (uint32_t)0    // set Ith gpio rise edge trigger
gpio.INTTYPE1[i] = (uint32_t)1    // set Ith gpio rise edge trigger

// polling mode
while(gpio.PADDIN[i] == 1) {}

// irq mode
...
gpio_handle(){
    irq_val = gpio.STAT           // read and clear irq flag
}

The trimmed reference keeps the RTL interface example only; it does not include a standalone GPIO software driver.

Resoureces

References

Revision History

文档以中文为第一语言,并提供对应英文版本。