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
PixyLinkUART.h@0:4a23b84b733e, 2017-05-17 (annotated)
- Committer:
- ZHAW_Prometheus
- Date:
- Wed May 17 13:08:18 2017 +0000
- Revision:
- 0:4a23b84b733e
PixyTest2 Vers. 17.05.2017
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ZHAW_Prometheus | 0:4a23b84b733e | 1 | #ifndef TUIASI_PIXYLINKUART_H |
| ZHAW_Prometheus | 0:4a23b84b733e | 2 | #define TUIASI_PIXYLINKUART_H |
| ZHAW_Prometheus | 0:4a23b84b733e | 3 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 4 | #include "Serial.h" |
| ZHAW_Prometheus | 0:4a23b84b733e | 5 | #include "PixyLink.h" |
| ZHAW_Prometheus | 0:4a23b84b733e | 6 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 7 | class PixyLinkUART : public PixyLink, private Serial |
| ZHAW_Prometheus | 0:4a23b84b733e | 8 | { |
| ZHAW_Prometheus | 0:4a23b84b733e | 9 | public: |
| ZHAW_Prometheus | 0:4a23b84b733e | 10 | PixyLinkUART(PinName tx, PinName rx) : |
| ZHAW_Prometheus | 0:4a23b84b733e | 11 | Serial(tx, rx) { |
| ZHAW_Prometheus | 0:4a23b84b733e | 12 | baud(19200); |
| ZHAW_Prometheus | 0:4a23b84b733e | 13 | }; |
| ZHAW_Prometheus | 0:4a23b84b733e | 14 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 15 | virtual uint16_t getWord() { |
| ZHAW_Prometheus | 0:4a23b84b733e | 16 | uint8_t data[2] = {0, 0}; |
| ZHAW_Prometheus | 0:4a23b84b733e | 17 | read(data, 2); |
| ZHAW_Prometheus | 0:4a23b84b733e | 18 | return ((uint16_t)data[1] << 8) | data[0]; |
| ZHAW_Prometheus | 0:4a23b84b733e | 19 | }; |
| ZHAW_Prometheus | 0:4a23b84b733e | 20 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 21 | virtual uint8_t getByte() { |
| ZHAW_Prometheus | 0:4a23b84b733e | 22 | uint8_t data = 0; |
| ZHAW_Prometheus | 0:4a23b84b733e | 23 | read(&data, 1); |
| ZHAW_Prometheus | 0:4a23b84b733e | 24 | return data; |
| ZHAW_Prometheus | 0:4a23b84b733e | 25 | }; |
| ZHAW_Prometheus | 0:4a23b84b733e | 26 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 27 | virtual int8_t send(uint8_t *data, uint8_t len) { |
| ZHAW_Prometheus | 0:4a23b84b733e | 28 | return write(data, len); |
| ZHAW_Prometheus | 0:4a23b84b733e | 29 | }; |
| ZHAW_Prometheus | 0:4a23b84b733e | 30 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 31 | |
| ZHAW_Prometheus | 0:4a23b84b733e | 32 | private: |
| ZHAW_Prometheus | 0:4a23b84b733e | 33 | }; |
| ZHAW_Prometheus | 0:4a23b84b733e | 34 | #endif //TUIASI_PIXYLINKUART_H |