summaryrefslogtreecommitdiff
path: root/2.3-1/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
diff options
context:
space:
mode:
authorBrijeshcr2017-07-20 19:39:55 +0530
committerBrijeshcr2017-07-20 19:39:55 +0530
commit215a24b64f6d0ec3fcef06c2634926f730b3dcc5 (patch)
tree48072b76fe009ec8423ba9e179fef964db666a3a /2.3-1/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
parent9a2e3e3174a9ff35ba9b739cec4a0b8c052a8dbe (diff)
parentdbf6486fa17d277729e0d6f77c2a6b93cbdd9424 (diff)
downloadScilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.tar.gz
Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.tar.bz2
Scilab2C-215a24b64f6d0ec3fcef06c2634926f730b3dcc5.zip
Added RPI demo and lcd128x64 fixed
Diffstat (limited to '2.3-1/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci')
-rwxr-xr-x2.3-1/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci54
1 files changed, 54 insertions, 0 deletions
diff --git a/2.3-1/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci b/2.3-1/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci
new file mode 100755
index 00000000..4716de80
--- /dev/null
+++ b/2.3-1/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