Subversion Repositories HomeAutomation

Rev

Go to most recent revision | Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
801 linlun 1
#include <inttypes.h>
2
#include <avr/interrupt.h>
3
#include <stdio.h>
4
#include <string.h>
5
#include <std_can.h>
6
#include <config.h> // All configuration parameters
7
#include <bios.h>   // BIOS interface declarations, including CAN structure and ID defines.
8
#include <drivers/timer/timer.h>
9
 
10
%INCLUDE
11
 
12
int main(void)
13
{
14
	volatile StdCan_Msg_t rxMsg; // Message storage
15
 
16
	// Enable interrupts as early as possible
17
	sei();
18
 
19
	Timer_Init();
20
 
21
	StdCan_Init();
22
 
23
	Timer_SetTimeout(APP_HEARTBEAT_TIMER, STDCAN_HEARTBEAT_PERIOD, TimerTypeFreeRunning, StdCan_SendHeartbeat);
24
 
25
	%INIT
26
 
27
	while (1) {
28
 
29
		%PROCESS
30
 
31
		if (StdCan_Get(&rxMsg) == StdCan_Ret_OK) {
32
 
33
			if (StdCan_Ret_class(rxMsg) == CAN_MODULE_NMT) {
34
 
35
				if (rxMsg.Header.ModuleType == CAN_MODULE_NMT_LIST) {
36
 
37
					%LIST
38
				}
39
			}
40
			else {
41
 
42
				%MESSAGE_HANDLE
43
			}
44
    		}
45
	}
46
 
47
	return 0;
48
}