| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 6 | kaklik | /*! \file edpdefs.h \brief Emerald Data Protocol Defines and Constants. */ |
| 2 | //***************************************************************************** |
||
| 3 | // |
||
| 4 | // File Name : 'edpdefs.h' |
||
| 5 | // Title : Emerald Data Protocol Defines and Constants |
||
| 6 | // Author : Pascal Stang - Copyright (C) 2003 |
||
| 7 | // Created : 09/08/2003 |
||
| 8 | // Revised : 09/08/2003 |
||
| 9 | // Version : 0.1 |
||
| 10 | // Target MCU : Atmel AVR Series |
||
| 11 | // Editor Tabs : 4 |
||
| 12 | // |
||
| 13 | // This code is distributed under the GNU Public License |
||
| 14 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
| 15 | // |
||
| 16 | //***************************************************************************** |
||
| 17 | |||
| 18 | #ifndef EDPDEFS_H |
||
| 19 | #define EDPDEFS_H |
||
| 20 | |||
| 21 | // **** Constant Definitions ***** |
||
| 22 | // ---- Message Size, etc ---- |
||
| 23 | // Standard defines for various message format parameters |
||
| 24 | #define I2C_MAX_COMMAND_LENGTH 127 // [param1]...[param127] (does not include Command, From |
||
| 25 | // or Chk) Note that this an absolute maximum, |
||
| 26 | // subsystems/nodes are free to set lower maximum lengths |
||
| 27 | // For versions pre rev5, this was fixed at 5. |
||
| 28 | #define I2C_MAX_DATA_PACKET_LENGTH 127 // Raw Data: [data1]...[data126][Chk] (includes Chk for |
||
| 29 | |||
| 30 | |||
| 31 | // ---- Communication OK (value all uppercase ('A'-'Z') |
||
| 32 | #define EDP_RESP_ACK 'A' // indicates the command (to_send) was sent but has no return value. |
||
| 33 | #define EDP_RESP_DATA_REPLY 'R' // command valid and has return, examine reply and length for details |
||
| 34 | |||
| 35 | // ---- Communication Error (values all lowercase ('a'-'z')) |
||
| 36 | #define EDP_RESP_UNKWN_CMD 'u' // given command is unrecognized by the subsystem at that address |
||
| 37 | #define EDP_RESP_CMD_CHK_ERROR 'c' // checksum error sending command |
||
| 38 | #define EDP_RESP_DATA_CHK_ERROR 'd' // checksum error receiving data |
||
| 39 | #define EDP_RESP_SEQUENCE_ERROR 's' // read/write out of order |
||
| 40 | #define EDP_RESP_READ_BEFORE_WRITE 'b' // requested read before writting associated Command |
||
| 41 | #define EDP_RESP_TOO_LONG 'l' // The command sent exceeds the maximum command length for node |
||
| 42 | #define EDP_RESP_TOO_FEW_PARAMS 'p' // The command sent has too few parameters |
||
| 43 | #define EDP_RESP_INCORRECT_PARAM 'i' // Parameters are incorrect (but there are the right number) |
||
| 44 | #define EDP_RESP_BUSY 'b' // The subsystem is still alive, but too busy to reply (AVOID USING) |
||
| 45 | #define EDP_RESP_NOT_ALLOWED 'n' // The command is recognized, but not allowed in the current |
||
| 46 | // operating mode. Try another command, or try again later |
||
| 47 | #define EDP_RESP_OTHER_ERROR 'e' // unspecified EDP/I2C error |
||
| 48 | |||
| 49 | // ---- Check Sum ---- |
||
| 50 | /* The Checksum that is used is a rolling 8-bit sum from the [From] to the last parameter byte of a command |
||
| 51 | packet and from the [Length] to the last data byte of a Data packet. This sum is then 1-complemented |
||
| 52 | (~, not) and passed as [Chk]. This prevents a series of 0x00 replys from passing the correct check sum. |
||
| 53 | Because of the inversion, a packet with all zeros should have a checksum of 0xFF. |
||
| 54 | |||
| 55 | The other nice feature of this checksum, is that no matter what the data is, if you add the checksum |
||
| 56 | ([Chk]) to the final sum, you should get 0xFF. |
||
| 57 | |||
| 58 | To make it even cleaner, you can start the rolling checksum at 0x01 such that when you add in all of the |
||
| 59 | data bytes and the [Chk] byte, you get 0x00. This effectively makes the whole operation a twos complement |
||
| 60 | */ |
||
| 61 | #define EDP_CHECKSUM_INIT 0x01 |
||
| 62 | |||
| 63 | // -------- Reserved I2C commands --------- |
||
| 64 | // Define a short list of reserved commands. Subsystems can choose whether or |
||
| 65 | // not to implement these commands, but if they are implemented, they must |
||
| 66 | // function as described below. |
||
| 67 | |||
| 68 | //Reserved Commands |
||
| 69 | #define EDP_CMD_SET_TIME ':' //0x3A Set the subsystem time, realtime.h format |
||
| 70 | #define EDP_CMD_RESERVED_1 ';' //0x3B Reserved for future command |
||
| 71 | #define EDP_CMD_ROM_WRITE '<' //0x3C Write to program ROM (uploadable code) |
||
| 72 | #define EDP_CMD_RESERVED_2 '=' //0x3D Reserved for future command |
||
| 73 | #define EDP_CMD_MEM_READ '>' //0x3E Read from program ROM (check program) |
||
| 74 | #define EDP_CMD_HELP '?' //0x3F Return human readable help string(s) |
||
| 75 | #define EDP_CMD_STATUS '@' //0x40 Get subsystem status |
||
| 76 | |||
| 77 | |||
| 78 | #define I2C_DATA_CONTINUE_MASK 0x80 // If MSB of length is set, then the data continues beyond |
||
| 79 | // this data packet |
||
| 80 | |||
| 81 | |||
| 82 | #endif |
Powered by WebSVN v2.8.3