Rev 79 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 79 | Rev 80 | ||
|---|---|---|---|
| 1 | /********************************************************************* |
1 | /********************************************************************* |
| 2 | * |
2 | * |
| 3 | * CAN.c header file |
3 | * CAN.c header file |
| 4 | * |
4 | * |
| 5 | ********************************************************************* |
5 | ********************************************************************* |
| 6 | * FileName: CAN.h |
6 | * FileName: CAN.h |
| 7 | * |
7 | * |
| 8 | * Author Date Comment |
8 | * Author Date Comment |
| 9 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
9 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 | * Johan Böhlin 21-10-06 Original (Rev 1.0) |
10 | * Johan Böhlin 21-10-06 Original (Rev 1.0) |
| 11 | ********************************************************************/ |
11 | ********************************************************************/ |
| 12 | // |
12 | // $Id: CAN.h 80 2006-11-11 20:22:39Z johboh $ |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | #ifndef CAN_H |
15 | #ifndef CAN_H |
| 16 | #define CAN_H |
16 | #define CAN_H |
| 17 | 17 | ||
| 18 | #include <CANdefs.h> |
18 | #include <CANdefs.h> |
| 19 | #include <compiler.h> |
19 | #include <compiler.h> |
| 20 | #include <typedefs.h> |
20 | #include <typedefs.h> |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | typedef struct _CAN_PROTO_MESSAGE |
23 | typedef struct _CAN_PROTO_MESSAGE |
| 24 | { |
24 | { |
| 25 | BYTE funct; //4 |
25 | BYTE funct; //4 |
| 26 | WORD funcc; //10 |
26 | WORD funcc; //10 |
| 27 | BYTE nid; //6 |
27 | BYTE nid; //6 |
| 28 | WORD sid; //9 |
28 | WORD sid; //9 |
| 29 | BYTE data_length;//5 |
29 | BYTE data_length;//5 |
| 30 | BOOL remote_request; //1 |
30 | BOOL remote_request; //1 |
| 31 | BYTE data[8]; |
31 | BYTE data[8]; |
| 32 | } CAN_PROTO_MESSAGE; |
32 | } CAN_PROTO_MESSAGE; |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | //<FUNCT> |
35 | //<FUNCT> |
| 36 | #define FUNCT_BOOTLOADER 0x0 |
36 | #define FUNCT_BOOTLOADER 0x0 |
| 37 | 37 | ||
| 38 | //<FUNCC> configuration packet |
38 | //<FUNCC> configuration packet |
| 39 | #define FUNCC_BOOT_INIT 0b0000000001 //för att initiera en programmering. |
39 | #define FUNCC_BOOT_INIT 0b0000000001 //för att initiera en programmering. |
| 40 | #define FUNCC_BOOT_ADDR 0b0000000010 //för att ändra adress. |
40 | #define FUNCC_BOOT_ADDR 0b0000000010 //för att ändra adress. |
| 41 | #define FUNCC_BOOT_DONE 0b0000000101 //för att avsluta en programmering. |
41 | #define FUNCC_BOOT_DONE 0b0000000101 //för att avsluta en programmering. |
| 42 | 42 | ||
| 43 | //<FUNCC> program packet |
43 | //<FUNCC> program packet |
| 44 | #define FUNCC_BOOT_PGM 0b0000000011 //för att indikera att detta är programdata som ska skrivas. |
44 | #define FUNCC_BOOT_PGM 0b0000000011 //för att indikera att detta är programdata som ska skrivas. |
| 45 | 45 | ||
| 46 | //<FUNCC> ack packet |
46 | //<FUNCC> ack packet |
| 47 | #define FUNCC_BOOT_ACK 0b0000000100 //för att indikera att detta är en ACK. |
47 | #define FUNCC_BOOT_ACK 0b0000000100 //för att indikera att detta är en ACK. |
| 48 | 48 | ||
| 49 | #define MY_ID 0x78 |
49 | #define MY_ID 0x78 |
| 50 | #define MY_NID 0x00 |
50 | #define MY_NID 0x00 |
| 51 | 51 | ||
| 52 | #define ADDRL_INDEX 0 |
52 | #define ADDRL_INDEX 0 |
| 53 | #define ADDRH_INDEX 1 |
53 | #define ADDRH_INDEX 1 |
| 54 | #define ADDRU_INDEX 2 |
54 | #define ADDRU_INDEX 2 |
| 55 | #define RID_LOW_INDEX 4 |
55 | #define RID_LOW_INDEX 4 |
| 56 | #define RID_HIGH_INDEX 5 |
56 | #define RID_HIGH_INDEX 5 |
| 57 | #define ERR_INDEX 4 |
57 | #define ERR_INDEX 4 |
| 58 | 58 | ||
| 59 | //<ERR> 8 bitar feltyp |
59 | //<ERR> 8 bitar feltyp |
| 60 | #define ERR_NO_ERROR 0x00 //= inget fel |
60 | #define ERR_NO_ERROR 0x00 //= inget fel |
| 61 | #define ERR_ERROR 0x01 //= fel |
61 | #define ERR_ERROR 0x01 //= fel |
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | typedef enum {PRIO_LOWEST=0,PRIO_LOW=1,PRIO_HIGH=2,PRIO_HIGEST=3} CAN_PRIORITY; |
64 | typedef enum {PRIO_LOWEST=0,PRIO_LOW=1,PRIO_HIGH=2,PRIO_HIGEST=3} CAN_PRIORITY; |
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | void canInit(void); |
67 | void canInit(void); |
| 68 | BOOL canSendMessage(CAN_PROTO_MESSAGE cm, CAN_PRIORITY prio); |
68 | BOOL canSendMessage(CAN_PROTO_MESSAGE cm, CAN_PRIORITY prio); |
| 69 | 69 | ||
| 70 | #endif //CAN.h |
70 | #endif //CAN.h |
| 71 | 71 | ||