Bananian

Low-level GPIO port in Linux

0 58
ter  
Hello,
on Banana Pro board i try to chage GPIO data in the processor (not using wiringPI library)
I want to write register like that

int fd = open ("/dev/mem", O_RDWR | O_SYNC);
unsigned long* gpio1 = (unsigned long *)mmap(NULL, 8*1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x01C20000);
*(gpio1 + 0x800) = 0x31111111;

When i read memory again the changing data is lost.

I want to change GPIO port such as in wiringPi library lile that

  1. wiringPiSetup();
  2. pinMode(22, OUTPUT);
  3. digitalWrite(22, 1);
Copy the Code

In datasheet

Module Name Base Address
PIO 0x01C20800   
Register Name Offset Description
Pn_CFG0 n*0x24+0x00 Port n Configure Register 0 (n from 0 to 9)
Pn_CFG1 n*0x24+0x04 Port n Configure Register 1 (n from 0 to 9)
Pn_CFG2 n*0x24+0x08 Port n Configure Register 2 (n from 0 to 9)
Pn_CFG3 n*0x24+0x0C Port n Configure Register 3 (n from 0 to 9)

0x01C20800 - is an address of the configuration port (input, output or other mode)

What information i must concentrate for understanding to change port?

Thank you

You have to log in before you can reply Login | Sign Up

Points Rules