forked from collin80/M2RET
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.h
183 lines (154 loc) · 6.41 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* config.h
*
* Defines the components to be used in the GEVCU and allows the user to configure
* static parameters.
*
* Note: Make sure with all pin defintions of your hardware that each pin number is
* only defined once.
Copyright (c) 2013-2016 Collin Kidder, Michael Neuweiler, Charles Galpin
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Author: Michael Neuweiler
*/
#ifndef CONFIG_H_
#define CONFIG_H_
#include "due_can.h"
struct FILTER { //should be 10 bytes
uint32_t id;
uint32_t mask;
boolean extended;
boolean enabled;
};
enum FILEOUTPUTTYPE
{
NONE = 0,
BINARYFILE = 1,
GVRET = 2,
CRTD = 3
};
struct EEPROMSettings { //Must stay under 256 - currently somewhere around 222
uint8_t version;
uint32_t CAN0Speed;
uint32_t CAN1Speed;
boolean CAN0_Enabled;
boolean CAN1_Enabled;
FILTER CAN0Filters[8]; // filters for our 8 mailboxes - 10*8 = 80 bytes
FILTER CAN1Filters[8]; // filters for our 8 mailboxes - 10*8 = 80 bytes
boolean useBinarySerialComm; //use a binary protocol on the serial link or human readable format?
FILEOUTPUTTYPE fileOutputType; //what format should we use for file output?
char fileNameBase[30]; //Base filename to use
char fileNameExt[4]; //extension to use
uint16_t fileNum; //incrementing value to append to filename if we create a new file each time
boolean appendFile; //start a new file every power up or append to current?
boolean autoStartLogging; //should logging start immediately on start up?
uint8_t logLevel; //Level of logging to output on serial line
uint8_t sysType; //0 = CANDUE, 1 = GEVCU, 2 = CANDue13, 3 = Macchina M2
uint16_t valid; //stores a validity token to make sure EEPROM is not corrupt
uint8_t singleWireMode; //anything other than 1 means normal mode. 1 means use single wire mode where we strobe the enable line to go into HV mode
boolean CAN0ListenOnly; //if true we don't allow any messing with the bus but rather just passively monitor.
boolean CAN1ListenOnly;
};
struct DigitalCANToggleSettings //16 bytes
{
/* Mode is a bitfield.
* Bit 0 -
* 0 = Read pin and send message when it changes state
* 1 = Set digital I/O on CAN Rx (Add 127
*
* Bit 1 -
* 0 = Don't listen to or send on CAN0
* 1 = Listen on or send on CAN0
* Bit 2 -
* 0 = Don't listen to or send on CAN1
* 1 = Listen on or send on CAN1
* Bit 7 -
* 0 = Pin is defaulted to LOW. If bit 0 is 0 then we assume the start up state is LOW, if bit 0 is 1 then we set pin LOW
* 1 = Pin is defaulted HIGH. If bit 0 is 0 then assume start up state is HIGH, if bit 0 is 1 then set pin HIGH
*
* Mostly people don't have to worry about any of this because the serial console takes care of these details for you.
*/
uint8_t mode;
uint8_t pin; //which pin we'll be using to either read a digital input or send one
uint32_t rxTxID; //which ID to use for reception and trasmission
uint8_t payload[8];
uint8_t length; //how many bytes to use for the message (TX) or how many to validate (RX)
boolean enabled; //true or false, is this special mode enabled or not?
};
struct SystemSettings
{
uint8_t eepromWPPin;
uint8_t CAN0EnablePin;
uint8_t CAN1EnablePin;
uint8_t SWCANMode0Pin;
uint8_t SWCANMode1Pin;
boolean useSD; //should we attempt to use the SDCard? (No logging possible otherwise)
boolean logToFile; //are we currently supposed to be logging to file?
uint8_t SDCardSelPin;
boolean SDCardInserted;
uint8_t LED_CANTX;
uint8_t LED_CANRX;
uint8_t LED_LOGGING;
boolean txToggle; //LED toggle values
boolean rxToggle;
boolean logToggle;
boolean lawicelMode;
boolean lawicelAutoPoll;
boolean lawicelTimestamping;
int lawicelPollCounter;
};
extern EEPROMSettings settings;
extern SystemSettings SysSettings;
extern DigitalCANToggleSettings digToggleSettings;
//buffer size for SDCard - Sending canbus data to the card. Still allocated even for GEVCU but unused in that case
//This is a large buffer but the sketch may as well use up a lot of RAM. It's there.
//This value is picked up by the SD card library and not directly used in the GVRET code.
#define BUF_SIZE 8192
//size to use for buffering writes to the USB bulk endpoint
//This is, however, directly used.
#define SER_BUFF_SIZE 4096
//maximum number of microseconds between flushes to the USB port.
//The host should be polling every 1ms or so and so this time should be a small multiple of that
#define SER_BUFF_FLUSH_INTERVAL 2000
#define CFG_BUILD_NUM 336
#define CFG_VERSION "GVRET alpha 2017-03-02"
#define EEPROM_ADDR 0
#define EEPROM_VER 0x15
#define CANDUE_EEPROM_WP_PIN 18
#define CANDUE_CAN0_EN_PIN 50
#define CANDUE_CAN1_EN_PIN 48
#define CANDUE_USE_SD 1
#define CANDUE_SDCARD_SEL 10
#define CANDUE_SWCAN_MODE0 46
#define CANDUE_SWCAN_MODE1 44
#define GEVCU_EEPROM_WP_PIN 19
#define GEVCU_CAN0_EN_PIN 255 //GEVCU has a different transceiver with no enable pin
#define GEVCU_CAN1_EN_PIN 255
#define GEVCU_USE_SD 0
#define GEVCU_SDCARD_SEL 10
#define GEVCU_SWCAN_MODE0 255
#define GEVCU_SWCAN_MODE1 255
#define BLINK_LED 73 //13 is L, 73 is TX, 72 is RX
#define NUM_ANALOG 4
#define NUM_DIGITAL 4
#define NUM_OUTPUT 8
//Number of times a frame would have to be sent or received to actually toggle the LED
//This number thus slows down the blinking quite a bit - Useful to make it easier to see
//what is going on based on the LEDs.
//Applies just to RX and TX leds
#define BLINK_SLOWNESS 32
#endif /* CONFIG_H_ */