示例#1
0
Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) {
  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
    return CTRL_NO_PRESENT;

  #ifdef DEBUG_MMC
    char buffer[80];
    sprintf_P(buffer, PSTR("SDWR: %d @ 0x%08x\n"), nb_sector, addr);
    SERIAL_ECHO_P(0, buffer);
  #endif

  if (!card.getSd2Card().writeStart(addr, nb_sector))
    return CTRL_FAIL;

  // For each specified sector
  while (nb_sector--) {

    // USB -> RAM
    if (!udi_msc_trans_block(false, sector_buf, SD_MMC_BLOCK_SIZE, NULL)) {
      card.getSd2Card().writeStop();
      return CTRL_FAIL;
    }

    // Write a sector
    card.getSd2Card().writeData(sector_buf);
  }

  // Stop writing
  card.getSd2Card().writeStop();

  // Done
  return CTRL_GOOD;
}
/**
 * M32: Select file and start SD Print
 *
 * Examples:
 *
 *    M32 !PATH/TO/FILE.GCO#      ; Start FILE.GCO
 *    M32 P !PATH/TO/FILE.GCO#    ; Start FILE.GCO as a procedure
 *    M32 S60 !PATH/TO/FILE.GCO#  ; Start FILE.GCO at byte 60
 *
 */
void GcodeSuite::M32() {
  if (IS_SD_PRINTING()) planner.synchronize();

  if (card.isDetected()) {
    const bool call_procedure = parser.boolval('P');

    card.openFile(parser.string_arg, true, call_procedure);

    if (parser.seenval('S')) card.setIndex(parser.value_long());

    card.startFileprint();

    // Procedure calls count as normal print time.
    if (!call_procedure) print_job_timer.start();
  }
}
/**
 * M25: Pause SD Print
 */
void GcodeSuite::M25() {

  // Set initial pause flag to prevent more commands from landing in the queue while we try to pause
  #if ENABLED(SDSUPPORT)
    if (IS_SD_PRINTING()) card.pauseSDPrint();
  #endif

  #if ENABLED(PARK_HEAD_ON_PAUSE)
    M125();
  #else
    print_job_timer.pause();
    ui.reset_status();

    #ifdef ACTION_ON_PAUSE
      host_action_pause();
    #endif
  #endif
}
/**
 * M524: Abort the current SD print job (started with M24)
 */
void GcodeSuite::M524() {
  if (IS_SD_PRINTING()) card.flag.abort_sd_printing = true;
}
/**
 * The enabled state was changed:
 *  - Enabled: Purge the job recovery file
 *  - Disabled: Write the job recovery file
 */
void PrintJobRecovery::changed() {
  if (!enabled)
    purge();
  else if (IS_SD_PRINTING())
    save(true);
}
示例#6
0
bool sd_mmc_spi_removal(void) {
  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
    return true;
  return false;
}
示例#7
0
// NOTE: This function is defined as returning the address of the last block
// in the card, which is cardSize() - 1
Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
    return CTRL_NO_PRESENT;
  *nb_sector = card.getSd2Card().cardSize() - 1;
  return CTRL_GOOD;
}
示例#8
0
Ctrl_status sd_mmc_spi_test_unit_ready(void) {
  if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isDetected())
    return CTRL_NO_PRESENT;
  return CTRL_GOOD;
}