Subversion Repositories HomeAutomation

Rev

Rev 174 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #ifndef COM_H_
  2. #define COM_H_
  3.  
  4.  
  5. /*-----------------------------------------------------------------------------
  6.  * Includes
  7.  *---------------------------------------------------------------------------*/
  8. #include <inttypes.h>
  9. #include <can.h>
  10.  
  11.  
  12. /*-----------------------------------------------------------------------------
  13.  * Type Definitions
  14.  *---------------------------------------------------------------------------*/
  15. /**
  16.  * Communication Message Type.
  17.  *
  18.  * IDENT:<FUNCT><FUNCC><NID><SID> DATA:<data7>...<data0>
  19.  *
  20.  */
  21. typedef struct {
  22.  
  23.     /*
  24.      * <FUNCT>, 4 bits = Function Type.
  25.      */
  26.     uint8_t Funct   :4;
  27.  
  28.     /*
  29.      * <FUNCC>, 10 bits = Function Code.
  30.      */
  31.     uint16_t Funcc  :10;
  32.  
  33.     /*
  34.      * <NID>, 6 bits = Network ID.
  35.      */
  36.     uint8_t Nid     :6;
  37.  
  38.     /*
  39.      * <SID>, 9 bits = Sender ID.
  40.      */
  41.     uint16_t Sid    :9;
  42.    
  43.     /*
  44.      * DATA section. Contains up to 8 data bytes.
  45.      */
  46.     union {
  47.         /* read as 8bit unsigned data */
  48.         uint8_t bytes[8];
  49.        
  50.         /* read as 16bit unsigned data */
  51.         uint16_t words[4];
  52.        
  53.         /* read as 32bit unsigned data */
  54.         uint32_t dwords[2];
  55.     } Data;
  56.  
  57. } Com_Message_t;
  58.  
  59.  
  60. /*-----------------------------------------------------------------------------
  61.  * Public Function Prototypes
  62.  *---------------------------------------------------------------------------*/
  63. void Com_Init(void);
  64. void Com_Service(void);
  65. void ProtocolParseCanMessage(Can_Message_t *cmsg);
  66.  
  67.  
  68. #endif /*COM_H_*/
  69.