Skip to content

Commit 875653a

Browse files
committed
some very minor cleanup beginnings
1 parent d5c99ad commit 875653a

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

Telemetry-Main/main.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "SDBlockDevice.h"
1111

1212
#define ENABLE_RADIO false
13-
#define ENABLE_SD false
13+
#define ENABLE_SD true
1414
#define ENABLE_DASH true
1515

1616
// #define TICKS_PER_SECOND 1000
@@ -31,18 +31,24 @@
3131
//
3232
// static TelemetrySystemState state = {ENABLE_RADIO, ENABLE_SD, ENABLE_DASH};
3333

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+
3839
auto mbed_can = CAN(PB_8, PB_9, 500000);
3940
auto can = MbedCAN(mbed_can);
4041
auto vsm = VehicleStateManager(&can, PC_5, PC_1, PC_0);
4142

42-
// For SD card
4343
// SDBlockDevice - lowest-level interfaces with the SD card.
4444
// 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+
};
4652
// FATFileSystem - Creates a FAT filesystem on the SDBlockDevice.
4753
// "sd" is the name of the filesystem; i.e. filepaths are /sd/...
4854
FATFileSystem fs{"sd"};
@@ -146,7 +152,7 @@ void update_dash() {
146152
static_cast<float>(vsm_state.pdbPowerA.GLV_VOLTAGE),
147153
static_cast<bool>(vsm_state.etcStatus.RTD),
148154
n
149-
);
155+
);
150156
}
151157

152158
void error_quit(std::string msg) {
@@ -173,7 +179,7 @@ int main() {
173179
// }
174180
// }, 1000ms / TICKS_PER_SECOND);
175181

176-
182+
177183
// Initializing Dash
178184
if (ENABLE_DASH) {
179185
eve.init(EvePresets::CFA800480E3);
@@ -191,7 +197,7 @@ int main() {
191197
if (error) {
192198
// Reformat if we can't mount the filesystem.
193199
// This should only happen on the first boot
194-
printf("No filesystem found, formatting...\n");
200+
printf("No filesystem found, attempting to reformat...\n");
195201
error = fs.reformat(&sd);
196202
if (error) error_quit("Error: could not reformat SD card! Is the SD card plugged in?\n");
197203
}
@@ -213,7 +219,7 @@ int main() {
213219
} else {
214220
error_quit("Couldn't open fsdaq directory!\n");
215221
}
216-
222+
217223
int max_num = 0;
218224
for (auto it = existing_filenames.begin(); it != existing_filenames.end(); ++it) {
219225
max_num = std::max(max_num, std::stoi(*it));
@@ -297,3 +303,4 @@ int main() {
297303
// printf("CAN!\n");
298304
// }
299305
}
306+

Telemetry-SD-Card/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
3535
if (error) {
3636
// Reformat if we can't mount the filesystem.
3737
// This should only happen on the first boot
38-
printf("No filesystem found, formatting...\n");
38+
printf("No filesystem found, attempting to reformat...\n");
3939
error = fs.reformat(&sd);
4040
if (error) error_quit("Error: could not reformat SD card! Is the SD card plugged in?\n");
4141
}

0 commit comments

Comments
 (0)