Subversion Repositories HomeAutomation

Rev

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 specification
3
 *                  CAN specification
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:        CANdefs.h
6
 * FileName:        CANdefs.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
// $IDI$
12
// $Id: CANdefs.h 80 2006-11-11 20:22:39Z johboh $
13
 
13
 
14
#ifndef CANDEFS_H
14
#ifndef CANDEFS_H
15
#define CANDEFS_H
15
#define CANDEFS_H
16
 
16
 
17
#include <compiler.h>
17
#include <compiler.h>
18
 
18
 
19
#define CAN_BAUD 0.500000 //in Mbits/s
19
#define CAN_BAUD 0.500000 //in Mbits/s
20
//#define CAN_LOOPBACK_MODE
20
//#define CAN_LOOPBACK_MODE
21
 
21
 
22
 
22
 
23
// TQ(us) = (2 * (BRP + 1))/FOSC(MHz)
23
// TQ(us) = (2 * (BRP + 1))/FOSC(MHz)
24
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / (TQ(us) * 8)
24
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / (TQ(us) * 8)
25
// Where 8 is nominal bit time.
25
// Where 8 is nominal bit time.
26
// From this, BRP can be calculated.
26
// From this, BRP can be calculated.
27
//
27
//
28
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / ((2 * (BRP + 1))/FOSC(MHz) * 8)
28
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / ((2 * (BRP + 1))/FOSC(MHz) * 8)
29
                   
29
                   
30
#define CAN_BRP (int)(CLOCK_FOSC/(CAN_BAUD * 16) - 1)
30
#define CAN_BRP (int)(CLOCK_FOSC/(CAN_BAUD * 16) - 1)
31
 
31
 
32
 
32
 
33
#endif //CANdefs.h
33
#endif //CANdefs.h
34
 
34