format

SDCard formatting - ERASES ALL CONTENTS of the SDCard! To activate, turn on confirm1 and click confirm2.
Author: Johannes Taelman
License: BSD
Github: util/format.axo

Inlets

None

Outlets

None

Parameters

bool32.tgl confirm1

bool32.mom confirm2

Displays

bool32 busy

bool32 succeeded

bool32 failed

Declaration
FRESULT fs_error = FR_OK;
bool pconfirm;
bool busy;
bool ready;

msg_t ThreadX2() {
  busy = 1;
  fs_error = f_mkfs(0, 0, 0);
  if (fs_error != FR_OK)
    report_fatfs_error(fs_error, "");
  sdcard_unmount();
  sdcard_attemptMountIfUnmounted();
  ready = 1;
  chThdExit((msg_t)0);
}

static msg_t ThreadX(void *arg) { ((attr_parent *)arg)->ThreadX2(); }

WORKING_AREA(waThreadX, 1024);
Thread *pThd = 0;
Control Rate
if (param_confirm1 && param_confirm2 && !pconfirm) {
  pconfirm = 1;
  pThd = chThdCreateStatic(waThreadX, sizeof(waThreadX), NORMALPRIO, ThreadX,
                           (void *)this);
} else if (!param_confirm2) {
  pconfirm = 0;
}

if (ready) {
  busy = 0;
  pThd = 0;
}

disp_busy = busy;
disp_succeeded = ready && (fs_error == FR_OK);
disp_failed = ready && (fs_error != FR_OK);

Privacy

© 2024 Zrna Research