summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/hardware/avr/uart
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/hardware/avr/uart')
-rw-r--r--2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c88
-rw-r--r--2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c21
-rw-r--r--2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.c26
-rw-r--r--2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c31
-rw-r--r--2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c24
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.c27
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c73
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c31
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.c25
-rw-r--r--2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.c26
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.c28
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c87
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c38
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c20
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c215
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.c26
-rw-r--r--2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c60
17 files changed, 768 insertions, 78 deletions
diff --git a/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c
new file mode 100644
index 00000000..ec63c4de
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmits.c
@@ -0,0 +1,88 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Not Tested//
+#include "AVRPeripheralUART.h"
+#include<math.h>
+
+
+uint8 dAVRUARTTransmits(double data)
+{
+ //Extract integer part
+ long int intpart = (long int)data;
+ //Extract double part
+ //double floatpart = data - (double)intpart;
+ char* str;
+ int i = 0;
+ while(intpart)
+ {
+ str[i] = (intpart%10) + '0';
+ intpart = intpart/10;
+ i++;
+ }
+ str[i]='\0';
+ /*
+ int j = 0;
+ int k = i-1;
+ char temp;
+ while(j<k)
+ {
+ temp = str[j];
+ str[j] = str[k];
+ str[k] = temp;
+ j++;
+ k--;
+ }
+*/
+
+
+ /*
+ char* strfloat;
+ floatpart = floatpart*1000000000;
+ int l = 0;
+ while(floatpart)
+ {
+ strfloat[l] = ((unsigned int)floatpart%10) + '0';
+ floatpart = floatpart/10;
+ l++;
+ }
+ while(*strfloat!='\0')
+ {
+ str[i+1] = strfloat[l-1];
+ i++;
+ l--;
+ }
+ */
+
+ while(*str!='\0')
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = *str; // Put data into buffer, sends the data
+ str++;
+ }
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.c
new file mode 100644
index 00000000..8978cc00
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/dAVRUARTTransmitu8.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Char.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 dAVRUARTTransmitu8(uint8 data)
+{
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = data; // Put data into buffer, sends the data
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.c
new file mode 100644
index 00000000..fea9319d
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmita.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit String.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 gAVRUARTTransmita(uint8 *x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ gAVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c
new file mode 100644
index 00000000..502f2727
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmits.c
@@ -0,0 +1,31 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit String.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 gAVRUARTTransmits(char* msg,int size)
+{
+ while(*msg!='\0')
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = *msg; // Put data into buffer, sends the data
+ msg++;
+ }
+while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.c
new file mode 100644
index 00000000..f3384068
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/gAVRUARTTransmitu8.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit String.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 gAVRUARTTransmitu8(uint8 *msg)
+{
+ while(*msg!='\0')
+ {
+ AVRUARTTransmitChar(*msg);
+ msg++;
+ }
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.c
new file mode 100644
index 00000000..8d0fcd47
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmita.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i16AVRUARTTransmita(int16 *x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ i16AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
+
+
diff --git a/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c
new file mode 100644
index 00000000..4d907762
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmits.c
@@ -0,0 +1,73 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 i16AVRUARTTransmits(int16 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ uint8 temp3;
+ uint8 temp4;
+ uint8 temp5;
+ if(data<0)
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (45); // Put data into buffer, sends the data
+ }
+ data = abs(data);
+ temp1 = data/10000;
+ if(temp1==0);
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp1); // Put data into buffer, sends the data
+ }
+ data = data % 10000;
+ temp2 = data/1000;
+ if((temp1==0)&(temp2==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp2); // Put data into buffer, sends the data
+ }
+ data = data % 1000;
+ temp3 = data/100;
+ if((temp1==0)&(temp2==0)&(temp3==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp3); // Put data into buffer, sends the data
+ }
+ data = data % 100;
+ temp4 = data/10;
+ if((temp1==0)&(temp2==0)&(temp3==0)&(temp4==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp4); // Put data into buffer, sends the data
+ }
+ temp5 = data % 10;
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp5); // Put data into buffer, sends the data
+
+
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
diff --git a/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c
new file mode 100644
index 00000000..99638c77
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/i16AVRUARTTransmitu8.c
@@ -0,0 +1,31 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i16AVRUARTTransmitu8(int16 data)
+{
+ uint16 temp1;
+ uint16 temp2;
+ temp1 = abs(data)/100;
+ if(data<0)
+ AVRUARTTransmitChar(45);
+ AVRUARTTransmitChar(48+temp1);
+ temp1 = abs(data) - temp1*100;
+ temp2 = temp1;
+ temp1 = temp1/10;
+ AVRUARTTransmitChar(48+temp1);
+ temp2 = temp2 - temp1*10;
+ AVRUARTTransmitChar(48+temp2);
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.c
new file mode 100644
index 00000000..10345738
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmita.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i8AVRUARTTransmita(int8 *x,int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ i8AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.c
new file mode 100644
index 00000000..6b8c20fb
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/i8AVRUARTTransmits.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Signed Integer Values.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 i8AVRUARTTransmits(int8 data)
+{
+ uint8 temp1;
+ temp1 = abs(data);
+ if(data<0)
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (45); // Put data into buffer, sends the data
+ u8AVRUARTTransmits(temp1);
+ return 0;
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.c
new file mode 100644
index 00000000..8b8e6301
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmita.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Unsigned Integer Values.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u16AVRUARTTransmita(uint16 *x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ u16AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
+
+
+
+
diff --git a/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c
new file mode 100644
index 00000000..3cfb4a27
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmits.c
@@ -0,0 +1,87 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Unsigned Integer Values.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u16AVRUARTTransmits(uint16 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ uint8 temp3;
+ uint8 temp4;
+ uint8 temp5;
+ temp1 = data/10000;
+ if(temp1==0);
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp1); // Put data into buffer, sends the data
+ }
+ data = data % 10000;
+ temp2 = data/1000;
+ if((temp1==0)&(temp2==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp2); // Put data into buffer, sends the data
+ }
+ data = data % 1000;
+ temp3 = data/100;
+ if((temp1==0)&(temp2==0)&(temp3==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp3); // Put data into buffer, sends the data
+ }
+ data = data % 100;
+ temp4 = data/10;
+ if((temp1==0)&(temp2==0)&(temp3==0)&(temp4==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp4); // Put data into buffer, sends the data
+ }
+ temp5 = data % 10;
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp5); // Put data into buffer, sends the data
+
+
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c
new file mode 100644
index 00000000..a68a5aa9
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/u16AVRUARTTransmitu8.c
@@ -0,0 +1,38 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Unsigned Integer Values.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u16AVRUARTTransmitu8(uint16 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ uint8 temp3;
+ uint8 temp4;
+ temp1 = data/10000;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = data - temp1*10000;
+ temp2 = temp1;
+ temp1 = temp1/1000;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = temp2 - temp1*1000;
+ temp3 = temp1;
+ temp1 = temp1/100;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = temp3 - temp1*100;
+ temp4 = temp1;
+ temp1 = temp1/10;
+ dAVRUARTTransmitu8(48+temp1);
+ temp1 = temp4 - temp1*10;
+ dAVRUARTTransmitu8(48+temp1);
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c
new file mode 100644
index 00000000..df0a55b7
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTReceiveCharu8.c
@@ -0,0 +1,20 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Receive Char.
+
+#include "AVRPeripheralUART.h"
+
+uint8 u8AVRUSARTReceiveCharu8()
+{
+ while ( !(UCSRA & (1<<RXC)) ) ; // Wait for data to be received
+ return UDR; // Get and return received data from buffer
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c
index f311500a..085ac6e3 100644
--- a/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c
+++ b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTSetups.c
@@ -1,84 +1,143 @@
-// Function to initialise uart interface of AVR
-//
-// Calling Sequence
-// u8AVRUARTSetups(uint8 mode, uint8 baudrate, uint8 stopbits, uint8 parity)
-//
-// Parameters
-// mode : Mode of usart interface (0-Normal mode, 1-Double speed mode,
-// 2-Synchronous master mode)
-// baudrate : Baudrate for communication. Refer AVRPeripheralUART.h
-// for available options)
-// stopbits : No. of stopbits (0-1) for stopbits 1 and 2 resp.
-// parity: set parity bit. (0-disabled, 1-Even parity, 2-Odd parity)
-//
-//
-// Description
-// This function initialises uart interface for AVR. Available modes are
-// Normal mode (0), Double speed mode (1), Synchronous master mode(2). 'baudrate'
-// decides baudrate for communication. For baudrate settings, variable
-// 'XTAL_FREQUENCY' is required. 'stopbits' sets no of stopbits for data
-// packet. 0 for 1 stopbit and 1 for 2 stopbits. 'parity' decides parity bit
-// for communication. 0 for disabling parity bit, 1 for even parity and 2
-// for odd parity.
-//
-// Authors
-// Siddhesh Wani
-//
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Setup Serial communication for ATmega16.
+
#include "AVRPeripheralUART.h"
-uint8 u8AVRUARTSetups(uint8 mode, uint8 baudrate, uint8 stopbits, uint8 parity)
+uint8 u8AVRUARTSetups(uint8 mode, uint32 baudrate, uint8 stopbits, uint8 parity)
+{
+//Enable UART and USART
+ UCSRC |= (1<<URSEL);
+ UCSRB |= (1<<TXEN)|(1<<RXEN);
+
+ switch (mode) //According to mode set bits UMSEL and U2X
+{
+ case 0: //Normal mode
+ UCSRC &= ~(1<<UMSEL); //Clear bit 6 UMSEL and U2X=0
+ UCSRA &= ~(1<<U2X);
+ UCSRC &= ~(1<<UCPOL); // Clock polarity bit
+ break;
+
+ case 1: //Double speed mode
+ UCSRC &= ~(1<<UMSEL); //Clear bit 6 UMSEL and U2X=1
+ UCSRA |= (1<<U2X);
+ UCSRC &= ~(1<<UCPOL); //Clock polarity bit
+ break;
+
+ case 2: //Synchronous mode
+ UCSRC |= (1<<UMSEL); //Set bit 6 UMSEL and set clock polarity
+ UCSRC |= (1<<UCPOL);
+ break;
+}
+
+//Set stop bits
+if(stopbits == 0)
+{
+ UCSRC &= ~(1<<USBS); // 1 stopbit
+}
+else UCSRC |= (1<<USBS); //2 stopbits
+
+//Set parity bit settings
+switch(parity)
+{
+ case 0: // Parity disabled
+ UCSRC &= ~(1<<UPM1); //UPM1:0=0
+ UCSRC &= ~(1<<UPM0);
+ break;
+
+ case 1: // Even parity
+ UCSRC |= (1<<UPM1); //UPM1:0 = 2
+ UCSRC &= ~(1<<UPM0);
+ break;
+
+ case 2: // Odd parity
+ UCSRC |= (1<<UPM1); //UPM1:1 = 3
+ UCSRC |= (1<<UPM0);
+ break;
+}
+
+//Set baudrate
+UCSRC &= ~(1<<URSEL);
+switch(baudrate)
{
- switch (mode) //According to mode set bits UMSEL and U2X
- {
- case 0: //Normal mode
- UCSRC &= ~(1<<6); //Clear bit 6 UMSEL
- break;
-
- case 1: //Double speed mode
- UCSRC &= ~(1<<6); //Clear bit 6 UMSEL
- break;
-
- case 2: //Synchronous master mode
- UCSRC |= (1<<6); //Set bit 6 UMSEL
- break;
- }
-
- if(stopbits == 0)
- { // 1 stopbit
- UCSRC &= ~(1<<3);
- }
- else
- { // 2 stopbits
- UCSRC |= (1<<3);
- }
-
- //Set parity bit settings
- switch(parity)
- {
- case 0: // Parity disabled
- UCSRC &= ~(3<<4); //UPM1:0=0
- break;
- case 1:// Even parity
- UCSRC |= (1<<5); //UPM1:0 = 2
- UCSRC &= ~(1<<4);
- break;
- case 2:// Odd parity
- UCSRC |= (1<<5); //UPM1:1 = 3
- UCSRC |= (1<<4);
- break;
- }
-
- //Set baud rate
- # define BAUD baudrate
- #include "util/setbaud.h"
- UBRRH = UBRRH_VALUE;
- UBRRL = UBRRL_VALUE;
- #if USE_2X
- UCSRA |= (1 << U2X);
- #else
- UCSRA &= ~(1 << U2X);
- #endif
- return 0;
+ case 2400:
+ UBRRL = 0xA0;
+ UBRRH = 0x01;
+ break;
+
+ case 4800:
+ UBRRL = 0xCF;
+ UBRRH = 0x00;
+ break;
+
+ case 9600:
+ UBRRL = 0x67;
+ UBRRH = 0x00;
+ break;
+
+ case 14400:
+ UBRRL = 0x44;
+ UBRRH = 0x00;
+ break;
+
+ case 19200:
+ UBRRL = 0x33;
+ UBRRH = 0x00;
+ break;
+
+ case 28800:
+ UBRRL = 0x22;
+ UBRRH = 0x00;
+ break;
+
+ case 38400:
+ UBRRL = 0x19;
+ UBRRH = 0x00;
+ break;
+
+ case 57600:
+ UBRRL = 0x10;
+ UBRRH = 0x00;
+ break;
+
+ case 768000:
+ UBRRL = 0x0C;
+ UBRRH = 0x00;
+ break;
+
+ case 115200:
+ UBRRL = 0x08;
+ UBRRH = 0x00;
+ break;
+
+ case 230400:
+ UBRRL = 0x03;
+ UBRRH = 0x00;
+ break;
+
+ case 250000:
+ UBRRL = 0x03;
+ UBRRH = 0x00;
+ break;
+
+ case 1000000:
+ UBRRL = 0x00;
+ UBRRH = 0x00;
+ break;
}
+//Set data format
+UCSRC|= (1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1);
+
+ return 0;
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.c
new file mode 100644
index 00000000..14e2a0ea
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmita.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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Char.
+
+
+#include "AVRPeripheralUART.h"
+
+
+uint8 u8AVRUARTTransmita(uint8* x, int size)
+{
+ int i = 0;
+ for (i = 0; i < size; ++i)
+ {
+ u8AVRUARTTransmits(x[i]);
+ }
+ return 0;
+}
diff --git a/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c
new file mode 100644
index 00000000..e7e5c716
--- /dev/null
+++ b/2.3-1/src/c/hardware/avr/uart/u8AVRUARTTransmits.c
@@ -0,0 +1,60 @@
+/* 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: Ashish Kamble
+ Organization: FOSSEE, IIT Bombay
+ Email: toolbox@scilab.in
+*/
+//Function to Transmit Char.
+
+
+#include "AVRPeripheralUART.h"
+
+uint8 u8AVRUARTTransmits(uint8 data)
+{
+ uint8 temp1;
+ uint8 temp2;
+ temp1 = data;
+ data = data/100;
+ if(data==0);
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+data); // Put data into buffer, sends the data
+ }
+ temp1 = temp1 - data*100;
+ temp2 = temp1;
+ temp1 = temp1/10;
+ if((data==0)&(temp1==0));
+ else
+ {
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp1); // Put data into buffer, sends the data
+ }
+ temp2 = temp2 - temp1*10;
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (48+temp2); // Put data into buffer, sends the data
+
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (10); // Put data into buffer, sends the data
+ while ( !( UCSRA & (1<<UDRE)) ) ; // Wait for empty transmit buffer
+ UDR = (13); // Put data into buffer, sends the data
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+