Speeduino
Loading...
Searching...
No Matches
board_template.h
Go to the documentation of this file.
1#ifndef TEMPLATE_H
2#define TEMPLATE_H
3#if defined(CORE_TEMPLATE)
4
5/*
6***********************************************************************************************************
7* General
8*/
9 #define PORT_TYPE uint32_t //Size of the port variables (Eg inj1_pin_port). Most systems use a byte, but SAMD21 and possibly others are a 32-bit unsigned int
10 #define PINMASK_TYPE uint32_t
11 #define SERIAL_BUFFER_SIZE 517 //Size of the serial buffer used by new comms protocol. For SD transfers this must be at least 512 + 1 (flag) + 4 (sector)
12 #define FPU_MAX_SIZE 0 //Size of the FPU buffer. 0 means no FPU.
13 #define BOARD_MAX_IO_PINS 52 //digital pins + analog channels + 1
14 #define BOARD_MAX_DIGITAL_PINS 52 //Pretty sure this isn't right
15 #define EEPROM_LIB_H <EEPROM.h> //The name of the file that provides the EEPROM class
16 typedef int eeprom_address_t;
17 #define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
18 void initBoard();
20 void doSystemReset();
21 void jumpToBootloader();
22
23 #define pinIsReserved(pin) ( ((pin) == 0) ) //Forbidden pins like USB
24
25/*
26***********************************************************************************************************
27* Schedules
28*/
29
30 #define FUEL1_COUNTER <register here>
31 #define FUEL2_COUNTER <register here>
32 #define FUEL3_COUNTER <register here>
33 #define FUEL4_COUNTER <register here>
34 //The below are optional, but recommended if there are sufficient timers/compares
35 #define FUEL5_COUNTER <register here>
36 #define FUEL6_COUNTER <register here>
37 #define FUEL7_COUNTER <register here>
38 #define FUEL8_COUNTER <register here>
39
40 #define IGN1_COUNTER <register here>
41 #define IGN2_COUNTER <register here>
42 #define IGN3_COUNTER <register here>
43 #define IGN4_COUNTER <register here>
44 //The below are optional, but recommended if there are sufficient timers/compares
45 #define IGN5_COUNTER <register here>
46 #define IGN6_COUNTER <register here>
47 #define IGN7_COUNTER <register here>
48 #define IGN8_COUNTER <register here>
49
50 #define FUEL1_COMPARE <register here>
51 #define FUEL2_COMPARE <register here>
52 #define FUEL3_COMPARE <register here>
53 #define FUEL4_COMPARE <register here>
54 //The below are optional, but recommended if there are sufficient timers/compares
55 #define FUEL5_COMPARE <register here>
56 #define FUEL6_COMPARE <register here>
57 #define FUEL7_COMPARE <register here>
58 #define FUEL8_COMPARE <register here>
59
60 #define IGN1_COMPARE <register here>
61 #define IGN2_COMPARE <register here>
62 #define IGN3_COMPARE <register here>
63 #define IGN4_COMPARE <register here>
64 //The below are optional, but recommended if there are sufficient timers/compares
65 #define IGN5_COMPARE <register here>
66 #define IGN6_COMPARE <register here>
67 #define IGN7_COMPARE <register here>
68 #define IGN8_COMPARE <register here>
69
70 static inline void FUEL1_TIMER_ENABLE(void) {<macro here>;}
71 static inline void FUEL2_TIMER_ENABLE(void) {<macro here>;}
72 static inline void FUEL3_TIMER_ENABLE(void) {<macro here>;}
73 static inline void FUEL4_TIMER_ENABLE(void) {<macro here>;}
74 //The below are optional, but recommended if there are sufficient timers/compares
75 static inline void FUEL5_TIMER_ENABLE(void) {<macro here>;}
76 static inline void FUEL6_TIMER_ENABLE(void) {<macro here>;}
77 static inline void FUEL7_TIMER_ENABLE(void) {<macro here>;}
78 static inline void FUEL8_TIMER_ENABLE(void) {<macro here>;}
79
80 static inline void FUEL1_TIMER_DISABLE(void) { <macro here>;}
81 static inline void FUEL2_TIMER_DISABLE(void) { <macro here>;}
82 static inline void FUEL3_TIMER_DISABLE(void) { <macro here>;}
83 static inline void FUEL4_TIMER_DISABLE(void) { <macro here>;}
84 //The below are optional, but recommended if there are sufficient timers/compares
85 static inline void FUEL5_TIMER_DISABLE(void) { <macro here>;}
86 static inline void FUEL6_TIMER_DISABLE(void) { <macro here>;}
87 static inline void FUEL7_TIMER_DISABLE(void) { <macro here>;}
88 static inline void FUEL8_TIMER_DISABLE(void) { <macro here>;}
89
90 static inline void IGN1_TIMER_ENABLE(void) {<macro here>;}
91 static inline void IGN2_TIMER_ENABLE(void) {<macro here>;}
92 static inline void IGN3_TIMER_ENABLE(void) {<macro here>;}
93 static inline void IGN4_TIMER_ENABLE(void) {<macro here>;}
94 //The below are optional, but recommended if there are sufficient timers/compares
95 static inline void IGN5_TIMER_ENABLE(void) {<macro here>;}
96 static inline void IGN6_TIMER_ENABLE(void) {<macro here>;}
97 static inline void IGN7_TIMER_ENABLE(void) {<macro here>;}
98 static inline void IGN8_TIMER_ENABLE(void) {<macro here>;}
99
100 static inline void IGN1_TIMER_DISABLE(void) {<macro here>;}
101 static inline void IGN2_TIMER_DISABLE(void) {<macro here>;}
102 static inline void IGN3_TIMER_DISABLE(void) {<macro here>;}
103 static inline void IGN4_TIMER_DISABLE(void) {<macro here>;}
104 //The below are optional, but recommended if there are suffici;}ent timers/compares
105 static inline void IGN5_TIMER_DISABLE(void) {<macro here>;}
106 static inline void IGN6_TIMER_DISABLE(void) {<macro here>;}
107 static inline void IGN7_TIMER_DISABLE(void) {<macro here>;}
108 static inline void IGN8_TIMER_DISABLE(void) {<macro here>;}
109
110
111 #define MAX_TIMER_PERIOD 139808 //This is the maximum time, in uS, that the compare channels can run before overflowing. It is typically 65535 * <how long each tick represents>
112 #define uS_TO_TIMER_COMPARE(uS) ((uS * 15) >> 5) //Converts a given number of uS into the required number of timer ticks until that time has passed.
113
114/*
115***********************************************************************************************************
116* Auxiliaries
117*/
118 //macro functions for enabling and disabling timer interrupts for the boost and vvt functions
119 #define ENABLE_BOOST_TIMER() <macro here>
120 #define DISABLE_BOOST_TIMER(void) { <macro here>
121
122 #define ENABLE_VVT_TIMER() <macro here>
123 #define DISABLE_VVT_TIMER() <macro here>
124
125 #define BOOST_TIMER_COMPARE <register here>
126 #define BOOST_TIMER_COUNTER <register here>
127 #define VVT_TIMER_COMPARE <register here>
128 #define VVT_TIMER_COUNTER <register here>
129
130/*
131***********************************************************************************************************
132* Idle
133*/
134 //Same as above, but for the timer controlling PWM idle
135 #define IDLE_COUNTER <register here>
136 #define IDLE_COMPARE <register here>
137
138 #define IDLE_TIMER_ENABLE() <macro here>
139 #define IDLE_TIMER_DISABLE() <macro here>
140
141/*
142***********************************************************************************************************
143* CAN / Second serial
144*/
145
146
147#endif //CORE_TEMPLATE
148#endif //TEMPLATE_H
static uint32_t rshift(uint32_t a)
Bitwise right shift - generic, unoptimized, case.
Definition bit_shifts.h:349