Subversion Repositories HomeAutomation

Rev

Rev 260 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 260 Rev 341
Line 2... Line 2...
2
 *
2
 *
3
 *                  Main application
3
 *                  Main application
4
 *
4
 *
5
 *********************************************************************
5
 *********************************************************************
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canIR/Source/Main.c $
6
 * FileName:        $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canIR/Source/Main.c $
7
 * Last changed:    $LastChangedDate: 2007-01-28 14:58:11 +0100 (Sun, 28 Jan 2007) $
7
 * Last changed:    $LastChangedDate: 2007-02-25 21:15:41 +0100 (Sun, 25 Feb 2007) $
8
 * By:              $LastChangedBy: johboh $
8
 * By:              $LastChangedBy: johboh $
9
 * Revision:        $Revision: 260 $
9
 * Revision:        $Revision: 341 $
10
 ********************************************************************/
10
 ********************************************************************/
11
 
11
 
12
 
12
 
13
#include <compiler.h>
13
#include <compiler.h>
14
#include <stackTasks.h>
14
#include <stackTasks.h>
15
#include <Tick.h>
15
#include <Tick.h>
16
#include <funcdefs.h>
16
#include <funcdefs.h>
17
#include <CAN.h>
17
#include <CAN.h>
-
 
18
#include "..\canBoot\Include\boot.h"
18
 
19
 
19
 
20
 
20
#ifdef USE_IREC
21
#ifdef USE_IREC
21
    #include <IRec.h>
22
    #include <IRec.h>
22
#endif
23
#endif
Line 25... Line 26...
25
 
26
 
26
 
27
 
27
void main()
28
void main()
28
{
29
{
29
    static TICK t = 0;
30
    static TICK t = 0;
30
    CAN_MESSAGE outCm;
31
    CAN_PACKET outCp;
31
 
32
 
32
    // Inits
33
    // Inits
33
 
34
 
34
    mainInit();
35
    mainInit();
35
    canInit();
36
    canInit();
Line 103... Line 104...
103
*   Pre-conditions: canInit and received packet.
104
*   Pre-conditions: canInit and received packet.
104
*   Affects: Sensors/actuators/etc. See code.
105
*   Affects: Sensors/actuators/etc. See code.
105
*   Depends: none.
106
*   Depends: none.
106
*/
107
*/
107
 
108
 
108
void canParse(CAN_MESSAGE cm)
109
void canParse(CAN_PACKET cp)
109
{
110
{
110
    CAN_MESSAGE outCm;
-
 
111
 
111
 
112
}
112
}
113
 
113
 
114
 
114
 
115
 
115
 
Line 123... Line 123...
123
*   Depends: none.
123
*   Depends: none.
124
*/
124
*/
125
#ifdef USE_IREC
125
#ifdef USE_IREC
126
void irecParse(IR_TYPE type, BYTE toggle, BYTE addr, BYTE data)
126
void irecParse(IR_TYPE type, BYTE toggle, BYTE addr, BYTE data)
127
{
127
{
128
    CAN_MESSAGE outCm;
128
    CAN_PACKET outCp;
129
    outCm.funct         = FUNCT_SENSORS;
-
 
130
    outCm.funcc         = FUNCC_SENSORS_IR;
-
 
131
    outCm.data_length   = 4;
-
 
132
    outCm.data[3]       = type;
-
 
133
    outCm.data[2]       = toggle;
-
 
134
    outCm.data[1]       = addr;
-
 
135
    outCm.data[0]       = data;
-
 
136
   
129
 
-
 
130
    outCp.type      = ptPGM;
-
 
131
    outCp.pgm.class = pcSENSOR;
-
 
132
    outCp.pgm.id    = pstIR;
-
 
133
    outCp.length    = 4;
-
 
134
    outCp.data[3]   = type;
-
 
135
    outCp.data[2]   = toggle;
-
 
136
    outCp.data[1]   = addr;
-
 
137
    outCp.data[0]   = data;
137
    while(!canSendMessage(outCm,PRIO_HIGH));
138
    while(!canSendMessage(outCp,PRIO_HIGH));
138
 
139
 
139
 
140
 
140
}
141
}
141
#endif
142
#endif
142
 
143
 
143
// Below are mandantory when using bootloader
144
// Below are mandantory when using bootloader
144
// define DEBUG_MODE to use without bootloader.
145
// define DEBUG_MODE to use without bootloader.
145
 
146
 
146
#ifndef DEBUG_MODE
147
#ifndef DEBUG_MODE
147
extern void _startup (void);
148
extern void _startup (void);
148
#pragma code _RESET_INTERRUPT_VECTOR = 0x001000
149
#pragma code _RESET_INTERRUPT_VECTOR = RM_RESET_VECTOR
149
void _reset (void)
150
void _reset (void)
150
{
151
{
151
    _asm goto _startup _endasm
152
    _asm goto _startup _endasm
152
}
153
}
153
#pragma code
154
#pragma code
154
#endif
155
#endif
155
 
156
 
156
#pragma code _HIGH_INTERRUPT_VECTOR = 0x001008
157
#pragma code _HIGH_INTERRUPT_VECTOR = RM_HIGH_INTERRUPT_VECTOR
157
void _high_ISR (void)
158
void _high_ISR (void)
158
{
159
{
159
    _asm GOTO high_isr _endasm
160
    _asm GOTO high_isr _endasm
160
}
161
}
161
#pragma code
162
#pragma code
162
 
163
 
163
#pragma code _LOW_INTERRUPT_VECTOR = 0x001018
164
#pragma code _LOW_INTERRUPT_VECTOR = RM_LOW_INTERRUPT_VECTOR
164
void _low_ISR (void)
165
void _low_ISR (void)
165
{
166
{
166
    _asm GOTO low_isr _endasm
167
    _asm GOTO low_isr _endasm
167
}
168
}
168
#pragma code
169
#pragma code