Skip to content

Commit f4ed0c3

Browse files
committed
save - trying more things, still no worky
1 parent b5cdd5e commit f4ed0c3

File tree

6 files changed

+35
-135
lines changed

6 files changed

+35
-135
lines changed

Telemetry-SD-Card/SDFileSystem/SDFileSystem.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@
120120
#define SD_DBG 0
121121

122122
SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) :
123-
FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs), _is_initialized(0) {
124-
_cs = 1;
123+
FATFileSystem(name), _spi(mosi, miso, sclk, cs, use_gpio_ssel), _is_initialized(0) {
124+
_spi.deselect();
125+
// _spi.lock();
125126

126127
// Set default to 100kHz for initialisation and 1MHz for data transfer
127128
_init_sck = 100000;
@@ -153,7 +154,7 @@ int SDFileSystem::initialise_card() {
153154

154155
_spi.set_dma_usage(DMAUsage::DMA_USAGE_OPPORTUNISTIC);
155156

156-
_cs = 1;
157+
_spi.deselect();
157158
for (int i = 0; i < 16; i++) {
158159
_spi.write(0xFF);
159160
}
@@ -280,7 +281,7 @@ uint32_t SDFileSystem::disk_sectors() { return _sectors; }
280281

281282
// PRIVATE FUNCTIONS
282283
int SDFileSystem::_cmd(int cmd, int arg) {
283-
_cs = 0;
284+
_spi.select();
284285

285286
// send a command
286287
_spi.write(0x40 | cmd);
@@ -294,17 +295,17 @@ int SDFileSystem::_cmd(int cmd, int arg) {
294295
for (int i = 0; i < SD_COMMAND_TIMEOUT; i++) {
295296
int response = _spi.write(0xFF);
296297
if (!(response & 0x80)) {
297-
_cs = 1;
298+
_spi.deselect();
298299
_spi.write(0xFF);
299300
return response;
300301
}
301302
}
302-
_cs = 1;
303+
_spi.deselect();
303304
_spi.write(0xFF);
304305
return -1; // timeout
305306
}
306307
int SDFileSystem::_cmdx(int cmd, int arg) {
307-
_cs = 0;
308+
_spi.select();
308309

309310
// send a command
310311
_spi.write(0x40 | cmd);
@@ -321,14 +322,14 @@ int SDFileSystem::_cmdx(int cmd, int arg) {
321322
return response;
322323
}
323324
}
324-
_cs = 1;
325+
_spi.deselect();
325326
_spi.write(0xFF);
326327
return -1; // timeout
327328
}
328329

329330

330331
int SDFileSystem::_cmd58() {
331-
_cs = 0;
332+
_spi.select();
332333
int arg = 0;
333334

334335
// send a command
@@ -347,18 +348,18 @@ int SDFileSystem::_cmd58() {
347348
ocr |= _spi.write(0xFF) << 16;
348349
ocr |= _spi.write(0xFF) << 8;
349350
ocr |= _spi.write(0xFF) << 0;
350-
_cs = 1;
351+
_spi.deselect();
351352
_spi.write(0xFF);
352353
return response;
353354
}
354355
}
355-
_cs = 1;
356+
_spi.deselect();
356357
_spi.write(0xFF);
357358
return -1; // timeout
358359
}
359360

360361
int SDFileSystem::_cmd8() {
361-
_cs = 0;
362+
_spi.select();
362363

363364
// send a command
364365
_spi.write(0x40 | 8); // CMD8
@@ -376,18 +377,18 @@ int SDFileSystem::_cmd8() {
376377
for (int j = 1; j < 5; j++) {
377378
response[i] = _spi.write(0xFF);
378379
}
379-
_cs = 1;
380+
_spi.deselect();
380381
_spi.write(0xFF);
381382
return response[0];
382383
}
383384
}
384-
_cs = 1;
385+
_spi.deselect();
385386
_spi.write(0xFF);
386387
return -1; // timeout
387388
}
388389

389390
int SDFileSystem::_read(uint8_t *buffer, uint32_t length) {
390-
_cs = 0;
391+
_spi.select();
391392

392393
// read until start byte (0xFF)
393394
while (_spi.write(0xFF) != 0xFE);
@@ -399,13 +400,13 @@ int SDFileSystem::_read(uint8_t *buffer, uint32_t length) {
399400
_spi.write(0xFF); // checksum
400401
_spi.write(0xFF);
401402

402-
_cs = 1;
403+
_spi.deselect();
403404
_spi.write(0xFF);
404405
return 0;
405406
}
406407

407408
int SDFileSystem::_write(const uint8_t*buffer, uint32_t length) {
408-
_cs = 0;
409+
_spi.select();
409410

410411
// indicate start of block
411412
_spi.write(0xFE);
@@ -421,15 +422,15 @@ int SDFileSystem::_write(const uint8_t*buffer, uint32_t length) {
421422

422423
// check the response token
423424
if ((_spi.write(0xFF) & 0x1F) != 0x05) {
424-
_cs = 1;
425+
_spi.deselect();
425426
_spi.write(0xFF);
426427
return 1;
427428
}
428429

429430
// wait for write to finish
430431
while (_spi.write(0xFF) == 0);
431432

432-
_cs = 1;
433+
_spi.deselect();
433434
_spi.write(0xFF);
434435
return 0;
435436
}

Telemetry-SD-Card/SDFileSystem/SDFileSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class SDFileSystem : public FATFileSystem {
8181
uint32_t _transfer_sck;
8282

8383
SPI _spi;
84-
DigitalOut _cs;
84+
// DigitalOut _cs;
8585
int cdv;
8686
int _is_initialized;
8787
};
8888

89-
#endif
89+
#endif

Telemetry-SD-Card/dbc_to_cpp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ def generate_nanoarrow_code(signal_to_fsdaq_datatype: dict[str, str], rows: int
144144
# v = v.removesuffix("),)")
145145
# print("{:33s} {}".format(k, v))
146146

147-
generate_nanoarrow_code({k: signal_to_datatype[k] for k in list(signal_to_datatype)}, 8)
147+
n = 120
148+
generate_nanoarrow_code({k: signal_to_datatype[k] for k in list(signal_to_datatype)[:n]}, 8)
148149

149150

150151

0 commit comments

Comments
 (0)