虽然移植完毕,但是不work。需要细调……

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Microduino_Protocol_HardSer.h Source File

Microduino_Protocol_HardSer.h

00001 #ifndef _MICRODUINO_PROTOCOL_HARDSER_H
00002 #define _MICRODUINO_PROTOCOL_HARDSER_H
00003 
00004 #include "mbed.h"
00005 
00006 #define PRO_PORT Serial
00007 
00008 enum p_sta {
00009     P_ERROR,
00010     P_BUSY,
00011     P_NONE,
00012     P_FINE,
00013     P_TIMEOUT,
00014 };
00015 
00016 #define MODE_WHILE 1
00017 #define MODE_LOOP 0
00018 
00019 #define BUFFER_MAX 256
00020 #define CHANNEL_NUM 8
00021 #define TYPE_NUM 0xC8
00022 
00023 class Protocol {
00024   public:
00025     Protocol(PRO_PORT *ser , uint8_t _channel) : num(0),time(0),sta(false),error(false){ // Constructor when using HardwareSerial
00026       //  common_init();  // Set everything to common state, then...
00027       channel = _channel;
00028       num = 0;
00029       sta = false;
00030       error = false;
00031       P_Serial = ser; // ...override P_Serial with value passed.
00032       //_timer.start();
00033     }
00034     void begin(uint16_t _baud);
00035     uint8_t parse(uint16_t* _data, bool _mod);
00036 
00037   private:
00038     uint8_t inChar, inCache;
00039     uint8_t buffer[BUFFER_MAX];
00040     uint8_t channel;
00041     uint32_t num ;
00042     uint32_t time;
00043     bool sta;
00044     bool error;
00045 
00046     bool available(bool _sta);
00047     PRO_PORT *P_Serial;
00048     
00049     
00050 };
00051 
00052 
00053 #endif