Subversion Repositories HomeAutomation

Rev

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

Rev 139 Rev 141
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/trunk/EmbeddedSoftware/PIC/Include/funcdefs.h $
7
 * Last changed:    $LastChangedDate: 2006-11-20 21:31:03 +0100 (Mon, 20 Nov 2006) $
7
 * Last changed:    $LastChangedDate: 2006-11-21 10:57:15 +0100 (Tue, 21 Nov 2006) $
8
 * By:          $LastChangedBy: johboh $
8
 * By:          $LastChangedBy: johboh $
9
 * Revision:        $Revision: 139 $
9
 * Revision:        $Revision: 141 $
10
 ********************************************************************/
10
 ********************************************************************/
11
 
11
 
12
 
12
 
13
 
13
 
14
//<FUNCT>
14
//<FUNCT>
15
#define FUNCT_BOOTLOADER 0x00
15
#define FUNCT_BOOTLOADER 0x00
16
#define FUNCT_SENSORS 0x01
16
#define FUNCT_SENSORS 0x01
17
 
17
 
18
//<FUNCC> configuration packet
18
//<FUNCC> configuration packet
19
#define FUNCC_BOOT_INIT   0b0000000001 //Start programmring and/or resseting user program to go into bootloader mode.
19
#define FUNCC_BOOT_INIT   0b0000000001 //Start programmring and/or resseting user program to go into bootloader mode.
20
#define FUNCC_BOOT_ADDR   0b0000000010  //Change programming address.
20
#define FUNCC_BOOT_ADDR   0b0000000010  //Change programming address.
21
#define FUNCC_BOOT_SET_ID 0b0000000110  //Change ID and NID.
21
#define FUNCC_BOOT_SET_ID 0b0000000110  //Change ID and NID.
22
#define FUNCC_BOOT_DONE   0b0000000101  //End programming, start user program.
22
#define FUNCC_BOOT_DONE   0b0000000101  //End programming, start user program.
23
 
23
 
24
#define FUNCC_BOOT_HEARTBEAT 0b0000001000 // Heartbeat
24
#define FUNCC_BOOT_HEARTBEAT 0b0000001000 // Heartbeat
25
 
25
 
26
//<FUNCC> program packet
26
//<FUNCC> program packet
27
#define FUNCC_BOOT_PGM 0b0000000011 //To indicate programming data packet.
27
#define FUNCC_BOOT_PGM 0b0000000011 //To indicate programming data packet.
28
 
28
 
29
//<FUNCC> ack packet
29
//<FUNCC> ack packet 10 bits, 0x3FF
30
#define FUNCC_BOOT_ACK 0b0000000100 //Ack packet
30
#define FUNCC_BOOT_ACK 0b0000000100 //Ack packet
31
 
31
 
32
 
32
 
33
//<FUNCC>
33
//<FUNCC> 10 bits, 0x3FF
34
#define FUNCC_SENSORS_IR            0b0000000001
34
#define FUNCC_SENSORS_IR                        0x001
35
#define FUNCC_SENSORS_TEMPERATURE_INSIDE    0b0000000010
-
 
36
#define FUNCC_SENSORS_TEMPERATURE_OUTSIDE   0b0000000011
-
 
37
#define FUNCC_SENSORS_TEMPERATURE_FREEZER   0b0000000012
-
 
38
#define FUNCC_SENSORS_TEMPERATURE_REFRIGERATOR  0b0000000013
-
 
39
 
35
 
-
 
36
#define FUNCC_SENSORS_TEMPERATURE_INSIDE        0x010
-
 
37
#define FUNCC_SENSORS_TEMPERATURE_OUTSIDE       0x011
-
 
38
#define FUNCC_SENSORS_TEMPERATURE_FREEZER       0x012
-
 
39
#define FUNCC_SENSORS_TEMPERATURE_REFRIGERATOR  0x013
-
 
40
 
-
 
41
#define FUNCC_SENSORS_DOORS_FREEZER             0x020
-
 
42
#define FUNCC_SENSORS_DOORS_REFRIGERATOR        0x021
40
 
