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 SimpleSerialProtocol MODSERIAL
TestProtocol.h@2:8799090c0fe4, 2012-01-16 (annotated)
- Committer:
- p3p
- Date:
- Mon Jan 16 22:46:45 2012 +0000
- Revision:
- 2:8799090c0fe4
- Child:
- 3:8ac7e37d0e0e
- Child:
- 5:f693f68e9de6
Modified to reflect changes in the SimpleSerialProtocol Library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| p3p | 2:8799090c0fe4 | 1 | #ifndef _TEST_PROTOCOL_H |
| p3p | 2:8799090c0fe4 | 2 | #define _TEST_PROTOCOL_H |
| p3p | 2:8799090c0fe4 | 3 | |
| p3p | 2:8799090c0fe4 | 4 | #include <mbed.h> |
| p3p | 2:8799090c0fe4 | 5 | #include <SimpleSerialProtocol/Protocol.h> |
| p3p | 2:8799090c0fe4 | 6 | |
| p3p | 2:8799090c0fe4 | 7 | //class will receive a packet and echo it back out |
| p3p | 2:8799090c0fe4 | 8 | class TestProtocol : public SimpleSerialProtocol::Protocol { |
| p3p | 2:8799090c0fe4 | 9 | public: |
| p3p | 2:8799090c0fe4 | 10 | TestProtocol() : Protocol(p9, p10, NC) { //LED1 to 4 for a status led, NC to disable |
| p3p | 2:8799090c0fe4 | 11 | _dma_port = 0; //set the dma port, must be unique per class 0 - 9 |
| p3p | 2:8799090c0fe4 | 12 | packetCallback(1, this, &TestProtocol::onEchoPacket); |
| p3p | 2:8799090c0fe4 | 13 | } |
| p3p | 2:8799090c0fe4 | 14 | virtual ~TestProtocol() {}; |
| p3p | 2:8799090c0fe4 | 15 | uint32_t onEchoPacket(uint32_t packet_ptr_value); |
| p3p | 2:8799090c0fe4 | 16 | void reply(); |
| p3p | 2:8799090c0fe4 | 17 | |
| p3p | 2:8799090c0fe4 | 18 | class EchoPacket : public SimpleSerialProtocol::Packet { |
| p3p | 2:8799090c0fe4 | 19 | public: |
| p3p | 2:8799090c0fe4 | 20 | EchoPacket() {} |
| p3p | 2:8799090c0fe4 | 21 | virtual ~EchoPacket() {} |
| p3p | 2:8799090c0fe4 | 22 | |
| p3p | 2:8799090c0fe4 | 23 | #pragma pack(push, 1) //must pack the structure to byte boundary for raw recast to work reliably |
| p3p | 2:8799090c0fe4 | 24 | struct Interface { |
| p3p | 2:8799090c0fe4 | 25 | Interface() { |
| p3p | 2:8799090c0fe4 | 26 | type = 1; // initialise the type |
| p3p | 2:8799090c0fe4 | 27 | } |
| p3p | 2:8799090c0fe4 | 28 | uint8_t type; |
| p3p | 2:8799090c0fe4 | 29 | uint8_t data; |
| p3p | 2:8799090c0fe4 | 30 | uint16_t datashort; |
| p3p | 2:8799090c0fe4 | 31 | uint32_t dataint; |
| p3p | 2:8799090c0fe4 | 32 | float datafloat; |
| p3p | 2:8799090c0fe4 | 33 | } interface; |
| p3p | 2:8799090c0fe4 | 34 | #pragma pack(pop) |
| p3p | 2:8799090c0fe4 | 35 | |
| p3p | 2:8799090c0fe4 | 36 | }; |
| p3p | 2:8799090c0fe4 | 37 | |
| p3p | 2:8799090c0fe4 | 38 | uint8_t temp; |
| p3p | 2:8799090c0fe4 | 39 | short temp1; |
| p3p | 2:8799090c0fe4 | 40 | int temp2; |
| p3p | 2:8799090c0fe4 | 41 | float temp3; |
| p3p | 2:8799090c0fe4 | 42 | }; |
| p3p | 2:8799090c0fe4 | 43 | |
| p3p | 2:8799090c0fe4 | 44 | #endif |