From 839c41ca408bd90207bfbf17a3712578ebd6f56b Mon Sep 17 00:00:00 2001 From: Tero K Date: Sun, 21 Dec 2014 02:15:19 +0200 Subject: 1) protocol image added 2) added clearer names for SM subpacket types --- doc/SMV2Protocol.svg | 643 +++++++++++++++++++++++++++++++++++++++++++++++++++ simplemotion_defs.h | 77 ++++-- 2 files changed, 705 insertions(+), 15 deletions(-) create mode 100644 doc/SMV2Protocol.svg diff --git a/doc/SMV2Protocol.svg b/doc/SMV2Protocol.svg new file mode 100644 index 0000000..8be482b --- /dev/null +++ b/doc/SMV2Protocol.svg @@ -0,0 +1,643 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + Subpacket 1 + 1 bytePackettype + 0 or 1 bytesNumber of payloadbytes unlessfixed lenght defined by packet type + 1 byteTarget deviceaddress 1-255 or 0 if broadcast to all devices + 0-120 bytesPayload datamade ofsubpackets + 2 byteCRC checksum + + + 2 bitssubpackettype andlenght + 6, 14, 22 or 30 bitsValue data(write / read valueof parameter) + Subpacket N + + + 2 bitssubpackettype andlenght + 6, 14, 22 or 30 bitsValue data(write / read valueof parameter) + . . . + + + SimpleMotion V2 outbound or inbound packet + + 3 - 125 bytes total + + Packet typesOutbound (host to devices):- execute payload subpackets instantly- place payload subpackets in buffer executed by timed fashion- get device clock value (used to sync buffered execution)Inbound (device to host)- Return data packets (one type for each outbound type), these contain payload data (read values) or clock value + + Subpacket typesOutbound- set parameter address where next values are written to, 2 bytes long- write parameter value, 3 or 4 bytes longInbound- SM bus status value, 1 byte long- read parameter value, 2, 3 or 4 bytes longEach outbound subpacket will give one inbound subpacket in return when devicesends the response to a SM packet. Content of inbound subpackets are defined bywritable parameters SMP_RETURN_PARAM_ADDR and SMP_RETURN_PARAM_LEN. + SimpleMotion V2 Protocol + + diff --git a/simplemotion_defs.h b/simplemotion_defs.h index 5c726e1..06810f2 100644 --- a/simplemotion_defs.h +++ b/simplemotion_defs.h @@ -32,14 +32,7 @@ #endif -//SMP command types -#define SMPCMD_SETPARAMADDR 2 -#define SMPCMD_24B 1 -#define SMPCMD_32B 0 -#define SMPRET_OTHER 3 -#define SMPRET_16B 2 -#define SMPRET_24B 1 -#define SMPRET_32B 0 + /* @@ -59,15 +52,69 @@ //mask for addresses #define SMP_ADDRESS_BITS_MASK 0x1FFF //E=1110 +/* + * SM payload command types and return value types. + */ //SMP packet header bits (2 bits). These determine content length and type -#define SMPCMD_SET_PARAM_ADDR 2 -#define SMPCMD_24B 1 -#define SMPCMD_32B 0 -#define SMPRET_CMD_STATUS 3 -#define SMPRET_16B 2 -#define SMPRET_24B 1 -#define SMPRET_32B 0 +#define SMPCMD_SETPARAMADDR 2 //Deprecated name, dont use these. Use new names seen below +#define SMPCMD_SET_PARAM_ADDR 2 //Deprecated name, dont use these. Use new names seen below +#define SMPCMD_24B 1 //Deprecated name, dont use these. Use new names seen below +#define SMPCMD_32B 0 //Deprecated name, dont use these. Use new names seen below +#define SMPRET_CMD_STATUS 3 //Deprecated name, dont use these. Use new names seen below +#define SMPRET_OTHER 3 //Deprecated name, dont use these. Use new names seen below +#define SMPRET_16B 2 //Deprecated name, dont use these. Use new names seen below +#define SMPRET_24B 1 //Deprecated name, dont use these. Use new names seen below +#define SMPRET_32B 0 //Deprecated name, dont use these. Use new names seen below + +// +//new naming for the above values (more clear meanings): +// + +//OUTBOUND SM COMMAND PAYLOAD SUBPACKET TYPES +//each SMCMD_INSTANT_CMD and SMCMD_BUFFERED_CMD payload is filled with subpackets of following types + //sets param address (one of SMP_ defines) where next written value goes to. + //consumes 2 bytes from payload buffer. + #define SM_SET_WRITE_ADDRESS 2 + //writes value to previously defined address. consumes 3 bytes (24 bits) from payload buffer. + //can hold value size up to 22 bits. bits above 22 are clipped (transmitted as 0s) + #define SM_WRITE_VALUE_24B 1 + //writes value to previously defined address. consumes 4 bytes (32 bits) from payload buffer. + //can hold value size up to 30 bits. bits above 30 are clipped (transmitted as 0s) + #define SM_WRITE_VALUE_32B 0 + +//INBOUND SM COMMAND PAYLOAD SUBPACKET TYPES +//each outbound subpacket will return one of these. the type and address what is being returned +//is defined by parameters SMP_RETURN_PARAM_ADDR and SMP_RETURN_PARAM_LEN + //return value contains SM bus status bits (possible faults etc). + //consumes 1 byte from payload buffer + #define SM_RETURN_STATUS 3 + //return value contains a read value from address defined by SMP_RETURN_PARAM_ADDR + //consumes 2 byte from payload buffer. can contain value up to 14 bits. value greater than 14 bits is clipped (padded with 0s) + #define SM_RETURN_VALUE_16B 2 + //return value contains a read value from address defined by SMP_RETURN_PARAM_ADDR + //consumes 3 byte from payload buffer. can contain value up to 14 bits. value greater than 22 bits is clipped (padded with 0s) + #define SM_RETURN_VALUE_24B 1 + //return value contains a read value from address defined by SMP_RETURN_PARAM_ADDR + //consumes 4 byte from payload buffer. can contain value up to 30 bits. value greater than 14 bits is clipped (padded with 0s) + #define SM_RETURN_VALUE_32B 0 + +/* subpacket format + * + * header: + * 2 bits packet type which defines also lenght of subpacket + * data: + * rest of subpacket contains the transmitted value + * + * example: + * SM_WRITE_VALUE_32B packet looks like this + * + * -2 first bits are 00 + * -next 30 bits carry the value + * + * SMV2 library takes care of forming subpackets so user only needs to care about using the macros above + * + */ //if command is to set param addr to this -> NOP #define SMP_ADDR_NOP 0x3fff -- cgit v1.2.3