We're no longer updating This wiki!!

GPIO port register map

GPIO Configuration register

Pin Number GPIO name Base Address Offset Name Bit Type Description Reset Value
15GPX1.2 0x1340_0000 0x0C20 GPX1CON[2] [11:8] RW 0x0=input, 0x1=Output, 0x2=Reserved, 0x3=Reserved, 0x4=TraceData, 0x5 to 0xE=Reserved, 0xF=EXT_INT 0x00
18GPX1.3 GPX1CON[3] [15:12]
13GPX1.5 GPX1CON[5] [23:20]
17GPX1.6 GPX1CON[6] [27:24]
25GPX1.7 GPX1CON[7] [31:28]
26GPX2.0 0x0C40 GPX2CON[0] [3:0]
24GPX2.1 GPX2CON[1] [7:4]
20GPX2.4 GPX2CON[4] [19:16]
21GPX2.5 GPX2CON[5] [23:20]
19GPX2.6 GPX2CON[6] [27:24]
22GPX2.7 GPX2CON[7] [31:28]
27GPX3.1 0x0C60 GPX3CON[1] [7:4]
10GPA2.4 0x1401_0000 0x0040 GPA2CON[4] [19:16]
11GPA2.5 GPA2CON[5] [23:20]
9GPA2.6 GPA2CON[6] [27:24]
7GPA2.7 GPA2CON[7] [31:28]
16GPB3.2 0x00C0 GPB3CON[2] [11:8]
14GPB3.3 GPB3CON[3] [15:12]

GPIO Data register

GPIO name Base Address Offset Name Bit Type Description Reset Value
GPX1[n]0x1340_0000 0x0C24 GPX1DAT[7:0] [7:0] RWX When you configure the port as input port, the corresponding bit is the pin state. When you configure the port as output port, the pin state is same as the corresponding bit. When you configure the port as functional pin, it reads the undefined value. 0x00
GPX2[n] 0x0C44 GPX2DAT[7:0]
GPX3[n] 0x0C64 GPX3DAT[7:0]
GPA2[n]0x1401_0000 0x0044 GPA2DAT[7:0]
GPB3[n] 0x00C4 GPB3DAT[7:0]

GPIO Pull-up/down register

GPIO name Base Address Offset Name Bit Type Description Reset Value
GPX1[n]0x1340_0000 0x0C28 GPX1PUD[n] [2n+1:2n] n = 0 to 7 RW 0x0=Disables pull-up/down, 0x1=Enables pull-down, 0x2=Reserved, 0x3=Enables pull-up 0x5555
GPX2[n] 0x0C48 GPX2PUD[n]
GPX3[n] 0x0C68 GPX3PUD[n]
GPA2[n]0X1401_0000 0x0048 GPA2PUD[n]
GPB3[n] 0x00C8 GPB3PUD[n]

Memory mapped GPIO example

root@odroid:# gcc -o mmap_gpio mmap_gpio.c
root@odroid:# ./mmap_gpio
GPX1CON register : 0x100000f0                                                   
GPX1CON register : 0x100001f0                                                   
GPX1DAT register : 0x00000086                                                   
GPX1DAT register : 0x00000082
mmap_gpio.c
#include <stdio.h>                                                              
#include <fcntl.h>                                                              
#include <sys/mman.h>                                                           
#include <stdint.h>                                                             
 
static volatile uint32_t *gpio;                                                 
 
int main(int argc, char **argv)                                                 
{                                                                               
        int fd ;                                                                
 
        if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0) {                   
                printf("Unable to open /dev/mem\n");                            
                return -1;                                                      
        }                                                                       
 
        gpio = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,     
                                                                0x13400000);    
        if (gpio < 0){                                                          
                printf("Mmap failed.\n");                                       
                return -1;                                                      
        }                                                                       
 
        // Print GPX1 configuration register.                                   
        printf("GPX1CON register : 0x%08x\n",                                   
                                *(unsigned int *)(gpio + (0x0c20 >> 2)));       
 
        // Set direction of GPX1.2 configuration register as out.               
        *(gpio + (0x0c20 >> 2)) |= (0x1 << 8);                                  
        printf("GPX1CON register : 0x%08x\n",                                   
                                *(unsigned int *)(gpio + (0x0c20 >> 2)));       
        // GPX1.2 High                                                          
        *(gpio + (0x0c24 >> 2)) |= (1 << 2);                                    
        printf("GPX1DAT register : 0x%08x\n",                                   
                                *(unsigned int *)(gpio + (0x0c24 >> 2)));       
        // GPX1.2 Low                                                           
        *(gpio + (0x0c24 >> 2)) &= ~(1 << 2);                                   
        printf("GPX1DAT register : 0x%08x\n",                                   
                                *(unsigned int *)(gpio + (0x0c24 >> 2)));       
 
        return 0;                                                               
}
en/xu3_gpio_register.txt · Last modified: 2015/05/10 11:16 by odroid
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0