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
 *                  Compiler specific
3
 *                  Compiler specific
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:        compiler.h
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canToSerial/Include/compiler.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 COMPILER_H
12
#ifndef COMPILER_H
14
#define COMPILER_H
13
#define COMPILER_H
15
 
14
 
16
#include <p18cxxx.h>
15
#include <p18cxxx.h>
17
#define CLOCK_FREQ      (40000000)      // Hz
16
#define CLOCK_FREQ      (40000000)      // Hz
18
#define INSTR_FREQ          (CLOCK_FREQ/4)
17
#define INSTR_FREQ          (CLOCK_FREQ/4)
19
#define CLOCK_FOSC      (40)      // MHz
18
#define CLOCK_FOSC      (40)      // MHz
20
 
19
 
21
#define UART_BAUD_RATE       (115200)     // bps
20
#define UART_BAUD_RATE       (115200)     // bps
22
#define HIGH_BRG
21
#define HIGH_BRG
23
 
22
 
24
#ifdef HIGH_BRG
23
#ifdef HIGH_BRG
25
    #define SPBRG_VAL   ( ((CLOCK_FREQ/UART_BAUD_RATE)/4) - 1)
24
    #define SPBRG_VAL   ( ((CLOCK_FREQ/UART_BAUD_RATE)/4) - 1)
26
    #define SPBRGH_VAL  0
25
    #define SPBRGH_VAL  0
27
#else
26
#else
28
    #define SPBRG_VAL   ( ((INSTR_FREQ/UART_BAUD_RATE)/16) - 1)
27
    #define SPBRG_VAL   ( ((INSTR_FREQ/UART_BAUD_RATE)/16) - 1)
29
#endif
28
#endif
30
 
29
 
31
 
30
 
32
#if (SPBRG_VAL > 255)
31
#if (SPBRG_VAL > 255)
33
    #error "Calculated SPBRG value is out of range for currnet CLOCK_FREQ."
32
    #error "Calculated SPBRG value is out of range for currnet CLOCK_FREQ."
34
#endif
33
#endif
35
 
34
 
36
#define LED0_TRIS       (TRISCbits.TRISC1)
35
#define LED0_TRIS       (TRISCbits.TRISC1)
37
#define LED0_IO         (PORTCbits.RC1)
36
#define LED0_IO         (PORTCbits.RC1)
38
 
37
 
39
#define UART_START_BYTE 253
38
#define UART_START_BYTE 253
40
#define UART_END_BYTE 250
39
#define UART_END_BYTE 250
41
 
40
 
42
#define UART_READ_TIMEOUT 30000
41
#define UART_READ_TIMEOUT 30000
43
 
42
 
44
#endif //compiler.h
43
#endif //compiler.h
45
 
44