Subversion Repositories HomeAutomation

Rev

Rev 1468 | Rev 1630 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1468 Rev 1629
Line 1... Line 1...
1
/*
1
/*
2
 * $Id: bios.c 1468 2010-05-06 15:45:50Z arune $
2
 * $Id: bios.c 1629 2010-12-02 13:17:49Z arune $
3
 */
3
 */
4
 
4
 
5
#include <inttypes.h>
5
#include <inttypes.h>
6
#include <avr/io.h>
6
#include <avr/io.h>
7
#include <avr/interrupt.h>
7
#include <avr/interrupt.h>
Line 22... Line 22...
22
 
22
 
23
#if defined(__AVR_ATmega8__)
23
#if defined(__AVR_ATmega8__)
24
#define IVSEL_REG GICR
24
#define IVSEL_REG GICR
25
#elif defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
25
#elif defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
26
#define IVSEL_REG MCUCR
26
#define IVSEL_REG MCUCR
-
 
27
#else
-
 
28
#error AVR device not supported!
-
 
29
#endif
-
 
30
 
-
 
31
/* DEVICETYPE is sent in bios start frame */
-
 
32
#if defined(__AVR_ATmega8__)
-
 
33
#define DEVICETYPE 0
-
 
34
#elif defined(__AVR_ATmega88__) 
-
 
35
#define DEVICETYPE 2
-
 
36
#elif defined(__AVR_ATmega168__) 
-
 
37
#define DEVICETYPE 3
-
 
38
#elif defined(__AVR_ATmega168P__) 
-
 
39
#define DEVICETYPE 3
-
 
40
#elif defined(__AVR_ATmega328P__)
-
 
41
#define DEVICETYPE 4
27
#else
42
#else
28
#error AVR device not supported!
43
#error AVR device not supported!
29
#endif
44
#endif
30
 
45
 
31
#if defined(AUTOSTART)
46
#if defined(AUTOSTART)
Line 128... Line 143...
128
    tx_msg.ExtendedFlag = 1;
143
    tx_msg.ExtendedFlag = 1;
129
    tx_msg.Id = CAN_ID_NMT_BIOS_START;
144
    tx_msg.Id = CAN_ID_NMT_BIOS_START;
130
    tx_msg.DataLength = 8;
145
    tx_msg.DataLength = 8;
131
    tx_msg.Data.bytes[0] = BIOS_VERSION&0xff;
146
    tx_msg.Data.bytes[0] = BIOS_VERSION&0xff;
132
    tx_msg.Data.bytes[1] = (BIOS_VERSION>>8)&0xff;
147
    tx_msg.Data.bytes[1] = (BIOS_VERSION>>8)&0xff;
133
    tx_msg.Data.bytes[3] = 0x00;
148
    tx_msg.Data.bytes[3] = DEVICETYPE;
134
    tx_msg.Data.bytes[4] = hwid&0xff;
149
    tx_msg.Data.bytes[4] = hwid&0xff;
135
    tx_msg.Data.bytes[5] = (hwid>>8)&0xff;
150
    tx_msg.Data.bytes[5] = (hwid>>8)&0xff;
136
    tx_msg.Data.bytes[6] = (hwid>>16)&0xff;
151
    tx_msg.Data.bytes[6] = (hwid>>16)&0xff;
137
    tx_msg.Data.bytes[7] = (hwid>>24)&0xff;
152
    tx_msg.Data.bytes[7] = (hwid>>24)&0xff;
138
 
153