Arduino Core API Library besed on mbed platform.

Dependents:   WeeESP8266 ESP8266_moj

Committer:
itead
Date:
Tue Feb 10 10:39:42 2015 +0000
Revision:
4:1fec2e4c60e5
Parent:
3:eb0bbd72ffa1
Change buffer size

Who changed what in which revision?

UserRevisionLine numberNew contents of line
itead 0:5ebc917ebd09 1 #ifndef __ARDUINOAPI_ARDUINOSERIAL_H__
itead 0:5ebc917ebd09 2 #define __ARDUINOAPI_ARDUINOSERIAL_H__
itead 0:5ebc917ebd09 3
itead 0:5ebc917ebd09 4 #include "Print.h"
itead 0:5ebc917ebd09 5 #include "WString.h"
itead 0:5ebc917ebd09 6
itead 0:5ebc917ebd09 7 typedef enum {
itead 4:1fec2e4c60e5 8 ARDUINOSERIAL_BUFFER_SIZE = 512,
itead 0:5ebc917ebd09 9 } ArduinoSerialConstant;
itead 0:5ebc917ebd09 10
itead 0:5ebc917ebd09 11 typedef struct {
itead 0:5ebc917ebd09 12 unsigned char buffer[ARDUINOSERIAL_BUFFER_SIZE];
itead 0:5ebc917ebd09 13 volatile unsigned int head;
itead 0:5ebc917ebd09 14 volatile unsigned int tail;
itead 0:5ebc917ebd09 15 } ArduinoSerialRingBuffer;
itead 0:5ebc917ebd09 16
itead 0:5ebc917ebd09 17 class ArduinoSerial;
itead 0:5ebc917ebd09 18
itead 0:5ebc917ebd09 19 typedef struct ArduinoSerialLinkedNode{
itead 0:5ebc917ebd09 20 ArduinoSerial* data;
itead 0:5ebc917ebd09 21 struct ArduinoSerialLinkedNode *next;
itead 0:5ebc917ebd09 22 } ArduinoSerialLinkedNode;
itead 0:5ebc917ebd09 23
itead 0:5ebc917ebd09 24 class ArduinoSerial: public Serial, public Print
itead 0:5ebc917ebd09 25 {
itead 0:5ebc917ebd09 26 public:
itead 0:5ebc917ebd09 27 ArduinoSerial(PinName tx, PinName rx);
itead 0:5ebc917ebd09 28
itead 0:5ebc917ebd09 29 virtual ~ArduinoSerial(void);
itead 0:5ebc917ebd09 30
itead 1:2179048af332 31 virtual size_t write(uint8_t data);
itead 1:2179048af332 32
itead 0:5ebc917ebd09 33 void begin(int baud_rate);
itead 0:5ebc917ebd09 34
itead 0:5ebc917ebd09 35 int available(void);
itead 0:5ebc917ebd09 36
itead 0:5ebc917ebd09 37 void flush(void);
itead 0:5ebc917ebd09 38
itead 0:5ebc917ebd09 39 char readChr(void);
itead 0:5ebc917ebd09 40
itead 0:5ebc917ebd09 41 void setTimeout(unsigned long millisecond);
itead 0:5ebc917ebd09 42
itead 0:5ebc917ebd09 43 bool find(const char *str);
itead 0:5ebc917ebd09 44
itead 0:5ebc917ebd09 45 private:
itead 0:5ebc917ebd09 46 static void uartIrqCallback(void);
itead 0:5ebc917ebd09 47 static ArduinoSerialLinkedNode *initHeadNode(ArduinoSerialLinkedNode *head);
itead 0:5ebc917ebd09 48 static ArduinoSerialLinkedNode *addNode(ArduinoSerialLinkedNode *head, ArduinoSerial* data);
itead 0:5ebc917ebd09 49 static ArduinoSerialLinkedNode *delNode(ArduinoSerialLinkedNode *head, ArduinoSerial* data);
itead 0:5ebc917ebd09 50 static ArduinoSerialLinkedNode *findNode(ArduinoSerialLinkedNode *head, ArduinoSerial* data);
itead 0:5ebc917ebd09 51
itead 0:5ebc917ebd09 52 static ArduinoSerialLinkedNode ms_list_head;
itead 0:5ebc917ebd09 53 static unsigned int ms_instance_counter;
itead 0:5ebc917ebd09 54
itead 0:5ebc917ebd09 55 void writeChr(unsigned char c);
itead 0:5ebc917ebd09 56
itead 0:5ebc917ebd09 57 ArduinoSerialRingBuffer m_rx_buffer;
itead 0:5ebc917ebd09 58 unsigned long m_find_timeout;
itead 0:5ebc917ebd09 59 };
itead 0:5ebc917ebd09 60
itead 0:5ebc917ebd09 61 #endif /* #ifndef __ARDUINOAPI_ARDUINOSERIAL_H__ */