Subversion Repositories HomeAutomation

Rev

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

Rev 363 Rev 800
1
/*********************************************************************
1
/*********************************************************************
2
 *
2
 *
3
 *   Defines functs and funccs and other global definitions.
3
 *   Defines functs and funccs and other global definitions.
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:            $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/Include/funcdefs.h $
6
 * FileName:            $HeadURL: https://svn.auml.se/svn/HomeAutomation/branches/modules/EmbeddedSoftware/PIC/Include/funcdefs.h $
7
 * Last changed:    $LastChangedDate: 2007-03-13 18:29:20 +0100 (Tue, 13 Mar 2007) $
7
 * Last changed:    $LastChangedDate: 2007-03-13 18:29:20 +0100 (Tue, 13 Mar 2007) $
8
 * By:          $LastChangedBy: johboh $
8
 * By:          $LastChangedBy: johboh $
9
 * Revision:        $Revision: 363 $
9
 * Revision:        $Revision: 363 $
10
 ********************************************************************/
10
 ********************************************************************/
11
 
11
 
12
#include <typedefs.h>
12
#include <typedefs.h>
13
#include <pgmtypes.h>
13
#include <pgmtypes.h>
14
 
14
 
15
#define DEFAULT_ID 0x78     // Default ID for bootloader/node when no id is set.
15
#define DEFAULT_ID 0x78     // Default ID for bootloader/node when no id is set.
16
#define NODE_ID_EE  0x00    // EEPROM first index where to look for ID and NID. 
16
#define NODE_ID_EE  0x00    // EEPROM first index where to look for ID and NID. 
17
                // NODE_ID_EE = NODE_HAS_ID if has correct ID, otherwise use DEFAULT_ID and DEFAULT_NID
17
                // NODE_ID_EE = NODE_HAS_ID if has correct ID, otherwise use DEFAULT_ID and DEFAULT_NID
18
                // NODE_ID_EE + 1 = ID
18
                // NODE_ID_EE + 1 = ID
19
#define NODE_HAS_ID 0x2A    // Value which indicate valid ID and NID.
19
#define NODE_HAS_ID 0x2A    // Value which indicate valid ID and NID.
20
 
20
 
21
 
21
 
22
typedef struct _CAN_BOOT_PACKET
22
typedef struct _CAN_BOOT_PACKET
23
{
23
{
24
    BOOT_TYPE type; //3
24
    BOOT_TYPE type; //3
25
    BYTE    offset; //8
25
    BYTE    offset; //8
26
    BYTE       rid; //8
26
    BYTE       rid; //8
27
} CAN_BOOT_PACKET;
27
} CAN_BOOT_PACKET;
28
 
28
 
29
 
29
 
30
typedef struct _CAN_PGM_PACKET
30
typedef struct _CAN_PGM_PACKET
31
{
31
{
32
    PGM_CLASS class; //4
32
    PGM_CLASS class; //4
33
    WORD         id; //15
33
    WORD         id; //15
34
} CAN_PGM_PACKET;
34
} CAN_PGM_PACKET;
35
 
35
 
36
typedef struct _CAN_PACKET
36
typedef struct _CAN_PACKET
37
{
37
{
38
    PACKET_TYPE     type;
38
    PACKET_TYPE     type;
39
    CAN_PGM_PACKET   pgm;
39
    CAN_PGM_PACKET   pgm;
40
    CAN_BOOT_PACKET boot;
40
    CAN_BOOT_PACKET boot;
41
    BYTE             sid; //8
41
    BYTE             sid; //8
42
    BYTE          length;
42
    BYTE          length;
43
    BYTE         data[8];
43
    BYTE         data[8];
44
} CAN_PACKET;
44
} CAN_PACKET;
45
 
45
 
46
 
46
 
47
 
47
 
48
// When CAN_BOOT_PACKET.type==btADDR
48
// When CAN_BOOT_PACKET.type==btADDR
49
// data[2] = ADDRU
49
// data[2] = ADDRU
50
// data[1] = ADDRH
50
// data[1] = ADDRH
51
// data[0] = ADDRL
51
// data[0] = ADDRL
52
 
52
 
53
// When CAN_BOOT_PACKET.type==btCRC
53
// When CAN_BOOT_PACKET.type==btCRC
54
// data[4] = CRCH
54
// data[4] = CRCH
55
// data[3] = CRCL
55
// data[3] = CRCL
56
// data[2] = ADDRU
56
// data[2] = ADDRU
57
// data[1] = ADDRH
57
// data[1] = ADDRH
58
// data[0] = ADDRL
58
// data[0] = ADDRL
59
 
59
 
60
// When CAN_BOOT_PACKET.type==btCHANGEID
60
// When CAN_BOOT_PACKET.type==btCHANGEID
61
// data[0] = new id
61
// data[0] = new id
62
 
62
 
63
 
63