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.
Dependencies: mbed ESC SR04 TSI
com/com.h@30:17297295ce0c, 2013-06-09 (annotated)
- Committer:
- dereklmc
- Date:
- Sun Jun 09 04:14:21 2013 +0000
- Revision:
- 30:17297295ce0c
- Parent:
- 16:5f736b955d53
Updated sr04 include
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| gabdo | 16:5f736b955d53 | 1 | /******************************* com.h ***********************************/ |
| gabdo | 16:5f736b955d53 | 2 | /* Version: 1.0 */ |
| gabdo | 16:5f736b955d53 | 3 | /* Last Updated: June 1, 2013 */ |
| gabdo | 16:5f736b955d53 | 4 | /*************************************************************************/ |
| gabdo | 16:5f736b955d53 | 5 | |
| gabdo | 16:5f736b955d53 | 6 | #ifndef COM_H |
| gabdo | 16:5f736b955d53 | 7 | #define COM_H |
| gabdo | 16:5f736b955d53 | 8 | |
| gabdo | 16:5f736b955d53 | 9 | #include "mbed.h" |
| gabdo | 16:5f736b955d53 | 10 | #include "queue.h" |
| gabdo | 16:5f736b955d53 | 11 | |
| gabdo | 16:5f736b955d53 | 12 | class com |
| gabdo | 16:5f736b955d53 | 13 | { |
| gabdo | 16:5f736b955d53 | 14 | public: |
| gabdo | 16:5f736b955d53 | 15 | com( PinName, PinName ); // Setup the com serial port. (tx, rx) |
| gabdo | 16:5f736b955d53 | 16 | bool isData(); // Is there data to be read? |
| gabdo | 16:5f736b955d53 | 17 | void write( char ); // Write to the port. |
| gabdo | 16:5f736b955d53 | 18 | char * read(); // Read from the queue. |
| gabdo | 16:5f736b955d53 | 19 | |
| gabdo | 16:5f736b955d53 | 20 | private: |
| gabdo | 16:5f736b955d53 | 21 | void callback(); // Handle the interrupts. |
| gabdo | 16:5f736b955d53 | 22 | void packetBuilder(); // Called by callback to place commandes into the queue. |
| gabdo | 16:5f736b955d53 | 23 | |
| gabdo | 16:5f736b955d53 | 24 | char buffer[50]; // Buffer for holding serial data. |
| gabdo | 16:5f736b955d53 | 25 | int bLength; // Location in the buffer to place next data. |
| gabdo | 16:5f736b955d53 | 26 | Serial xbee; // tx - DIN, rx - DOUT |
| gabdo | 16:5f736b955d53 | 27 | queue *readBuffer; // queue of commands ready to be read. |
| gabdo | 16:5f736b955d53 | 28 | }; |
| gabdo | 16:5f736b955d53 | 29 | |
| gabdo | 16:5f736b955d53 | 30 | #endif |
