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.
serial.h
00001 #ifndef SERIAL_H 00002 #define SERIAL_H 00003 #include <channels.h> 00004 #include <Mutexes.h> 00005 #include <processes.h> 00006 00007 #define UART1TX p9 00008 #define UART1RX p10 00009 00010 Serial USB(USBTX, USBRX); // tx, rx 00011 Serial XB(UART1TX, UART1RX); // tx, rx 00012 Serial *OUT = &USB; //intially set to USB 00013 00014 extern BusOut leds; 00015 void USB_serial() //signal RTOS event that RXinterrupt has been asserted 00016 { 00017 OS::TISRW ISRW; 00018 leds = 0x7; 00019 //char count = 0; 00020 //led3 = !led3; 00021 char temp = 0; 00022 00023 //leds = 0xa; 00024 if(true)//!Serial_Mutex.IsLocked()) 00025 { 00026 //leds = 0xb; 00027 //Serial_Mutex.Lock(); 00028 leds = 0xc; 00029 if(USB.readable()) 00030 { 00031 temp = USB.getc(); 00032 leds = 0xd; 00033 00034 if(RX_channel.get_free_size() >0 ) //only push a character onto the channel if there is free space 00035 { 00036 //OUT = &USB; 00037 if(temp != '\n') 00038 { 00039 RX_channel.push(temp); 00040 leds = 0xe; 00041 } 00042 else if(temp == '\n') 00043 { 00044 RX_channel.push('\0'); 00045 } 00046 } 00047 else USB.getc(); //start discarding characters!*/ 00048 leds = 0xf; 00049 leds = 0xa; 00050 } 00051 leds = 0xb; 00052 //Serial_Mutex.Unlock(); 00053 //Serial_Mutex.Lock(); 00054 //if(USB.writeable()) 00055 //USB.putc(temp); 00056 //Serial_Mutex.Unlock(); 00057 leds = 0x1; 00058 } 00059 else USB.getc(); //start discarding characters! 00060 00061 leds = 0x9; 00062 } 00063 00064 /*void XB_serial() 00065 { 00066 //led4 = !led4; 00067 char temp = 0; 00068 OS::TISRW ISRW; 00069 if(!XB_Mutex.IsLocked()) 00070 { 00071 XB_Mutex.Lock(); 00072 while(XB.readable()) 00073 { 00074 temp = XB.getc(); 00075 if(RX_channel.get_free_size() >0 ) //only push a character onto the channel if there is free space 00076 { 00077 OUT = &XB; 00078 if(temp != '\n') 00079 { 00080 RX_channel.push(temp); 00081 } 00082 else if(temp == '\n') 00083 { 00084 OUT = &XB; 00085 RX_channel.push('\0'); 00086 } 00087 } 00088 else temp = XB.getc(); //otherwise, wait until another character is sent and try then 00089 } 00090 XB_Mutex.Unlock(); 00091 } 00092 00093 00094 }*/ 00095 00096 #endif 00097
Generated on Wed Jul 13 2022 05:20:16 by
1.7.2