diff options
author | siddhu8990 | 2016-06-27 19:16:41 +0530 |
---|---|---|
committer | siddhu8990 | 2016-06-27 19:16:41 +0530 |
commit | d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2 (patch) | |
tree | 9f918cd4dfba745362e0cf3341c1eb65ac239dd3 /2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c | |
parent | 7e9419d65013fa1109dd67deaabf77aa34011a35 (diff) | |
download | Scilab2C-d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2.tar.gz Scilab2C-d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2.tar.bz2 Scilab2C-d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2.zip |
test commit
Diffstat (limited to '2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c')
-rw-r--r-- | 2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c index 657df3a1..79668b16 100644 --- a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c +++ b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c @@ -10,35 +10,31 @@ Email: toolbox@scilab.in */ -/* Function to setup digital pins. - - Calling Sequence - u8RPI_DigitalSetup(pin,direction) - - Parameters - pin : pin of RPi to be used - direction : direction to be set for pin (0 -> INPUT, 1 -> OUTPUT) - - Description - There are few pins available on RPi as Gpio or digital io. These pins can be used as digital output or input. Pin name must be provided from list provided. Please refer '' for complete list of pins. Direction can be 0 or 1 depending upon desired function (Input/output) - Examples - RPI_DigitalSetup(RPI_GPIO_P1_03,0) //Sets pin 3 of header P1 as input - - See also - RPI_DigitalIn RPI_DigitalOut +/* Function to setup digital pins + direction = 1 -> output */ #include "types.h" #include "RPIPeripheralDigital.h" + +/*This array maps pin numbers on RPi board, with actual physical pin numbers +on processor, required by BCM2835 library*/ +int phy_pin[] = {0, 0, 2, 0, 3, 0, 4, 14, 0, 15, /*Pin 1 to 10*/ + 17, 18, 27, 0, 22, 23, 0, 24, 10, 0, /*Pin 11 to 20*/ + 9, 25, 11, 8, 0, 7 }; /*Pin 21 to 26*/ + +/*pin is reduced by one as arrayiindex starts from 0 and pin no starts from 1*/ uint8 u8RPIDigitalSetups(uint8 pin, uint8 direction) { if(direction == 1) //Pin to be used as output { - bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP); + bcm2835_gpio_fsel(phy_pin[pin-1], BCM2835_GPIO_FSEL_OUTP); } else { - bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_INPT); + bcm2835_gpio_fsel(phy_pin[pin-1], BCM2835_GPIO_FSEL_INPT); } + + return 0; } |