an old afLib which supports both SPI and UART
StatusCommand.h@0:6f371c791202, 2018-03-20 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Mar 20 06:47:25 2018 +0000
- Revision:
- 0:6f371c791202
SPI mode started working
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Rhyme | 0:6f371c791202 | 1 | /** |
| Rhyme | 0:6f371c791202 | 2 | * Copyright 2015 Afero, Inc. |
| Rhyme | 0:6f371c791202 | 3 | * |
| Rhyme | 0:6f371c791202 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| Rhyme | 0:6f371c791202 | 5 | * you may not use this file except in compliance with the License. |
| Rhyme | 0:6f371c791202 | 6 | * You may obtain a copy of the License at |
| Rhyme | 0:6f371c791202 | 7 | * |
| Rhyme | 0:6f371c791202 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| Rhyme | 0:6f371c791202 | 9 | * |
| Rhyme | 0:6f371c791202 | 10 | * Unless required by applicable law or agreed to in writing, software |
| Rhyme | 0:6f371c791202 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| Rhyme | 0:6f371c791202 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| Rhyme | 0:6f371c791202 | 13 | * See the License for the specific language governing permissions and |
| Rhyme | 0:6f371c791202 | 14 | * limitations under the License. |
| Rhyme | 0:6f371c791202 | 15 | */ |
| Rhyme | 0:6f371c791202 | 16 | |
| Rhyme | 0:6f371c791202 | 17 | #ifndef STATUS_COMMAND_H__ |
| Rhyme | 0:6f371c791202 | 18 | #define STATUS_COMMAND_H__ |
| Rhyme | 0:6f371c791202 | 19 | |
| Rhyme | 0:6f371c791202 | 20 | #include "mbed.h" |
| Rhyme | 0:6f371c791202 | 21 | #define Stream Serial |
| Rhyme | 0:6f371c791202 | 22 | |
| Rhyme | 0:6f371c791202 | 23 | class StatusCommand { |
| Rhyme | 0:6f371c791202 | 24 | public: |
| Rhyme | 0:6f371c791202 | 25 | StatusCommand(Stream *); |
| Rhyme | 0:6f371c791202 | 26 | |
| Rhyme | 0:6f371c791202 | 27 | StatusCommand(Stream *,uint16_t bytesToSend); |
| Rhyme | 0:6f371c791202 | 28 | |
| Rhyme | 0:6f371c791202 | 29 | ~StatusCommand(); |
| Rhyme | 0:6f371c791202 | 30 | |
| Rhyme | 0:6f371c791202 | 31 | uint16_t getSize(); |
| Rhyme | 0:6f371c791202 | 32 | |
| Rhyme | 0:6f371c791202 | 33 | uint16_t getBytes(int *bytes); |
| Rhyme | 0:6f371c791202 | 34 | |
| Rhyme | 0:6f371c791202 | 35 | uint8_t calcChecksum(); |
| Rhyme | 0:6f371c791202 | 36 | |
| Rhyme | 0:6f371c791202 | 37 | void setChecksum(uint8_t checksum); |
| Rhyme | 0:6f371c791202 | 38 | |
| Rhyme | 0:6f371c791202 | 39 | uint8_t getChecksum(); |
| Rhyme | 0:6f371c791202 | 40 | |
| Rhyme | 0:6f371c791202 | 41 | void setAck(bool ack); |
| Rhyme | 0:6f371c791202 | 42 | |
| Rhyme | 0:6f371c791202 | 43 | void setBytesToSend(uint16_t bytesToSend); |
| Rhyme | 0:6f371c791202 | 44 | |
| Rhyme | 0:6f371c791202 | 45 | uint16_t getBytesToSend(); |
| Rhyme | 0:6f371c791202 | 46 | |
| Rhyme | 0:6f371c791202 | 47 | void setBytesToRecv(uint16_t bytesToRecv); |
| Rhyme | 0:6f371c791202 | 48 | |
| Rhyme | 0:6f371c791202 | 49 | uint16_t getBytesToRecv(); |
| Rhyme | 0:6f371c791202 | 50 | |
| Rhyme | 0:6f371c791202 | 51 | bool equals(StatusCommand *statusCommand); |
| Rhyme | 0:6f371c791202 | 52 | |
| Rhyme | 0:6f371c791202 | 53 | bool isValid(); |
| Rhyme | 0:6f371c791202 | 54 | |
| Rhyme | 0:6f371c791202 | 55 | void dump(); |
| Rhyme | 0:6f371c791202 | 56 | |
| Rhyme | 0:6f371c791202 | 57 | void dumpBytes(); |
| Rhyme | 0:6f371c791202 | 58 | |
| Rhyme | 0:6f371c791202 | 59 | private: |
| Rhyme | 0:6f371c791202 | 60 | Stream * _serial; |
| Rhyme | 0:6f371c791202 | 61 | uint8_t _cmd; |
| Rhyme | 0:6f371c791202 | 62 | uint16_t _bytesToSend; |
| Rhyme | 0:6f371c791202 | 63 | uint16_t _bytesToRecv; |
| Rhyme | 0:6f371c791202 | 64 | uint8_t _checksum; |
| Rhyme | 0:6f371c791202 | 65 | }; |
| Rhyme | 0:6f371c791202 | 66 | |
| Rhyme | 0:6f371c791202 | 67 | #endif // STATUS_COMMAND_H__ |
| Rhyme | 0:6f371c791202 | 68 |