Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
170 jimmy 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.
172 eqlazer 17
 *
18
 * IDENT:<FUNCT><FUNCC><NID><SID> DATA:<data7>...<data0>
19
 *
170 jimmy 20
 */
21
typedef struct {
172 eqlazer 22
 
23
    /*
24
     * <FUNCT>, 4 bits = Function Type.
25
     */
173 jimmy 26
    uint8_t Funct   :4;
172 eqlazer 27
 
28
    /*
29
     * <FUNCC>, 10 bits = Function Code.
30
     */
173 jimmy 31
    uint16_t Funcc  :10;
172 eqlazer 32
 
33
    /*
34
     * <NID>, 6 bits = Network ID.
35
     */
173 jimmy 36
    uint8_t Nid     :6;
172 eqlazer 37
 
38
    /*
39
     * <SID>, 9 bits = Sender ID.
40
     */
173 jimmy 41
    uint16_t Sid    :9;
174 jimmy 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;
172 eqlazer 56
 
170 jimmy 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_*/