Subversion Repositories HomeAutomation

Rev

Rev 61 | Blame | Last modification | View Log | SVN | RSS feed

  1. #ifndef PROTOCOL_H_
  2. #define PROTOCOL_H_
  3.  
  4.  
  5. /*-----------------------------------------------------------------------------
  6.  * Includes
  7.  *---------------------------------------------------------------------------*/
  8. #include <inttypes.h>
  9. #include <can.h>
  10.  
  11.  
  12. /*-----------------------------------------------------------------------------
  13.  * Type Definitions
  14.  *---------------------------------------------------------------------------*/
  15. /**
  16.  * Protocol Message Type.
  17.  * A protocol message has the following structure:
  18.  *      -------- 29bit IDENT --------- -- 8 bytes data --
  19.  *      <FUNC><RID><SID><RIDEN><RESVD>  <data7>...<data0>
  20.  */
  21. typedef struct {
  22.     /*
  23.      * Header section.
  24.      */
  25.     union {
  26.         uint32_t Raw;
  27.        
  28.         struct {
  29.             unsigned RESVD:2;
  30.             unsigned RIDEN:1;
  31.             unsigned SID:7;
  32.             unsigned RID:7;
  33.             unsigned FUNC:12;
  34.             unsigned __unused:3;    /* pad to 32bit */
  35.         } Fields;
  36.     } Header;
  37.    
  38.     /*
  39.      * Data section.
  40.      */
  41.     union {
  42.         /* read as 8bit unsigned data */
  43.         uint8_t bytes[8];
  44.        
  45.         /* read as 16bit unsigned data */
  46.         uint16_t words[4];
  47.        
  48.         /* read as 32bit unsigned data */
  49.         uint32_t dwords[2];
  50.     } Data;
  51. } ProtocolMessage_t;
  52.  
  53.  
  54. /*-----------------------------------------------------------------------------
  55.  * Public Function Prototypes
  56.  *---------------------------------------------------------------------------*/
  57. void ProtocolParseCanMessage(CanMessage_t *cmsg);
  58.  
  59.  
  60. #endif /*PROTOCOL_H_*/
  61.