summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/hardware/rasberrypi
diff options
context:
space:
mode:
authorsiddhu89902016-06-27 19:16:41 +0530
committersiddhu89902016-06-27 19:16:41 +0530
commitd7d53dc95a7cb9878a4e49bdd06e626e981b0eb2 (patch)
tree9f918cd4dfba745362e0cf3341c1eb65ac239dd3 /2.3-1/src/c/hardware/rasberrypi
parent7e9419d65013fa1109dd67deaabf77aa34011a35 (diff)
downloadScilab2C-d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2.tar.gz
Scilab2C-d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2.tar.bz2
Scilab2C-d7d53dc95a7cb9878a4e49bdd06e626e981b0eb2.zip
test commit
Diffstat (limited to '2.3-1/src/c/hardware/rasberrypi')
-rw-r--r--2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c20
-rw-r--r--2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c21
-rw-r--r--2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c32
-rw-r--r--2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h2
-rw-r--r--2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h2
5 files changed, 24 insertions, 53 deletions
diff --git a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
index 8ce0b3ce..d9ff093f 100644
--- a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
+++ b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c
@@ -10,29 +10,15 @@
Email: toolbox@scilab.in
*/
-/* Function to read the state of the gpio pin
-
- Calling Sequence
- u8RPI_DigitalIn(pin)
-
- Parameters
- pin : pin of RPi to be read
-
- Returns
- state: Current state of the specified gpio pin
-
- Description
- There are few pins available on RPi as Gpio or digital i/o. These pins can be used as digital output or input. Using this function, current state (low/high) of any gpio pin can be read. 'pin' name must be provided from list provided. Please refer '' for complete list of pins. 'state' can be 0 or 1 depending upon state of the pin (Low/High). RPI_DigitalSetup with appropriate arguments must be called before using this function.
- Examples
- u8RPI_DigitalIn(RPI_GPIO_P1_03,1) //Returns the state of pin 3 of header P1
-*/
+/* Function to read the state of the gpio pin */
#include "types.h"
#include "RPIPeripheralDigital.h"
+/*pin is reduced by one as array index starts from 0 and pin no starts from 1*/
uint8 u8RPIDigitalIns(uint8 pin)
{
uint8 state = 0;
- state = bcm2835_gpio_lev(pin);
+ state = bcm2835_gpio_lev(phy_pin[pin-1]);
return (state);
}
diff --git a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
index d97f4588..97c6a034 100644
--- a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
+++ b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c
@@ -10,30 +10,17 @@
Email: toolbox@scilab.in
*/
-/* Function to change the output state of the gpio pin
-
- Calling Sequence
- u8RPI_DigitalOuts(pin,state)
-
- Parameters
- pin : pin of RPi to be used
- state : desired output state for pin (0 -> LOW, 1 -> HIGH)
-
- Description
- There are few pins available on RPi as Gpio or digital i/o. 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. 'state' can be 0 or 1 depending upon desired output (Low/High). RPI_DigitalSetup with appropriate arguments must be called before using this function.
- Examples
- u8RPI_DigitalOuts(RPI_GPIO_P1_03,1) //Sets pin 3 of header P1 as 'high' output
-*/
+/* Function to change the output state of the gpio pin */
#include "types.h"
#include "RPIPeripheralDigital.h"
-
+/*pin is reduced by one as arrayiindex starts from 0 and pin no starts from 1*/
uint8 u8RPIDigitalOuts(uint8 pin, uint8 state)
{
if (state == 0) //low output
- bcm2835_gpio_clr(pin);
+ bcm2835_gpio_clr(phy_pin[pin-1]);
if (state == 1) //high output
- bcm2835_gpio_set(pin);
+ bcm2835_gpio_set(phy_pin[pin-1]);
}
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;
}
diff --git a/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h
index 87fe7dc0..e56366c3 100644
--- a/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h
+++ b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h
@@ -23,6 +23,8 @@ extern "C" {
#include "types.h"
#include "bcm2835.h"
+extern int phy_pin[];
+
uint8 u8RPIDigitalSetups(uint8 pin, uint8 direction);
uint8 u8RPIDigitalOuts(uint8 pin, uint8 state);
uint8 u8RPIDigitalIns(uint8 pin);
diff --git a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h
index 056f3cb8..40a8e1a4 100644
--- a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h
+++ b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h
@@ -22,7 +22,7 @@ extern "C" {
#define RPI_DigitalSetup(in1,in2) u8RPIDigitalSetups((uint8) in1, (uint8) in2);
-#define RPI_DigitalIn(in1,in2) u8RPIDigitalIns((uint8) in1);
+#define RPI_DigitalIn(in1) u8RPIDigitalIns((uint8) in1);
#define RPI_DigitalOut(in1,in2) u8RPIDigitalOuts((uint8) in1, (uint8) in2);