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.
Fork of BalanceCar by
Microduino_Protocol_HardSer.h
- Committer:
- lixianyu
- Date:
- 2016-06-04
- Revision:
- 0:a4d8f5b3c546
File content as of revision 0:a4d8f5b3c546:
#ifndef _MICRODUINO_PROTOCOL_HARDSER_H #define _MICRODUINO_PROTOCOL_HARDSER_H #include "mbed.h" #define PRO_PORT Serial enum p_sta { P_ERROR, P_BUSY, P_NONE, P_FINE, P_TIMEOUT, }; #define MODE_WHILE 1 #define MODE_LOOP 0 #define BUFFER_MAX 256 #define CHANNEL_NUM 8 #define TYPE_NUM 0xC8 class Protocol { public: Protocol(PRO_PORT *ser , uint8_t _channel) : num(0),time(0),sta(false),error(false){ // Constructor when using HardwareSerial // common_init(); // Set everything to common state, then... channel = _channel; num = 0; sta = false; error = false; P_Serial = ser; // ...override P_Serial with value passed. //_timer.start(); } void begin(uint16_t _baud); uint8_t parse(uint16_t* _data, bool _mod); private: uint8_t inChar, inCache; uint8_t buffer[BUFFER_MAX]; uint8_t channel; uint32_t num ; uint32_t time; bool sta; bool error; bool available(bool _sta); PRO_PORT *P_Serial; }; #endif