Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
260 johboh 1
/*********************************************************************
129 johboh 2
 *
3
 *                  Main application
4
 *
5
 *********************************************************************
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canIRtrans/Source/Main.c $
7
 * Last changed:    $LastChangedDate: 2007-01-28 14:58:11 +0100 (Sun, 28 Jan 2007) $
8
 * By:              $LastChangedBy: johboh $
9
 * Revision:        $Revision: 260 $
10
 ********************************************************************/
11
 
12
 
13
#include <compiler.h>
14
#include <stackTasks.h>
15
#include <Tick.h>
16
#include <funcdefs.h>
260 johboh 17
#include <CAN.h>
129 johboh 18
 
19
static void mainInit(void);
20
 
21
void main()
22
{
23
    static TICK t = 0;
24
    CAN_MESSAGE outCm;
25
 
26
    // Inits
27
 
28
    mainInit();
260 johboh 29
    canInit();
129 johboh 30
 
31
 
32
    while(1)
33
    {
34
        static TICK t = 0;
35
 
36
        if ((tickGet()-t)>TICK_SECOND)
37
        {
38
            LED0_IO=~LED0_IO;
39
            t = tickGet();
40
        }
41
    }
42
}
43
 
44
 
45
#pragma interrupt high_isr
46
void high_isr(void)
47
{
260 johboh 48
    canISR();
129 johboh 49
}
50
 
51
 
52
#pragma interrupt low_isr
53
void low_isr(void)
54
{
55
 
56
}
57
 
58
 
59
 
60
/*
61
*   Function: mainInit
62
*
63
*   Input:  none
64
*   Output: none
65
*   Pre-conditions: none
66
*   Affects: Se code
67
*   Depends: none.
68
*/
69
void mainInit()
70
{
71
    LED0_TRIS=0;   
72
 
73
    // Enable Interrupts
74
    INTCONbits.GIEH = 1;
75
    INTCONbits.GIEL = 1;
76
 
77
    // Enable interrupt prirority
78
    RCONbits.IPEN=1;
79
 
80
 
81
}
82
 
83
/*
84
*   Function: canParse
85
*
86
*   Input:  Received can message
87
*   Output: none
88
*   Pre-conditions: canInit and received packet.
89
*   Affects: Sensors/actuators/etc. See code.
90
*   Depends: none.
91
*/
92
void canParse(CAN_MESSAGE cm)
93
{
94
    CAN_MESSAGE outCm;
260 johboh 95
}
129 johboh 96
 
97
 
98
 
99
 
100
// Below are mandantory when using bootloader
101
// define DEBUG_MODE to use without bootloader.
102
 
103
#ifndef DEBUG_MODE
104
extern void _startup (void);
105
#pragma code _RESET_INTERRUPT_VECTOR = 0x001000
106
void _reset (void)
107
{
108
    _asm goto _startup _endasm
109
}
110
#pragma code
111
#endif
112
 
113
#pragma code _HIGH_INTERRUPT_VECTOR = 0x001008
114
void _high_ISR (void)
115
{
116
    _asm GOTO high_isr _endasm
117
}
118
#pragma code
119
 
120
#pragma code _LOW_INTERRUPT_VECTOR = 0x001018
121
void _low_ISR (void)
122
{
123
    _asm GOTO low_isr _endasm
124
}
125
#pragma code