Welcome, Guest

Author Topic: GPIO Problem  (Read 2095 times)

Bwakao

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
GPIO Problem
« on: January 13, 2015, 01:01:30 PM »
Hello !

I have an A10 with a LCD screen and i have a particulary problem.

In fact , i want managing a particulary PIN on the GPIO3 port with a C program : the PIN number 6, PB3.

I want to send "1" , to the PIN and check with a voltmeter. its simply  >:(


My code here :

#include <stdio.h>
#include <sys/io.h>
#include <unistd.h>

#undef extern



int main(int argc,char* argv[])
{
   printf("Debut du programme test du PIN");

   ioperm(0xB14,1,1);

   outb(1,0xB14);
   
   printf("fin du programme");
   
   return 0;
}


After compiling the program and execute the ".exe" called gpio , the terminal tell me "Segmentation Fault".

Im not sure about the adress of the GPIO3. On the manual , its write B14 for the PIN num 6 for GPIO3


If you have a solution , i would be happy to hear ;D

PS : sorry for my english .






kantal

  • Newbie
  • *
  • Posts: 35
  • Karma: +1/-0
Re: GPIO Problem
« Reply #1 on: January 13, 2015, 04:38:03 PM »
B14 is not an io port number, so it can't be used in ioperm().

MBR

  • Sr. Member
  • ****
  • Posts: 256
  • Karma: +19/-0
Re: GPIO Problem
« Reply #2 on: January 13, 2015, 09:41:16 PM »
Yes, it's just a name and it's usefull when accessing GPIO via sysfs interface. The direct I/O is necessary only when speed is critical, normal programs will be happy with the file-based sysfs interface in /sys.

BTW, the out() is for port-mapped IO, but most of ARM SoC I/O is memory-mapped, so you will probably need mmap() instead.

jmyreen

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +4/-0
Re: GPIO Problem
« Reply #3 on: January 14, 2015, 08:59:58 AM »
For more info on the sysfs interface MBR mentioned, see https://www.olimex.com/wiki/A10-OLinuXino-LIME#GPIO_under_Linux. The B14 is just the pin number (or ball number, since this is a Ball Grid Array part) on the A10 package.