Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CMSIS_DSP_401 GPS MPU9150_DMP PID QuaternionMath Servo mbed
Fork of SolarOnFoils_MainModule_20150518 by
Diff: uart.cpp
- Revision:
- 0:81b21910454e
diff -r 000000000000 -r 81b21910454e uart.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/uart.cpp Tue Jun 23 13:55:28 2015 +0000
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * Module : UART
+ * Copyright : 2008 - H. Arends
+ * Description : STK525 Driver
+ ******************************************************************************
+ Change History:
+
+ Version 0.2 - November 2011
+ > Port to mbed
+
+ Version 0.1 - March 2008
+ > Initial revision
+
+******************************************************************************/
+
+/******************************************************************************
+ Include files
+******************************************************************************/
+#include "mbed.h"
+
+#include "uart.h"
+
+
+/******************************************************************************
+ Global variables
+******************************************************************************/
+Serial pc(USBTX, USBRX); // Seri� verbinding met PC terminal
+
+
+/******************************************************************************
+ UART_ Function implementation
+******************************************************************************/
+void UART_vInitIO (void)
+{
+ // Initialise UART
+ pc.baud(BAUDRATE); // Baudrate
+ pc.format(8, Serial::None, 1); // UART Frame format
+}
+
+/******************************************************************************
+
+******************************************************************************/
+void UART_vPutStr (char *p)
+{
+ while(*p)
+ {
+ if(*p == LF) {UART_iPutCh(CR);}
+ UART_iPutCh(*p++);
+ }
+}
+
+/******************************************************************************
+
+******************************************************************************/
+void UART_vGetStr (unsigned short l, char *p)
+{
+ signed short t = 0;
+
+ while ((p[t] = UART_ucGetCh ()) != CR)
+ {
+ t++;
+ }
+ p[t] = '\0';
+}
+
+/******************************************************************************
+
+******************************************************************************/
+int UART_iPutCh (int c)
+{
+ return pc.putc(c);
+}
+
+/******************************************************************************
+
+******************************************************************************/
+unsigned char UART_ucGetCh (void)
+{
+ // wait for data received by the UART
+ // while ((UCSR1A & _BV(RXC1)) == 0) {;}
+ //return UDR1;
+ //return OS_iPutCh(UDR);
+ return pc.getc();
+}
+
+/******************************************************************************
+
+******************************************************************************/
+void UART_vPutStr_P (char *p)
+{
+ /*while(pgm_read_byte(p))
+ {
+ if(pgm_read_byte(p) == LF) {UART_iPutCh(CR);}
+ UART_iPutCh(pgm_read_byte(p++));
+ }*/
+ pc.printf(p);
+}
+
+/******************************************************************************
+
+******************************************************************************/
+void UART_vPutInt (int c)
+{
+ pc.printf("%i", c);
+}
+/******************************************************************************
+ EOF
+******************************************************************************/
