10
10
#include " SDBlockDevice.h"
11
11
12
12
#define ENABLE_RADIO false
13
- #define ENABLE_SD false
13
+ #define ENABLE_SD true
14
14
#define ENABLE_DASH true
15
15
16
16
// #define TICKS_PER_SECOND 1000
31
31
//
32
32
// static TelemetrySystemState state = {ENABLE_RADIO, ENABLE_SD, ENABLE_DASH};
33
33
34
- DigitalIn spi_attn (PA_9);
35
- DigitalOut cs (PC_8);
36
- SPI spi (PA_7, PA_6, PA_5);
37
- XBeeRadio radio (spi, cs, spi_attn);
34
+ DigitalIn xbee_spi_attn (PA_9);
35
+ DigitalOut xbee_spi_cs (PC_8);
36
+ SPI xbee_spi (PA_7, PA_6, PA_5);
37
+ XBeeRadio radio (xbee_spi, xbee_spi_cs, xbee_spi_attn);
38
+
38
39
auto mbed_can = CAN(PB_8, PB_9, 500000 );
39
40
auto can = MbedCAN(mbed_can);
40
41
auto vsm = VehicleStateManager(&can, PC_5, PC_1, PC_0);
41
42
42
- // For SD card
43
43
// SDBlockDevice - lowest-level interfaces with the SD card.
44
44
// Pin configurations and transfer speeds are set in mbed_app.json.
45
- SDBlockDevice sd{ PB_15, PB_14, PB_13, PB_12, 25000000 };
45
+ SDBlockDevice sd{
46
+ MBED_CONF_SD_SPI_MOSI,
47
+ MBED_CONF_SD_SPI_MISO,
48
+ MBED_CONF_SD_SPI_CLK,
49
+ MBED_CONF_SD_SPI_CS,
50
+ MBED_CONF_SD_TRX_FREQUENCY,
51
+ };
46
52
// FATFileSystem - Creates a FAT filesystem on the SDBlockDevice.
47
53
// "sd" is the name of the filesystem; i.e. filepaths are /sd/...
48
54
FATFileSystem fs{" sd" };
@@ -146,7 +152,7 @@ void update_dash() {
146
152
static_cast <float >(vsm_state.pdbPowerA .GLV_VOLTAGE ),
147
153
static_cast <bool >(vsm_state.etcStatus .RTD ),
148
154
n
149
- );
155
+ );
150
156
}
151
157
152
158
void error_quit (std::string msg) {
@@ -173,7 +179,7 @@ int main() {
173
179
// }
174
180
// }, 1000ms / TICKS_PER_SECOND);
175
181
176
-
182
+
177
183
// Initializing Dash
178
184
if (ENABLE_DASH) {
179
185
eve.init (EvePresets::CFA800480E3);
@@ -191,7 +197,7 @@ int main() {
191
197
if (error) {
192
198
// Reformat if we can't mount the filesystem.
193
199
// This should only happen on the first boot
194
- printf (" No filesystem found, formatting ...\n " );
200
+ printf (" No filesystem found, attempting to reformat ...\n " );
195
201
error = fs.reformat (&sd);
196
202
if (error) error_quit (" Error: could not reformat SD card! Is the SD card plugged in?\n " );
197
203
}
@@ -213,7 +219,7 @@ int main() {
213
219
} else {
214
220
error_quit (" Couldn't open fsdaq directory!\n " );
215
221
}
216
-
222
+
217
223
int max_num = 0 ;
218
224
for (auto it = existing_filenames.begin (); it != existing_filenames.end (); ++it) {
219
225
max_num = std::max (max_num, std::stoi (*it));
@@ -297,3 +303,4 @@ int main() {
297
303
// printf("CAN!\n");
298
304
// }
299
305
}
306
+
0 commit comments