Better Serial C++ class library with interrupt
Dependents: Dumb_box_rev2 mbed_GPSproject
iSerial class library can easy be used just by swapping Serial declarations.
API
iSerial | |
Examples
#include "mbed.h" #include "iSerial.h" char s[] = "12345678901234567890123456789012345678901234567890"; int main() { iSerial pc(USBTX,USBRX); char* c = s; while(1) { pc.puts(s); while(pc.readable()){ int ret = pc.getc(); if(ret) *c++ = ret; if(c >= s+sizeof(s)-1) c = s; } wait(1); } }
Example 2
Comparing speed of ordinary Serial functions
#include "mbed.h" #include "iSerial.h" char s[] = "12345678901234567890123456789012345678901234567890"; // 50 bytes int main() { Timer t; Serial pc(USBTX,USBRX); pc.baud(921600); t.reset(); t.start(); for(int i=0; i<30; i++) { pc.printf(s); wait(0.001); } t.stop(); int t1 = t.read_us(); pc.puts("\n\n\n"); iSerial ipc(USBTX,USBRX,NULL,1000,100); // try NOT to set the buffer over flowed // iSerial ipc(USBTX,USBRX); // set as default = 100, 100 ipc.baud(921600); t.reset(); t.start(); for(int i=0; i<30; i++) { ipc.printf(s); wait(0.001); } t.stop(); int t2 = t.read_us(); ipc.printf("\n\n\nThe time %d, %d [us] was taken.\n", t1, t2); ipc.puts("End."); ipc.flush(); }
History
bugfix of rx interrupt
2012-09-03, by ykuroda [Mon, 03 Sep 2012 17:59:00 +0000] rev 8
bugfix of rx interrupt
bugfix of tx interrupt
2012-09-03, by ykuroda [Mon, 03 Sep 2012 17:26:38 +0000] rev 7
bugfix of tx interrupt
flush added
2012-09-03, by ykuroda [Mon, 03 Sep 2012 12:01:55 +0000] rev 6
flush added
Now support both LPC1768 and LPC11U24. But it can be used for USBTX/USBRX. Others are unchecked.;
2012-09-03, by ykuroda [Mon, 03 Sep 2012 11:18:05 +0000] rev 5
Now support both LPC1768 and LPC11U24. But it can be used for USBTX/USBRX. Others are unchecked.;
printf using interrupt is implemented
2012-09-03, by ykuroda [Mon, 03 Sep 2012 09:15:34 +0000] rev 4
printf using interrupt is implemented
name change
2012-09-01, by ykuroda [Sat, 01 Sep 2012 12:28:28 +0000] rev 3
name change
Name change
2012-08-31, by ykuroda [Fri, 31 Aug 2012 17:32:00 +0000] rev 2
Name change
Including RingBuffer library
2012-08-31, by ykuroda [Fri, 31 Aug 2012 17:21:59 +0000] rev 1
Including RingBuffer library
1st coding
2012-08-31, by ykuroda [Fri, 31 Aug 2012 17:17:12 +0000] rev 0
1st coding