chiark / gitweb /
Updated mostly to the gpio readall command to support the Raspberry Pi B+
[wiringPi.git] / gpio / pins.c
1 /*
2  * pins.c:
3  *      Just display a handy Pi pinnout diagram.
4  *      Copyright (c) 2012-2013 Gordon Henderson
5  ***********************************************************************
6  * This file is part of wiringPi:
7  *      https://projects.drogon.net/raspberry-pi/wiringpi/
8  *
9  *    wiringPi is free software: you can redistribute it and/or modify
10  *    it under the terms of the GNU Lesser General Public License as published by
11  *    the Free Software Foundation, either version 3 of the License, or
12  *    (at your option) any later version.
13  *
14  *    wiringPi is distributed in the hope that it will be useful,
15  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *    GNU Lesser General Public License for more details.
18  *
19  *    You should have received a copy of the GNU Lesser General Public License
20  *    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
21  ***********************************************************************
22  */
23
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <stdint.h>
28 #include <ctype.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <errno.h>
32 #include <fcntl.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
35
36 #include <wiringPi.h>
37
38 extern int wpMode ;
39
40 void doPins (void)
41 {
42   int model, rev, mem ;
43   char *maker ;
44
45   piBoardId (&model, &rev, &mem, &maker) ;
46   if (model == PI_MODEL_CM)
47   {
48     printf ("This Raspberry Pi is a Compute Module.\n") ;
49     printf ("    (who knows what's been done to the pins!)\n") ;
50     return ;
51   }
52
53   printf ("This Raspberry Pi is a revision %d board.\n", piBoardRev ()) ;
54
55   printf (
56 " +-----+--------+------------+--------+-----+\n"
57 " | Pin |   Name ||  P1 Pin  ||  Name  | Pin |\n"
58 " +-----+--------+------------+--------+-----+\n"
59 " |     |  3.3v  ||  1 oo 2  ||     5v |     |\n"
60 " |   8 |   SDA  ||  3 oo 4  ||     5v |     |\n"
61 " |   9 |    SCL ||  5 oo 6  ||    Gnd |     |\n"
62 " |   7 | GPIO 7 ||  7 oo 8  ||    TxD |  15 |\n"
63 " |     |    GND ||  9 oo 10 ||    RxD |  16 |\n"
64 " |   0 | GPIO 0 || 11 oo 12 || GPIO 1 |   1 |\n"
65 " |   2 | GPIO 2 || 13 oo 14 ||    Gnd |     |\n"
66 " |   3 | GPIO 3 || 15 oo 16 || GPIO 4 |   4 |\n"
67 " |     |   3.3v || 17 oo 18 || GPIO 5 |   5 |\n"
68 " |  12 |   MOSI || 19 oo 20 ||    Gnd |     |\n"
69 " |  13 |   MISO || 21 oo 22 || GPIO 6 |   6 |\n"
70 " |  14 |   SCLK || 23 oo 24 ||   CE 0 |  10 |\n"
71 " |     |    Gnd || 25 oo 26 ||   CE 1 |  11 |\n"
72 " +-----+--------+------------+--------+-----+\n") ;
73
74 /***
75  +---
76  |  5v|  5v| Gnd | TxD | RxD | G1  | Gnd |  G4  |  G5  | G
77  |  2 |  4 |  6 |  8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 |\n"
78  |  1 |  3 |  5 |  7 |  9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 |\n"
79 ***/
80
81 }