FreeEMS  0.2.0-SNAPSHOT-282-g9efc524
xgateVectors.h
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2  *
3  * Copyright 2010 Fred Cooke
4  *
5  * This file is part of the FreeEMS project.
6  *
7  * FreeEMS software is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FreeEMS software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
19  *
20  * We ask that if you make any changes to this file you email them upstream to
21  * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22  *
23  * Thank you for choosing FreeEMS to run your engine!
24  */
25 
26 /** @file
27  *
28  * @ingroup xgateFiles
29  * @ingroup xgateHeaders
30  *
31  * @brief C header for assembly xgate functions
32  *
33  * Because we need to call the assembly flash burning function from C code an
34  * extern function declaration is required to allow successful compilation.
35  *
36  * @author Sean Keys
37  */
38 #ifndef FILE_XGATEVECTORS_H_SEEN
39 #define FILE_XGATEVECTORS_H_SEEN
40 
41 
42 #ifdef EXTERN
43 #warning "EXTERN already defined by another header, please sort it out!"
44 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
45 #endif
46 
47 
48 #ifdef XGATEVECTORS_C
49 #define EXTERN
50 #else
51 #define EXTERN extern
52 #endif
53 
54 #define START_OF_FLASH_WINDOW (unsigned short*)0x8000 /* 16KB long */
55 #define START_OF_RAM_WINDOW (unsigned short*)0x1000 /* 4KB long */
56 #define XGATE_RAM_ALLOCATION_SIZE 0x0200 /* 512Bytes */
57 #define RPAGE_TUNE_TWO_WINDOW_DIFFERENCE (0x8000) /*xgate RPAGE2 starts at 0x9000 but the s12 window starts at 0x10000 */
58 #define XGATE_INTERRUPT 0x80
59 #define PRIORITY_LEVEL_ONE 0x01
60 
61 #define ROUTE_INTERRUPT(channel_id, cpu_assignment, priority) \
62  INT_CFADDR = (channel_id * 2) & 0xF0; \
63  INT_CFDATA_ARR[((channel_id * 2) & 0x0F) >> 1] = (cpu_assignment | priority);
64 
65 typedef struct {
66  unsigned short programCounterValue; /* This data is forced into the XGATE PC register */
67  unsigned short initialVariable; /* This data is forced into the XGATE R1 register */
69 
70 // This statement imports the symbol from the xgate ASM for use in the vector table
71 void xgateSchedule();
72 void xgatePITTurnOff();
73 void xgatePITTurnOn();
74 void xgateDelayCounter();
75 void startXGATECode();
76 void endXGATECode();
77 void parameterGuard(); /* counter that gets update when a write to shared RAM begins and again when the write is complete */
78 
80 
81 
82 // Xgate control value
83 #define XGATE_ERROR_HANDLER 0x0000 /* TODO Create the XGATE error handling thread in asm. */
84 
85 
86 #else
87  /* let us know if we are being untidy with headers */
88  #warning "Header file XGATEVECTORS_H seen before, sort it out!"
89 /* end of the wrapper ifdef from the very top */
90 #endif