Subversion Repositories HomeAutomation

Rev

Rev 73 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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