43
 
41
#define DEFAULT_ID 0x78     // Default ID for bootloader/node when no id is set.
44
#define DEFAULT_ID 0x78     // Default ID for bootloader/node when no id is set.
42
#define DEFAULT_NID 0x00    // Default ID for bootloader/node when no nid is set.
45
#define DEFAULT_NID 0x00    // Default ID for bootloader/node when no nid is set.
43
 
46
 
44
 
47
 
45
#define NODE_ID_EE  0x00    // EEPROM first index where to look for ID and NID. 
48
#define NODE_ID_EE  0x00    // EEPROM first index where to look for ID and NID. 
46
                // NODE_ID_EE = NODE_HAS_ID if has correct ID, otherwise use DEFAULT_ID and DEFAULT_NID
49
                // NODE_ID_EE = NODE_HAS_ID if has correct ID, otherwise use DEFAULT_ID and DEFAULT_NID
47
                // NODE_ID_EE + 1 = ID[1]
50
                // NODE_ID_EE + 1 = ID[1]
48
                // NODE_ID_EE + 2 = ID[0]
51
                // NODE_ID_EE + 2 = ID[0]
49
                // NODE_ID_EE + 3 = NID
52
                // NODE_ID_EE + 3 = NID
50
 
53
 
51
#define NODE_HAS_ID 0x2A    // Value which indicate valid ID and NID.
54
#define NODE_HAS_ID 0x2A    // Value which indicate valid ID and NID.
52
 
55
 
53
 
56
 
54
// Definitions for BOOT packets. Which index in data where things are.
57
// Definitions for BOOT packets. Which index in data where things are.
55
#define BOOT_DATA_ADDRL_INDEX 0
58
#define BOOT_DATA_ADDRL_INDEX 0
56
#define BOOT_DATA_ADDRH_INDEX 1
59
#define BOOT_DATA_ADDRH_INDEX 1
57
#define BOOT_DATA_ADDRU_INDEX 2
60
#define BOOT_DATA_ADDRU_INDEX 2
58
#define BOOT_DATA_RID_LOW_INDEX 4
61
#define BOOT_DATA_RID_LOW_INDEX 4
59
#define BOOT_DATA_RID_HIGH_INDEX 5
62
#define BOOT_DATA_RID_HIGH_INDEX 5
60
#define BOOT_DATA_ERR_INDEX 4
63
#define BOOT_DATA_ERR_INDEX 4
61
#define BOOT_DATA_NEW_ID_LOW_INDEX 0 
64
#define BOOT_DATA_NEW_ID_LOW_INDEX 0 
62
#define BOOT_DATA_NEW_ID_HIGH_INDEX 1 
65
#define BOOT_DATA_NEW_ID_HIGH_INDEX 1 
63
#define BOOT_DATA_NEW_NID_INDEX 2
66
#define BOOT_DATA_NEW_NID_INDEX 2
64
#define BOOT_DATA_HEARTBEAT_INDEX 0
67
#define BOOT_DATA_HEARTBEAT_INDEX 0
65
 
68
 
66
//<ERR>
69
//<ERR>
67
// Value in BOOT_DATA_ERR_INDEX
70
// Value in BOOT_DATA_ERR_INDEX
68
#define ACK_ERR_NO_ERROR 0x00 //= no error
71
#define ACK_ERR_NO_ERROR 0x00 //= no error
69
#define ACK_ERR_ERROR 0x01 //= error
72
#define ACK_ERR_ERROR 0x01 //= error
70
 
73
 
71
//<HEART>
74
//<HEART>
72
#define HEARTBEAT_BOOT_STARTUP 0x00
75
#define HEARTBEAT_BOOT_STARTUP 0x00
73
#define HEARTBEAT_USER_STARTUP 0x01
76
#define HEARTBEAT_USER_STARTUP 0x01
74
#define HEARTBEAT_ALIVE 0x02
77
#define HEARTBEAT_ALIVE 0x02
75
 
78
 
76
 
79
 
-
 
80