Subversion Repositories HomeAutomation

Rev

Rev 56 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 56 Rev 64
Line 16... Line 16...
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_MESSAGE
21
typedef struct _CAN_PROTO_MESSAGE
22
{
22
{
23
   
23
    BYTE funct; //4
24
    DWORD ident;
24
    WORD funcc; //10
25
    BOOL extended;
25
    BYTE nid; //6
26
    BOOL remote_request;
26
    WORD sid; //9
27
    BYTE data_length;
27
    BYTE data_length;//5
-
 
28
    BOOL remote_request; //1
28
    BYTE data[8];
29
    BYTE data[8];
29
} CAN_MESSAGE;
30
} CAN_PROTO_MESSAGE;
-
 
31
 
-
 
32
 
-
 
33
//<FUNCT>
-
 
34
#define FUNCT_BOOTLOADER 0x0
-
 
35
 
-
 
36
//<FUNCC> configuration packet
-
 
37
#define FUNCC_BOOT_INIT 0b0000000001 //för att initiera en programmering.
-
 
38
#define FUNCC_BOOT_ADDR 0b0000000010  //för att ändra adress.
-
 
39
#define FUNCC_BOOT_DONE 0b0000000101  //för att avsluta en programmering.
-
 
40
 
-
 
41
//<FUNCC> program packet
-
 
42
#define FUNCC_BOOT_PGM 0b0000000011 //för att indikera att detta är programdata som ska skrivas.
-
 
43
 
-
 
44
//<FUNCC> ack packet
-
 
45
#define FUNCC_BOOT_ACK 0b0000000100 //för att indikera att detta är en ACK.
-
 
46
 
-
 
47
#define MY_ID 0x78 
-
 
48
#define MY_NID 0x00
-
 
49
 
-
 
50
#define ADDRL_INDEX 0
-
 
51
#define ADDRH_INDEX 1
-
 
52
#define ADDRU_INDEX 2
-
 
53
#define RID_INDEX 4
-
 
54
#define ERR_INDEX 4
-
 
55
 
-
 
56
//<ERR> 8 bitar feltyp
-
 
57
#define ERR_NO_ERROR 0x00 //= inget fel
-
 
58
#define ERR_ERROR 0x01 //= fel
30
 
59
 
31
 
60
 
32
typedef enum {PRIO_LOWEST=0,PRIO_LOW=1,PRIO_HIGH=2,PRIO_HIGEST=3} CAN_PRIORITY;
61
typedef enum {PRIO_LOWEST=0,PRIO_LOW=1,PRIO_HIGH=2,PRIO_HIGEST=3} CAN_PRIORITY;
33
 
62
 
34
 
63
 
35
void canInit(void);
64
void canInit(void);
36
void canISR(void);
-
 
37
void canParse(CAN_MESSAGE cm);
-
 
38
BOOL canSendMessage(CAN_MESSAGE cm, CAN_PRIORITY prio);
65
BOOL canSendMessage(CAN_PROTO_MESSAGE cm, CAN_PRIORITY prio);
39
 
66
 
40
#endif //CAN.h
67
#endif //CAN.h