summaryrefslogtreecommitdiff
path: root/src/c/hardware/rasberrypi/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/hardware/rasberrypi/gpio')
-rw-r--r--src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c2
-rw-r--r--src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c6
-rw-r--r--src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c15
3 files changed, 12 insertions, 11 deletions
diff --git a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
index d9ff093..7b84350 100644
--- a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
+++ b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
@@ -19,6 +19,6 @@
uint8 u8RPIDigitalIns(uint8 pin)
{
uint8 state = 0;
- state = bcm2835_gpio_lev(phy_pin[pin-1]);
+ state = digitalRead(phy_pin[pin-1]);
return (state);
}
diff --git a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
index 97c6a03..d40263f 100644
--- a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
+++ b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
@@ -16,11 +16,11 @@
#include "types.h"
#include "RPIPeripheralDigital.h"
-/*pin is reduced by one as arrayiindex starts from 0 and pin no starts from 1*/
+/*pin is reduced by one as array index starts from 0 and pin no starts from 1*/
uint8 u8RPIDigitalOuts(uint8 pin, uint8 state)
{
if (state == 0) //low output
- bcm2835_gpio_clr(phy_pin[pin-1]);
+ digitalWrite(phy_pin[pin-1], LOW);
if (state == 1) //high output
- bcm2835_gpio_set(phy_pin[pin-1]);
+ digitalWrite(phy_pin[pin-1], HIGH);
}
diff --git a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c
index 79668b1..163f0c8 100644
--- a/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c
+++ b/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c
@@ -12,28 +12,29 @@
/* Function to setup digital pins
direction = 1 -> output
+ direction = 0 -> input
*/
#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*/
+/*This array maps pin numbers on RPi board, with pin numbers corrsponding
+to WiringPi library*/
+int phy_pin[] = {17, 17, 8, 17, 9, 17, 7, 15, 17, 16, /*Pin 1 to 10*/
+ 0, 1, 2, 17, 3, 4, 17, 5, 12, 17, /*Pin 11 to 20*/
+ 13, 6, 14, 10, 17, 11 }; /*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(phy_pin[pin-1], BCM2835_GPIO_FSEL_OUTP);
+ pinMode(phy_pin[pin-1], OUTPUT);
}
else
{
- bcm2835_gpio_fsel(phy_pin[pin-1], BCM2835_GPIO_FSEL_INPT);
+ pinMode(phy_pin[pin-1], INPUT);
}
return 0;