summaryrefslogtreecommitdiff
path: root/src/c/hardware/rasberrypi/serial
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/hardware/rasberrypi/serial')
-rw-r--r--src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c35
-rw-r--r--src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c25
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c24
-rw-r--r--src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c26
-rw-r--r--src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c22
-rw-r--r--src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c34
-rw-r--r--src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c28
-rw-r--r--src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c23
-rw-r--r--src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c25
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c21
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c21
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c21
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c27
-rw-r--r--src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c22
19 files changed, 489 insertions, 0 deletions
diff --git a/src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c
new file mode 100644
index 0000000..f990255
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/dRPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send double data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void dRPISerialSendDataa(int fd, double* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; count++)
+ {
+ dRPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c
new file mode 100644
index 0000000..39112fc
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/dRPISerialSendDatas.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send double data on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void dRPISerialSendDatas(int fd, double data)
+{
+ uint8 count;
+
+ union double_bytes{
+ double double_data;
+ unsigned char bytes[sizeof(double)];
+ } in_data;
+
+ in_data.double_data = data;
+
+ for(count=0; count<sizeof(double); count++)
+ {
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) in_data.bytes[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c
new file mode 100644
index 0000000..f4ec8a8
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/gRPISerialSendDatas.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send string on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void gRPISerialSendDatas(int fd, uint8* data, int size)
+{
+ int count = 0;
+
+ while(data[count] != '\0')
+ {
+ serialPutchar(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c b/src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c
new file mode 100644
index 0000000..b56a819
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialDataAvails.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to check for data availability at specified port. Returns no of
+ bytes to be read */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+int16 i16RPISerialDataAvails(int fd)
+{
+ int bytes = 0;
+ bytes = serialDataAvail(fd);
+
+ return bytes;
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c b/src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c
new file mode 100644
index 0000000..18ca2a7
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialGetChars.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to read character from spcified serial port (file descriptor).
+ This function will block execution for 10 secs if no character is available,
+ and will return -1 in that case*/
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+int16 i16RPISerialGetChars(int fd)
+{
+ int data = 0;
+
+ data = serialGetchar(fd);
+
+ return data;
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c
new file mode 100644
index 0000000..24180f4
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 16-bit data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i16RPISerialSendDataa(int fd, int16* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ i16RPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c
new file mode 100644
index 0000000..fe6fe6f
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i16RPISerialSendDatas.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 16-bit byte on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i16RPISerialSendDatas(int fd, int16 data)
+{
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) data);
+ serialPutchar(fd, (uint8) (data>>8));
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c
new file mode 100644
index 0000000..c4dd199
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDataa.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 8-bit byte array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i8RPISerialSendDataa(int fd, int8* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ i8RPISerialSendDatas(fd, data[count]);
+ }
+}
diff --git a/src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c
new file mode 100644
index 0000000..e637871
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/i8RPISerialSendDatas.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send signed 8-bit byte on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void i8RPISerialSendDatas(int fd, int8 data)
+{
+ serialPutchar(fd, (uint8) data);
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c
new file mode 100644
index 0000000..14c0bc7
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/sRPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send float data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void sRPISerialSendDataa(int fd, float* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ sRPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c
new file mode 100644
index 0000000..ff78dd1
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/sRPISerialSendDatas.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send float data on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void sRPISerialSendDatas(int fd, float data)
+{
+ uint8 count;
+
+ union float_bytes{
+ float float_data;
+ unsigned char bytes[sizeof(float)];
+ } in_data;
+ in_data.float_data = data;
+
+ for(count=0; count<sizeof(float); count++)
+ {
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) in_data.bytes[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c
new file mode 100644
index 0000000..b444047
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDataa.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 16-bit data array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u16RPISerialSendDataa(int fd, uint16* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ u16RPISerialSendDatas(fd, data[count]);
+ }
+
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c
new file mode 100644
index 0000000..b4a90c2
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u16RPISerialSendDatas.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 16-bit data on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u16RPISerialSendDatas(int fd, uint16 data)
+{
+ /*Send lsb first*/
+ serialPutchar(fd, (uint8) data);
+ serialPutchar(fd, (uint8) (data>>8));
+}
diff --git a/src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c b/src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c
new file mode 100644
index 0000000..cde4cba
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u16RPISerialSetups.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to setup port with desired baud rate. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+int u16RPISerialSetups(char* port, int baudrate)
+{
+ int fd;
+
+ fd = serialOpen (port, baudrate);
+
+ return fd;
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c b/src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c
new file mode 100644
index 0000000..5162d15
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialCloses.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to close serial port opened. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialCloses(int fd)
+{
+ serialClose (fd);
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c b/src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c
new file mode 100644
index 0000000..c80a92c
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialFlushs.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to discards data serial buffer (received as well as waiting to be sent */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialFlushs(int fd)
+{
+ serialFlush(fd);
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c b/src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c
new file mode 100644
index 0000000..e381351
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialSendChars.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send 8-bit char on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialSendChars(int fd, uint8 data)
+{
+ serialPutchar(fd, data);
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c
new file mode 100644
index 0000000..9d09714
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDataa.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 8-bit byte array/matrix on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialSendDataa(int fd, uint8* data, int size)
+{
+ int count = 0;
+
+ for (count = 0; count < size; ++count)
+ {
+ u8RPISerialSendDatas(fd, data[count]);
+ }
+
+}
diff --git a/src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c
new file mode 100644
index 0000000..9edb439
--- /dev/null
+++ b/src/c/hardware/rasberrypi/serial/u8RPISerialSendDatas.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 - 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
+ Author: Siddhesh Wani
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+
+/* Function to send unsigned 8-bit byte on specified serial port. */
+
+#include "types.h"
+#include "RPIPeripheralSerial.h"
+
+void u8RPISerialSendDatas(int fd, uint8 data)
+{
+ serialPutchar(fd, data);
+
+}