xrocusOS_ADXL355 version
Dependencies: mbed SDFileSystem
include/UartReceiver.h@20:2f2687580ecb, 2019-07-05 (annotated)
- Committer:
- APS_Lab
- Date:
- Fri Jul 05 02:09:06 2019 +0000
- Revision:
- 20:2f2687580ecb
- Parent:
- 0:c347f602596d
Ver0.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Inscape_ao | 0:c347f602596d | 1 | #ifndef _UARTRECEIVER_H_ |
Inscape_ao | 0:c347f602596d | 2 | #define _UARTRECEIVER_H_ |
Inscape_ao | 0:c347f602596d | 3 | |
Inscape_ao | 0:c347f602596d | 4 | |
Inscape_ao | 0:c347f602596d | 5 | /** --- Includes --- */ |
Inscape_ao | 0:c347f602596d | 6 | #include "mbed.h" |
Inscape_ao | 0:c347f602596d | 7 | |
Inscape_ao | 0:c347f602596d | 8 | /** --- Global Structs --- */ |
Inscape_ao | 0:c347f602596d | 9 | class UartReceiver |
Inscape_ao | 0:c347f602596d | 10 | { |
Inscape_ao | 0:c347f602596d | 11 | private: |
Inscape_ao | 0:c347f602596d | 12 | /** defines */ |
Inscape_ao | 0:c347f602596d | 13 | static const int RXBUF_SIZE = 64; |
Inscape_ao | 0:c347f602596d | 14 | static const int RXBUF_NEST = 4; |
Inscape_ao | 0:c347f602596d | 15 | static const int BufOpen = 0; |
Inscape_ao | 0:c347f602596d | 16 | static const int BufFixed = 1; |
Inscape_ao | 0:c347f602596d | 17 | public: |
Inscape_ao | 0:c347f602596d | 18 | static const int MaxStr = (RXBUF_SIZE - 1); |
Inscape_ao | 0:c347f602596d | 19 | |
Inscape_ao | 0:c347f602596d | 20 | private: |
Inscape_ao | 0:c347f602596d | 21 | /** varialbles */ |
Inscape_ao | 0:c347f602596d | 22 | Serial *pUart; |
Inscape_ao | 0:c347f602596d | 23 | void(*pLineHandler)(char*); |
Inscape_ao | 0:c347f602596d | 24 | char inner_buffer[RXBUF_NEST][RXBUF_SIZE]; |
Inscape_ao | 0:c347f602596d | 25 | int nesthead; |
Inscape_ao | 0:c347f602596d | 26 | int nesttail; |
Inscape_ao | 0:c347f602596d | 27 | int tail; |
Inscape_ao | 0:c347f602596d | 28 | int head; |
Inscape_ao | 0:c347f602596d | 29 | |
Inscape_ao | 0:c347f602596d | 30 | private: |
Inscape_ao | 0:c347f602596d | 31 | /* Constructor(CouldNotUse) */ |
Inscape_ao | 0:c347f602596d | 32 | UartReceiver(void); |
Inscape_ao | 0:c347f602596d | 33 | |
Inscape_ao | 0:c347f602596d | 34 | public: |
Inscape_ao | 0:c347f602596d | 35 | /* Constructor(Accepted) */ |
Inscape_ao | 0:c347f602596d | 36 | UartReceiver(Serial *pSetUart); |
Inscape_ao | 0:c347f602596d | 37 | /* Start Receiving */ |
Inscape_ao | 0:c347f602596d | 38 | void run(void); |
Inscape_ao | 0:c347f602596d | 39 | /* Stop Receiving */ |
Inscape_ao | 0:c347f602596d | 40 | void stop(void); |
Inscape_ao | 0:c347f602596d | 41 | /* set Line Handler */ |
Inscape_ao | 0:c347f602596d | 42 | void* setLineHandler(void(*setLineHandler)(char*)); |
Inscape_ao | 0:c347f602596d | 43 | /* Export Fixed Buffer Pointer */ |
Inscape_ao | 0:c347f602596d | 44 | char* dequeue_str(void); |
Inscape_ao | 0:c347f602596d | 45 | /* Recv char from UART and Concat to Liquid Buffer */ |
Inscape_ao | 0:c347f602596d | 46 | void concat(); |
Inscape_ao | 0:c347f602596d | 47 | /* Get Pointer */ |
Inscape_ao | 0:c347f602596d | 48 | Serial *getCurrentUart(void); |
Inscape_ao | 0:c347f602596d | 49 | private: |
Inscape_ao | 0:c347f602596d | 50 | /* Concat to Liquid Buffer */ |
Inscape_ao | 0:c347f602596d | 51 | /** return UartReceiver::BufFixed, UartReceiver::BufOpen */ |
Inscape_ao | 0:c347f602596d | 52 | int enqueue_ch(char ch); |
Inscape_ao | 0:c347f602596d | 53 | }; |
Inscape_ao | 0:c347f602596d | 54 | |
Inscape_ao | 0:c347f602596d | 55 | |
Inscape_ao | 0:c347f602596d | 56 | #endif /* _UARTRECEIVER_H_ */ |