Pin Layouts - PlasmaTrout/Beaglebone-CLIB GitHub Wiki
Essentially the Beaglebone has two headers P8 and P9, each has 46 pins. In order to activate one of the pins its necessary to provide both the header and the pin number.
Each Pin can be in 7 different modes. In order to set these modes you must know the mux mode of a specific pin and its mux name. This is done by making a call to <beaglepins.h>:
Pin findPin(int header,int pin);
This returns back a struct named Pin that has the following items:
typedef struct { char muxname[20]; char pinname[10]; int pinnumber; int ionumber; } Pin;
NAME | DESCRIPTION |
---|---|
muxname | The mux name that you will need to use to set the mux mode of this pin. |
pinname | The common name of the pin (different from the mux name) |
pinnumber | The integral pin number as you would count it on the board |
ionumber | The actual io number that the beaglebone will append to gpioxx to define the pin |
There is an enum in beaglepins.h that helps with the mux mode. According to the Beaglebone documentation the mux modes are set with 0x0 through 0x7 and bits 4,5,6 help set specific parameters on those modes. The table looks like:
BIT | VALUE | PURPOSE | Enumerated Value |
---|---|---|---|
0 | 1 | Mux Mode 0x0 and 0x1 | RESERVED1 |
1 | 2 | Mux Mode 0x2 and 0x3 | RESERVED2 |
2 | 4 | Mux Mode 0x4,0x5,0x6,0x7 | RESERVED3 |
3 | 8 | Internal Resistor Disabled (1=Disabled, 0=Enabled) | DISABLE_PULLUP_RESISTOR |
4 | 16 | Pullup or Pulldown (1=Pullup, 0=Pulldown) | PULL_UP_NOT_DOWN |
5 | 32 | Received Enabled (1=Receive, 0=Transmit) | RX{ENABLED |
6 | 64 | Slew Control (1=Slow, 0=Fast) | SLEW_SLOW |
To use these values all you have to do is include <beaglepins.h> and voila! You can now use the enum values to find the hex codes to send to the setMuxMode functions.
#include <stdio.h> #include <beaglebone.h> #include <beaglepins.h> int main() { MuxMode mode = 0 | DISABLE_PULLUP_RESISTOR | PULL_UP_NOT_DOWN; printf("Mux Mode 0 Pullup Disabled/Pull Up Not Down is 0x%X \n",mode); }