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
iSerial.h
00001 // 00002 // iSerial.h ... Serial Driver with Interrupt Rec/Send 00003 // 00004 // Copyright 2012 Yoji KURODA 00005 // 00006 // 2009.11.13 ... Originally written by Y.Kuroda for Renesas H83664 00007 // 2012.08.31 ... Code convert for mbed in C++ 00008 // 2015.01.02 ... Added other mbed code by JH1PJL 00009 // 2016.11.11 ... Added STM32F746 with durty solution 00010 // 00011 #ifndef _ISERIAL_H 00012 #define _ISERIAL_H 00013 00014 #include <string.h> 00015 #include "RingBuffer.h" 00016 00017 /** iSerial class 00018 * 00019 * @code 00020 * #include "mbed.h" 00021 * #include "iSerial.h" 00022 * 00023 * iSerial pc(USBTX, USBRX, 32, 1024); 00024 * 00025 * int main() { 00026 * uint32_t n = 0; 00027 * 00028 * while(true){ 00029 * pc.printf("count n=%d", ++n); 00030 * wait(1.0); 00031 * } 00032 * } 00033 * @endcode 00034 */ 00035 00036 class iSerial : public Serial { 00037 protected: 00038 00039 PinName tx; 00040 PinName rx; 00041 const int txbufsize; 00042 const int rxbufsize; 00043 RingBuffer txbuf; 00044 RingBuffer rxbuf; 00045 char* str; 00046 00047 void tx_handler(void); 00048 void rx_handler(void); 00049 void enable_uart_irq(void); 00050 void disable_uart_irq(void); 00051 00052 public: 00053 00054 enum TERMINL_CODES { CR=0x0D, LF=0x0A }; 00055 00056 /** Configure pin and buffer size 00057 * @param pin assign TX, RX the buffer size for TX, RX 00058 */ 00059 iSerial(PinName _tx, PinName _rx, int _txbufsize=100, int _rxbufsize=100); 00060 00061 virtual ~iSerial(); 00062 00063 short int putstr(const char* s); 00064 int readable(void); 00065 int getc(void); 00066 void putc(short ch); 00067 short int puts(const char* s); 00068 //void printf(); 00069 char* printf(const char* format, ...); 00070 00071 void flush(void); 00072 }; 00073 00074 #endif /* _ISERIAL_H */
Generated on Wed Jul 13 2022 12:22:36 by
1.7.2
