== Communication protocol between CAN and CC2540 chip [[BR]] * [http://en.wikipedia.org/wiki/CAN_bus] * [http://www.can-cia.org/index.php?id=496 NMEA2000 principles] * [http://www.keversoft.com/downloads/packetlogger_20120415_explain.txt NMEA2000 message dictionary] List of commands from CC2540 to CAN transiver: 1. Subscribe to a message 2. Subscribe to a message with a bitmask 3. Unsubscribe from messages 4. Unsubscribe from messages with a bitmask 5. List of all subscriptions 6. Reset filter state 7. Passthrough message {{{ enum { CMD_SUBSCRIBE = 1, CMD_SUBSCRIBE_BITMASK, CMD_UNSUBSCRIBE, CMD_UNSUBSCRIBE_BITMASK, CMD_LIST, CMD_RESET, CMD_MSG } cmd_type; }}} List of responces from CAN transiver: {{{ enum { ACK_SUBSCRIBE = 1, ACK_SUBSCRIBE_BITMASK, ACK_UNSUBSCRIBE, ACK_UNSUBSCRIBE_BITMASK, ACK_LIST, ACK_RESET, ACK_MSG } cmd_type; }}} Command message structure ||= Byte =||= Bitmask =||= Description =||= Values =|| || 0 || || Command code || 1 - 7|| || 1 || || Payload size || 0 - 254|| || 2 - 255 || || Payload |||| Examples {{{ 01:08:00:76:01:55:02:44:00:01 04:02:00:76 05:00 06:00 07:07:FF:05:01:02:03:04:05 07:01:67:02:00:05 }}} ||=Command =||= Length =||= Payload =|| || 1 byte || 1 || n || || 01 || 08 || 76:01:55:02:44:00:01 || || Subscribe ||||2 CAN message IDs, 4 byte each || Temp Message 81 FD 06 00 08 01 1B 01 16 01 84 03 00 81 FD 06 00 08 01 25 01 20 01 84 03 00 81 FD 06 00 08 01 2A 01 25 01 84 03 00 {{{ ------------------------------------------------- Standard CAN message example: ID=76h byte0 - 07h (incoming CAN MESSAGE) byte1 - 00h (00h=b00000000 bit.7=0 standard message) (this is byte.1 of std.ID excluding high 5 bits in this byte) //if byte1 bit7=0 expect 1 more byte for ID byte2 - 76h (this is byte.0 of std.ID) byte3 - DLC (message data length code. also the payload. 8 in this example) byte4 - 01h (byte.0 of data) byte5 - 02h (byte.1 of data) byte6 - 03h (byte.2 of data) byte7 - 04h (byte.3 of data) byte8 - 05h (byte.4 of data) byte9 - 06h (byte.5 of data) byte10 - 07h (byte.6 of data) byte11 - 08h (byte.7 of data) std.ID example 1 (ID=76h) 07h, 00h,76h, 08h, 01h,02h,03h,04h,05h,06h,07h,08h std.ID example 2 (ID=5DFh) 07h, 05h,DFh, 08h, 01h,02h,03h,04h,05h,06h,07h,08h ------------------------------------------------- ------------------------------------------------- Extended CAN message example: ID=76h byte0 - 07h (incoming CAN MESSAGE) byte1 - 80h (80h=b10000000 bit.7=1 extended message ) (this is byte.3 of ext.ID excluding high 3 bits in this byte) //if byte1 bit7=1 expect 3 more bytes for ID byte2 - 00h (this is byte.2 of ext.ID) byte3 - 00h (this is byte.1 of ext.ID) byte4 - 76h (this is byte.0 of ext.ID) byte5 - DLC (message data length code. also the payload. 8 in this example) byte6 - 01h (byte.0 of data) byte7 - 02h (byte.1 of data) byte8 - 03h (byte.2 of data) byte9 - 04h (byte.3 of data) byte10 - 05h (byte.4 of data) byte11 - 06h (byte.5 of data) byte12 - 07h (byte.6 of data) byte13 - 08h (byte.7 of data) ext.ID example 1 (ID=76h ( b00000000000000000000000001110110 )) 07h, 80h,00h,00h,76h, 08h, 01h,02h,03h,04h,05h,06h,07h,08h ext.ID example 2 (ID=12345678h ( b00010010001101000101011001111000 )) 07h, 92h,34h,56h,78h, 08h, 01h,02h,03h,04h,05h,06h,07h,08h ext.ID example 3 (ID=1FFFFFFFh ( b00011111111111111111111111111111 29 bits, max value of ext.ID)) 07h, 9Fh,FFh,FFh,FFh, 08h, 01h,02h,03h,04h,05h,06h,07h,08h -------------------------------------------------- }}} [[Image(Capture3.PNG)]] [[Image(Capture1.PNG)]]