Subversion Repositories HomeAutomation

Rev

Rev 24 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 24 Rev 25
-
 
1
/*********************************************************************
-
 
2
 *
-
 
3
 *                  CAN specification
-
 
4
 *
-
 
5
 *********************************************************************
-
 
6
 * FileName:        CANdefs.h
-
 
7
 *
-
 
8
 * Author               Date    Comment
-
 
9
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
 
10
 * Johan Böhlin     21-10-06    Original        (Rev 1.0)
-
 
11
 ********************************************************************/
-
 
12
 
1
#ifndef CANDEFS_H
13
#ifndef CANDEFS_H
2
#define CANDEFS_H
14
#define CANDEFS_H
3
 
15
 
4
#include "../Include/compiler.h"
16
#include "../Include/compiler.h"
5
 
17
 
6
#define CAN_BAUD 0.250000 //in Mbits/s
18
#define CAN_BAUD 0.250000 //in Mbits/s
7
#define CAN_LOOPBACK_MODE
19
#define CAN_LOOPBACK_MODE
8
 
20
 
9
 
21
 
10
// TQ(us) = (2 * (BRP + 1))/FOSC(MHz)
22
// TQ(us) = (2 * (BRP + 1))/FOSC(MHz)
11
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / (TQ(us) * 8)
23
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / (TQ(us) * 8)
12
// Where 8 is nominal bit time.
24
// Where 8 is nominal bit time.
13
// From this, BRP can be calculated.
25
// From this, BRP can be calculated.
14
//
26
//
15
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / ((2 * (BRP + 1))/FOSC(MHz) * 8)
27
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / ((2 * (BRP + 1))/FOSC(MHz) * 8)
16
                   
28
                   
17
#define CAN_BRP (int)(CLOCK_FOSC/(CAN_BAUD * 16) - 1)
29
#define CAN_BRP (int)(CLOCK_FOSC/(CAN_BAUD * 16) - 1)
18
 
30
 
19
 
31
 
20
#endif //CANdefs.h
32
#endif //CANdefs.h
21
 
33