Subversion Repositories HomeAutomation

Rev

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

Rev 88 Rev 91
1
/*********************************************************************
1
/*********************************************************************
2
 *
2
 *
3
 *                  CAN module header file
3
 *                  CAN module header file
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canBoot/Include/CAN.h $
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canBoot/Include/CAN.h $
7
 * Last changed:    $LastChangedDate: 2006-11-14 11:44:27 +0100 (Tue, 14 Nov 2006) $
7
 * Last changed:    $LastChangedDate: 2006-11-14 12:50:16 +0100 (Tue, 14 Nov 2006) $
8
 * By:              $LastChangedBy: johboh $
8
 * By:              $LastChangedBy: johboh $
9
 * Revision:        $Revision: 88 $
9
 * Revision:        $Revision: 91 $
10
 ********************************************************************/
10
 ********************************************************************/
11
 
11
 
12
 
12
 
13
#ifndef CAN_H
13
#ifndef CAN_H
14
#define CAN_H
14
#define CAN_H
15
 
15
 
16
#include <CANdefs.h>
16
#include <CANdefs.h>
17
#include <compiler.h>
17
#include <compiler.h>
18
#include <typedefs.h>
18
#include <typedefs.h>
19
 
19
 
20
 
20
 
21
typedef struct _CAN_PROTO_MESSAGE
21
typedef struct _CAN_PROTO_MESSAGE
22
{
22
{
23
    BYTE funct; //4
23
    BYTE funct; //4
24
    WORD funcc; //10
24
    WORD funcc; //10
25
    BYTE nid; //6
25
    BYTE nid; //6
26
    WORD sid; //9
26
    WORD sid; //9
27
    BYTE data_length;//5
27
    BYTE data_length;//5
28
    BYTE data[8];
28
    BYTE data[8];
29
} CAN_PROTO_MESSAGE;
29
} CAN_PROTO_MESSAGE;
30
 
30
 
31
 
-
 
32
//<FUNCT>
-
 
33
#define FUNCT_BOOTLOADER 0x0
-
 
34
 
-
 
35
//<FUNCC> configuration packet
-
 
36
#define FUNCC_BOOT_INIT 0b0000000001 //för att initiera en programmering.
-
 
37
#define FUNCC_BOOT_ADDR 0b0000000010  //för att ändra adress.
-
 
38
#define FUNCC_BOOT_DONE 0b0000000101  //för att avsluta en programmering.
-
 
39
 
-
 
40
//<FUNCC> program packet
-
 
41
#define FUNCC_BOOT_PGM 0b0000000011 //för att indikera att detta är programdata som ska skrivas.
-
 
42
 
-
 
43
//<FUNCC> ack packet
-
 
44
#define FUNCC_BOOT_ACK 0b0000000100 //för att indikera att detta är en ACK.
-
 
45
 
31
 
46
#define MY_ID 0x78 
32
#define MY_ID 0x78 
47
#define MY_NID 0x00
33
#define MY_NID 0x00
48
 
34
 
49
#define ADDRL_INDEX 0
35
#define ADDRL_INDEX 0
50
#define ADDRH_INDEX 1
36
#define ADDRH_INDEX 1
51
#define ADDRU_INDEX 2
37
#define ADDRU_INDEX 2
52
#define RID_LOW_INDEX 4
38
#define RID_LOW_INDEX 4
53
#define RID_HIGH_INDEX 5
39
#define RID_HIGH_INDEX 5
54
#define ERR_INDEX 4
40
#define ERR_INDEX 4
55
 
41
 
56
//<ERR> 8 bitar feltyp
42
//<ERR> 8 bitar feltyp
57
#define ERR_NO_ERROR 0x00 //= inget fel
43
#define ERR_NO_ERROR 0x00 //= inget fel
58
#define ERR_ERROR 0x01 //= fel
44
#define ERR_ERROR 0x01 //= fel
59
 
45
 
60
 
46
 
61
typedef enum {PRIO_LOWEST=0,PRIO_LOW=1,PRIO_HIGH=2,PRIO_HIGEST=3} CAN_PRIORITY;
47
typedef enum {PRIO_LOWEST=0,PRIO_LOW=1,PRIO_HIGH=2,PRIO_HIGEST=3} CAN_PRIORITY;
62
 
48
 
63
 
49
 
64
void canInit(void);
50
void canInit(void);
65
BOOL canSendMessage(CAN_PROTO_MESSAGE cm, CAN_PRIORITY prio);
51
BOOL canSendMessage(CAN_PROTO_MESSAGE cm, CAN_PRIORITY prio);
66
 
52
 
67
#endif //CAN.h
53
#endif //CAN.h
68
 
54