Subversion Repositories HomeAutomation

Rev

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

Rev 73 Rev 97
1
/*********************************************************************
1
/*********************************************************************
2
 *
2
 *
3
 *                  CAN specification
3
 *                  CAN specification
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:        CANdefs.h
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canToSerial/Include/CANdefs.h $
7
 *
-
 
8
 * Author               Date    Comment
7
 * Last changed:    $LastChangedDate: 2006-11-14 21:22:17 +0100 (Tue, 14 Nov 2006) $
9
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
 * By:              $LastChangedBy: johboh $
10
 * Johan Böhlin     21-10-06    Original        (Rev 1.0)
9
 * Revision:        $Revision: 97 $
11
 ********************************************************************/
10
 ********************************************************************/
12
 
11
 
13
#ifndef CANDEFS_H
12
#ifndef CANDEFS_H
14
#define CANDEFS_H
13
#define CANDEFS_H
15
 
14
 
16
#include <compiler.h>
15
#include <compiler.h>
17
 
16
 
18
#define CAN_BAUD 0.500000 //in Mbits/s
17
#define CAN_BAUD 0.500000 //in Mbits/s
19
//#define CAN_LOOPBACK_MODE
18
//#define CAN_LOOPBACK_MODE
20
 
19
 
21
 
20
 
22
// TQ(us) = (2 * (BRP + 1))/FOSC(MHz)
21
// TQ(us) = (2 * (BRP + 1))/FOSC(MHz)
23
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / (TQ(us) * 8)
22
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / (TQ(us) * 8)
24
// Where 8 is nominal bit time.
23
// Where 8 is nominal bit time.
25
// From this, BRP can be calculated.
24
// From this, BRP can be calculated.
26
//
25
//
27
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / ((2 * (BRP + 1))/FOSC(MHz) * 8)
26
// Nominal Bit Rate(kbit/s) = 1 / TBIT = 1 / ((2 * (BRP + 1))/FOSC(MHz) * 8)
28
                   
27
                   
29
#define CAN_BRP (int)(CLOCK_FOSC/(CAN_BAUD * 16) - 1)
28
#define CAN_BRP (int)(CLOCK_FOSC/(CAN_BAUD * 16) - 1)
30
 
29
 
31
 
30
 
32
#endif //CANdefs.h
31
#endif //CANdefs.h
33
 
32