Rev 386 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 386 | Rev 389 | ||
|---|---|---|---|
| 1 | /** |
1 | /** |
| 2 | * CAN Test. |
2 | * CAN Test. |
| 3 | * Tests if sending CAN messages is ok. |
3 | * Tests if sending CAN messages is ok. |
| 4 | * |
4 | * |
| 5 | * @date 2006-11-21 |
5 | * @date 2006-11-21 |
| 6 | * @author Jimmy Myhrman |
6 | * @author Jimmy Myhrman |
| 7 | * |
7 | * |
| 8 | */ |
8 | */ |
| 9 | 9 | ||
| 10 | /*----------------------------------------------------------------------------- |
10 | /*----------------------------------------------------------------------------- |
| 11 | * Includes |
11 | * Includes |
| 12 | *---------------------------------------------------------------------------*/ |
12 | *---------------------------------------------------------------------------*/ |
| 13 | /* system files */ |
13 | /* system files */ |
| 14 | #include <avr/io.h> |
14 | #include <avr/io.h> |
| 15 | #include <avr/interrupt.h> |
15 | #include <avr/interrupt.h> |
| 16 | #include <avr/wdt.h> |
16 | #include <avr/wdt.h> |
| 17 | #include <stdio.h> |
17 | #include <stdio.h> |
| 18 | /* lib files */ |
18 | /* lib files */ |
| 19 | #include <can.h> |
19 | #include <can.h> |
| 20 | #include <timebase.h> |
20 | #include <timebase.h> |
| 21 | 21 | ||
| 22 | #define INTERVAL 1000 |
22 | #define INTERVAL 1000 |
| 23 | #define SENDER_ID 0xff |
23 | #define SENDER_ID 0xff |
| 24 | /*----------------------------------------------------------------------------- |
24 | /*----------------------------------------------------------------------------- |
| 25 | * Main Program |
25 | * Main Program |
| 26 | *---------------------------------------------------------------------------*/ |
26 | *---------------------------------------------------------------------------*/ |
| 27 | int main(void) { |
27 | int main(void) { |
| 28 | Timebase_Init(); |
28 | Timebase_Init(); |
| 29 | 29 | ||
| 30 | sei(); |
30 | sei(); |
| 31 | 31 | ||
| 32 | Can_Init(); |
32 | Can_Init(); |
| 33 | 33 | ||
| 34 | uint32_t timeStamp = 0; |
34 | uint32_t timeStamp = 0; |
| 35 | 35 | ||
| 36 | Can_Message_t txMsg; |
36 | Can_Message_t txMsg; |
| 37 | 37 | ||
| 38 | txMsg.Id = SENDER_ID; |
38 | txMsg.Id = SENDER_ID; |
| 39 | txMsg.RemoteFlag = 0; |
39 | txMsg.RemoteFlag = 0; |
| 40 | txMsg.ExtendedFlag = 1; |
40 | txMsg.ExtendedFlag = 1; |
| 41 | txMsg.DataLength = 1; |
41 | txMsg.DataLength = 1; |
| 42 | txMsg.Data.bytes[0] = 0xff; |
42 | txMsg.Data.bytes[0] = 0xff; |
| 43 | 43 | ||
| 44 | /* main loop */ |
44 | /* main loop */ |
| 45 | while (1) { |
45 | while (1) { |
| 46 | /* service the CAN routines */ |
46 | /* service the CAN routines */ |
| 47 | Can_Service(); |
47 | Can_Service(); |
| 48 | 48 | ||
| 49 | /* send CAN message */ |
49 | /* send CAN message */ |
| 50 | if (Timebase_PassedTimeMillis(timeStamp) >= INTERVAL) { |
50 | if (Timebase_PassedTimeMillis(timeStamp) >= INTERVAL) { |
| 51 | timeStamp = Timebase_CurrentTime(); |
51 | timeStamp = Timebase_CurrentTime(); |
| 52 | /* send txMsg */ |
52 | /* send txMsg */ |
| 53 | Can_Send(&txMsg); |
53 | Can_Send(&txMsg); |
| 54 | } |
54 | } |
| 55 | } |
55 | } |
| 56 | 56 | ||
| 57 | return 0; |
57 | return 0; |
| 58 | } |
58 | } |
| 59 | 59 | ||