0

I need to do some changes in my audio card driver on the raspberry pi board.

What I need to do is: I have to check which model board it is and then I have to program the GPIO's based on the revision number that I get.

Can anyone suggest me how to do?

2
  • The first and second part of the question does not seem to belong together. What is it you want to achieve, really?
    – Bex
    Oct 8, 2014 at 7:23
  • 1
    You should have a look there Oct 8, 2014 at 7:29

1 Answer 1

2

I use the following code to extract the board revision.

unsigned gpioHardwareRevision(void)
{
   static unsigned rev = 0;

   FILE * filp;
   char buf[512];
   char term;

   if (rev) return rev;

   filp = fopen ("/proc/cpuinfo", "r");

   if (filp != NULL)
   {
      while (fgets(buf, sizeof(buf), filp) != NULL)
      {
         if (!strncasecmp("revision\t", buf, 9))
         {
            if (sscanf(buf+strlen(buf)-5, "%x%c", &rev, &term) == 2)
            {
               if (term == '\n') break;
               rev = 0;
            }
         }
      }
      fclose(filp);
   }
   return rev;
}

See http://elinux.org/RPi_HardwareHistory for the meaning of the returned numbers.

There are three different pinouts according to the revision.

If Revision < 4
   pinout type 1
else if Revision < 16
   pinout type 2
else
   pinout type 3

          0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
Type.1    X  X  -  -  X  -  -  X  X  X  X  X  -  -  X  X
Type.2    -  -  X  X  X  -  -  X  X  X  X  X  -  -  X  X
Type.3          X  X  X  X  X  X  X  X  X  X  X  X  X  X

         16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Type.1    -  X  X  -  -  X  X  X  X  X  -  -  -  -  -  -
Type.2    -  X  X  -  -  -  X  X  X  X  -  X  X  X  X  X
Type.3    X  X  X  X  X  X  X  X  X  X  X  X  -  -  -  -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.