summaryrefslogtreecommitdiff
path: root/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
diff options
context:
space:
mode:
authorJorawar Singh2017-07-16 22:17:43 +0530
committerJorawar Singh2017-07-16 22:36:51 +0530
commitd9d92203ea349d5eb44c0edc5565d827322caabe (patch)
tree9bf874443e6e5a8ccd8fba3f5918297d95a194e8 /macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
parentce5c0f9d407d533364e9e7adc81e4d338e031383 (diff)
downloadScilab2C_fossee_old-d9d92203ea349d5eb44c0edc5565d827322caabe.tar.gz
Scilab2C_fossee_old-d9d92203ea349d5eb44c0edc5565d827322caabe.tar.bz2
Scilab2C_fossee_old-d9d92203ea349d5eb44c0edc5565d827322caabe.zip
Toolbox merge, RPI demos and structured demos
Diffstat (limited to 'macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci')
-rwxr-xr-xmacros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci54
1 files changed, 54 insertions, 0 deletions
diff --git a/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci b/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
new file mode 100755
index 0000000..4716de8
--- /dev/null
+++ b/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+function out=RPI_pinNumbering(pinSetup)
+// Function to initialize wiringpi with the number sequence to be followed.
+//
+// Calling Sequence
+// RPI_pinNumbering(pinSetup)
+//
+// Parameters
+// pinSetup: The pin number sequence to follow
+//
+// Description
+// This function must be called at the start of the program or the program will fail to work correctly. It tells the wiringpi which number sequence will be used to work on Raspberry Pi. Returns 0 if no errors encountered. Pin maps for the different pinSetups can be found at the link in bibliography.
+//
+// pinSetup can take the following values:
+// <itemizedlist>
+// <listitem>'wiringpi' -> This initialises wiringPi and assumes that the calling program is going to be using the wiringPi pin numbering scheme. This is a simplified numbering scheme which provides a mapping from virtual pin numbers to the real underlying Broadcom GPIO pin numbers.</listitem>
+// <listitem>'GPIO' -> Same as above, however it allows the calling programs to use the Broadcom GPIO pin numbers directly with no re-mapping.</listitem>
+// <listitem>'phys' -> Identical to above, however it allows the calling programs to use the physical pin numbers on the P1 connector only.</listitem>
+// </itemizedlist>
+//
+// Examples
+// RPI_pinNumbering('wiringpi')
+// Authors
+// Jorawar Singh
+//
+// Bibliography
+// http://wiringpi.com/reference/
+
+ if (pinSetup=='wiringpi') then
+ commande="pN0#0#";
+ elseif (pinSetup=='GPIO') then
+ commande="pN1#0#";
+ elseif (pinSetup=='sys') then
+ commande="pN2#0#";
+ elseif (pinSetup=='phys') then
+ commande="pN3#0#";
+ else
+ error("pinSetup should be one of wiringpi/GPIO/sys/phys");
+ end
+ if getos()=="Linux" then
+ out=unix_g("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()""");
+ elseif getos()=="Windows" then
+ [out,RPI_winR]=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()""");
+ end
+endfunction