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.
Dependents: Frequency_Counter_w_GPS_1PPS FreqCntr_GPS1PPS_F746F4xx_w_recipro
Fork of iSerial by
Revision 3:d5353b68105f, committed 2012-09-01
- Comitter:
- ykuroda
- Date:
- Sat Sep 01 12:28:28 2012 +0000
- Parent:
- 2:3fc74f4d685a
- Child:
- 4:b38ef9675d39
- Commit message:
- name change
Changed in this revision
| iSerial.cpp | Show annotated file Show diff for this revision Revisions of this file |
| iSerial.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/iSerial.cpp Fri Aug 31 17:32:00 2012 +0000
+++ b/iSerial.cpp Sat Sep 01 12:28:28 2012 +0000
@@ -1,138 +1,138 @@
-//
-// iSerial.cpp ... Serial Driver with Interrupt Rec/Send
-//
-// 2009.11.13 ... Originally written by Y.Kuroda for Renesas H83664
-// 2012.08.31 ... Code convert for mbed in C++
-//
-#include "mbed.h"
-#include "RingBuffer.h"
-#include "iSerial.h"
-
-
-/*
- * Interrupt Function
- */
-void
-ISerial::rx_handler(void)
-{
- if(Serial::readable()){
- rxbuf.save(Serial::getc());
- }
-
- NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
-}
-
-void
-ISerial::tx_handler(void)
-{
- if(Serial::writeable()){
- if(txbuf.check()){
- Serial::putc( txbuf.read() );
- }
- }
- NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
-}
-
-/*
- * void sci_init(void)
- *
- *ããã¼ãåæå颿°ï¼ï¼ï¼ï¼ãã¹ã¦ã®I/Oã®è¨å®ãè¡ã£ã¦ããï¼
- *
- *ãã弿°ï¼ãªã
- *ããæ»ãå¤ï¼ãªã
- *
- */
-ISerial::ISerial(PinName _tx, PinName _rx, const char *_name, int _txbufsize, int _rxbufsize)
-: Serial(_tx, _rx, _name),
- txbuf(RingBuffer(_txbufsize)),
- rxbuf(RingBuffer(_rxbufsize))
-{
- __disable_irq();
-
- attach(this, &ISerial::tx_handler, Serial::TxIrq);
- attach(this, &ISerial::rx_handler, Serial::RxIrq);
-
-// format(8,Serial::None,1); // default
-// baud(baudrate);
-
- __enable_irq();
- NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
-}
-
-/*
- * ã·ãªã¢ã«å
¥åã«æåããããã©ãããã§ãã¯
- * è¿å¤ï¼ ãããã¡ã«ããæåæ°
- */
-int
-ISerial::readable(void)
-{
- return rxbuf.check();
-}
-
-/*
- * ã·ãªã¢ã«ãã䏿åå
¥å
- * --- æåå
¥åãå¾
ã¤
- */
-int
-ISerial::getc(void)
-{
- unsigned short int c;
-
- while(!rxbuf.check());
- c = rxbuf.read();
-
- return c;
-}
-
-
-/*
- *ãã·ãªã¢ã«ã¸ä¸æååºå
- */
-void
-ISerial::putc(short ch)
-{
- if(txbuf.check()==0 && Serial::writeable()){
- Serial::putc(ch);
-
- } else {
- while(txbuf.full());
- txbuf.save(ch);
- NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
- }
-}
-
-/*
- *ãã·ãªã¢ã«ã¸æååãåºå
- *ããæ³¨ï¼ä¸åã®æå¤§æåæ°ã¯LINESIZE
- *ããæ³¨ï¼æååã®çµããã«ã¯ãã«æåãå¿
è¦ï¼
- *
- *ãã弿°ï¼æååã¸ã®ãã¤ã³ã¿
- *ããè¿å¤ï¼åºåããæåæ°
- */
-short int
-ISerial::putstr(const char* s)
-{
- int i=0;
- for(; ; i++){
- if(*s==0) break;
- putc(*s++);
- }
- return i;
-}
-
-/*ãshort int sci_puts(char* s)
- *ãã·ãªã¢ã«ã¸æååãä¸è¡åºå
- *ããæ³¨ï¼æå¾ã«æ¹è¡ã³ã¼ããéãä»ã¯sci_putstrã¨åã
- *
- *ãã弿°ï¼æååã¸ã®ãã¤ã³ã¿
- *ããè¿å¤ï¼åºåããæåæ°
- */
-short int
-ISerial::puts(const char* s)
-{
- short int n = putstr(s);
- putc(CR);
- putc(LF);
- return n;
-}
-
+//
+// iSerial.cpp ... Serial Driver with Interrupt Rec/Send
+//
+// 2009.11.13 ... Originally written by Y.Kuroda for Renesas H83664
+// 2012.08.31 ... Code convert for mbed in C++
+//
+#include "mbed.h"
+#include "RingBuffer.h"
+#include "iSerial.h"
+
+
+/*
+ * Interrupt Function
+ */
+void
+iSerial::rx_handler(void)
+{
+ if(Serial::readable()){
+ rxbuf.save(Serial::getc());
+ }
+
+ NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
+}
+
+void
+iSerial::tx_handler(void)
+{
+ if(Serial::writeable()){
+ if(txbuf.check()){
+ Serial::putc( txbuf.read() );
+ }
+ }
+ NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
+}
+
+/*
+ * void sci_init(void)
+ *
+ *@|[gú»ÖDDDD·×ÄÌI/OÌÝèðsÁÄ¢éD
+ *
+ *@@øFȵ
+ *@@ßèlFȵ
+ *
+ */
+iSerial::iSerial(PinName _tx, PinName _rx, const char *_name, int _txbufsize, int _rxbufsize)
+: Serial(_tx, _rx, _name),
+ txbuf(RingBuffer(_txbufsize)),
+ rxbuf(RingBuffer(_rxbufsize))
+{
+ __disable_irq();
+
+ attach(this, &iSerial::tx_handler, Serial::TxIrq);
+ attach(this, &iSerial::rx_handler, Serial::RxIrq);
+
+// format(8,Serial::None,1); // default
+// baud(baudrate);
+
+ __enable_irq();
+ NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
+}
+
+/*
+ * VAüÍɶª é©Ç¤©`FbN
+ * ÔlF obt@É é¶
+ */
+int
+iSerial::readable(void)
+{
+ return rxbuf.check();
+}
+
+/*
+ * VA©çê¶üÍ
+ * --- ¶üÍðÒÂ
+ */
+int
+iSerial::getc(void)
+{
+ unsigned short int c;
+
+ while(!rxbuf.check());
+ c = rxbuf.read();
+
+ return c;
+}
+
+
+/*
+ *@VAÖê¶oÍ
+ */
+void
+iSerial::putc(short ch)
+{
+ if(txbuf.check()==0 && Serial::writeable()){
+ Serial::putc(ch);
+
+ } else {
+ while(txbuf.full());
+ txbuf.save(ch);
+ NVIC_EnableIRQ(UART_IRQn); // UART1_IRQn);
+ }
+}
+
+/*
+ *@VAÖ¶ñðoÍ
+ *@@FêñÌÅå¶ÍLINESIZE
+ *@@F¶ñÌIíèÉÍk¶ªKvD
+ *
+ *@@øF¶ñÖÌ|C^
+ *@@ÔlFo͵½¶
+ */
+short int
+iSerial::putstr(const char* s)
+{
+ int i=0;
+ for(; ; i++){
+ if(*s==0) break;
+ putc(*s++);
+ }
+ return i;
+}
+
+/*@short int sci_puts(char* s)
+ *@VAÖ¶ñðêsoÍ
+ *@@FÅãÉüsR[hðé¼Ísci_putstrƯ¶
+ *
+ *@@øF¶ñÖÌ|C^
+ *@@ÔlFo͵½¶
+ */
+short int
+iSerial::puts(const char* s)
+{
+ short int n = putstr(s);
+ putc(CR);
+ putc(LF);
+ return n;
+}
+
--- a/iSerial.h Fri Aug 31 17:32:00 2012 +0000
+++ b/iSerial.h Sat Sep 01 12:28:28 2012 +0000
@@ -1,80 +1,80 @@
-//
-// iSerial.h ... Serial Driver with Interrupt Rec/Send
-//
-// Copyright 2012 Yoji KURODA
-//
-// 2009.11.13 ... Originally written by Y.Kuroda for Renesas H83664
-// 2012.08.31 ... Code convert for mbed in C++
-//
-#ifndef _ISERIAL_H
-#define _ISERIAL_H
-
-#include <string.h>
-#include "RingBuffer.h"
-
-
-class ISerial : public Serial {
- protected:
-
- RingBuffer txbuf;
- RingBuffer rxbuf;
-
- void tx_handler(void);
- void rx_handler(void);
-
-
- public:
-
- enum TERMINL_CODES { CR=0x0D, LF=0x0A };
-
- /*
- * void init_sci(void)
- *
- *ããã¼ãåæå颿°ï¼ï¼ï¼ï¼ãã¹ã¦ã®I/Oã®è¨å®ãè¡ã£ã¦ããï¼
- *
- *ãã弿°ï¼ãªã
- *ããæ»ãå¤ï¼ãªã
- *
- */
- ISerial(PinName _tx, PinName _rx, const char *_name=NULL, int _txbufsize=100, int _rxbufsize=100);
-
- /*
- * ã·ãªã¢ã«å
¥åã«æåããããã©ãããã§ãã¯
- * è¿å¤ï¼ ï¼ããï¼æåããªã
- * ï¼ä»¥å¤ï¼æåãæ¥ã¦ãã
- */
- int readable(void);
-
- /*
- * ã·ãªã¢ã«ãã䏿åå
¥å
- */
- int getc(void);
-
- /*
- *ãã·ãªã¢ã«ã¸ä¸æååºå
- */
- void putc(short ch);
-
-
- /*
- *ãã·ãªã¢ã«ã¸æååãåºå
- *ããæ³¨ï¼ä¸åã®æå¤§æåæ°ã¯LINESIZE
- *ããæ³¨ï¼æååã®çµããã«ã¯ãã«æåãå¿
è¦ï¼
- *
- *ãã弿°ï¼æååã¸ã®ãã¤ã³ã¿
- *ããè¿å¤ï¼åºåããæåæ°
- */
- short int putstr(const char* s);
-
- /*ãvoid outs(char* s)
- *ãã·ãªã¢ã«ã¸æååãä¸è¡åºå
- *ããæ³¨ï¼æå¾ã«æ¹è¡ã³ã¼ããéãä»ã¯outstrã¨åã
- *
- *ãã弿°ï¼æååã¸ã®ãã¤ã³ã¿
- *ããè¿å¤ï¼åºåããæåæ°
- */
- short int puts(const char* s);
-};
-
-
-#endif /* _SCI_H */
+//
+// iSerial.h ... Serial Driver with Interrupt Rec/Send
+//
+// Copyright 2012 Yoji KURODA
+//
+// 2009.11.13 ... Originally written by Y.Kuroda for Renesas H83664
+// 2012.08.31 ... Code convert for mbed in C++
+//
+#ifndef _ISERIAL_H
+#define _ISERIAL_H
+
+#include <string.h>
+#include "RingBuffer.h"
+
+
+class iSerial : public Serial {
+ protected:
+
+ RingBuffer txbuf;
+ RingBuffer rxbuf;
+
+ void tx_handler(void);
+ void rx_handler(void);
+
+
+ public:
+
+ enum TERMINL_CODES { CR=0x0D, LF=0x0A };
+
+ /*
+ * void init_sci(void)
+ *
+ *@|[gú»ÖDDDD·×ÄÌI/OÌÝèðsÁÄ¢éD
+ *
+ *@@øFȵ
+ *@@ßèlFȵ
+ *
+ */
+ iSerial(PinName _tx, PinName _rx, const char *_name=NULL, int _txbufsize=100, int _rxbufsize=100);
+
+ /*
+ * VAüÍɶª é©Ç¤©`FbN
+ * ÔlF O@@F¶ªÈ¢
+ * OÈOF¶ªÄ¢é
+ */
+ int readable(void);
+
+ /*
+ * VA©çê¶üÍ
+ */
+ int getc(void);
+
+ /*
+ *@VAÖê¶oÍ
+ */
+ void putc(short ch);
+
+
+ /*
+ *@VAÖ¶ñðoÍ
+ *@@FêñÌÅå¶ÍLINESIZE
+ *@@F¶ñÌIíèÉÍk¶ªKvD
+ *
+ *@@øF¶ñÖÌ|C^
+ *@@ÔlFo͵½¶
+ */
+ short int putstr(const char* s);
+
+ /*@void outs(char* s)
+ *@VAÖ¶ñðêsoÍ
+ *@@FÅãÉüsR[hðé¼ÍoutstrƯ¶
+ *
+ *@@øF¶ñÖÌ|C^
+ *@@ÔlFo͵½¶
+ */
+ short int puts(const char* s);
+};
+
+
+#endif /* _SCI_H */
