Exemplo n.º 1
0
DRESULT disk_ioctl (
  BYTE pdrv,    /* Physical drive nmuber (0..) */
  BYTE cmd,     /* Control code */
  void *buff    /* Buffer to send/receive control data */
)
{
  switch (pdrv) {
#if HAL_USE_MMC_SPI
  case MMC:
    switch (cmd) {
    case CTRL_SYNC:
        return RES_OK;
    case GET_SECTOR_SIZE:
        *((WORD *)buff) = MMCSD_BLOCK_SIZE;
        return RES_OK;
#if _USE_ERASE
    case CTRL_ERASE_SECTOR:
        mmcErase(&MMCD1, *((DWORD *)buff), *((DWORD *)buff + 1));
        return RES_OK;
#endif
    default:
        return RES_PARERR;
    }
#else
  case SDC:
    switch (cmd) {
    case CTRL_SYNC:
        return RES_OK;
    case GET_SECTOR_COUNT:
        *((DWORD *)buff) = mmcsdGetCardCapacity(&SDCD1);
        return RES_OK;
    case GET_SECTOR_SIZE:
        *((WORD *)buff) = MMCSD_BLOCK_SIZE;
        return RES_OK;
    case GET_BLOCK_SIZE:
        *((DWORD *)buff) = 256; /* 512b blocks in one erase block */
        return RES_OK;
#if _USE_ERASE
    case CTRL_ERASE_SECTOR:
        sdcErase(&SDCD1, *((DWORD *)buff), *((DWORD *)buff + 1));
        return RES_OK;
#endif
    default:
        return RES_PARERR;
    }
#endif
  }
  return RES_PARERR;
}
Exemplo n.º 2
0
int eraseImg_Cmd(char **argv,unsigned short argc){
    int ret;
    //erase data from SD card
    ret=mmcErase(IMG_ADDR_START,IMG_ADDR_END);
    //check return value
    if(ret==MMC_SUCCESS){
        //clear imager variables
        writePic = 0;
        picNum=0;
        //print message
        printf("Picture data erased\r\n");
        //refresh status info
        status_refresh();
    }else{
        //print error
        printf("Error erase failed %s\r\n",SD_error_str(ret));
    }
    return 0;
}
Exemplo n.º 3
0
int mmc_eraseCmd(char **argv, unsigned short argc){
  unsigned long start,end;
  int resp;
  //check arguments
  if(argc!=2){
    printf("Error : %s requiors two arguments\r\n",argv[0]);
    return 1;
  }
  errno=0;
  start=strtoul(argv[1],NULL,0);
  end=strtoul(argv[2],NULL,0);
  if(errno){
    printf("Error : could not parse arguments\r\n");
    return 2;
  }
  printf("Erasing from %lu to %lu\r\n",start,end);
  //send erase command
  resp=mmcErase(start,end);
  printf("%s\r\n",SD_error_str(resp));
  return 0;
}
Exemplo n.º 4
0
DRESULT disk_ioctl (
  BYTE pdrv,    /* Physical drive nmuber (0..) */
  BYTE cmd,     /* Control code */
  void *buff    /* Buffer to send/receive control data */
)
{
  switch (pdrv) {
#if HAL_USE_MMC_SPI
  case MMC:
    switch (cmd) {
    case CTRL_SYNC:
        return RES_OK;
    case GET_SECTOR_SIZE:
        *((WORD *)buff) = MMCSD_BLOCK_SIZE;
        return RES_OK;
    case MMC_GET_TYPE:
        *((BYTE *)buff) = SDCD1.cardmode;
        return RES_OK;
    case MMC_GET_CSD:
        memcpy(buff, &SDCD1.csd, sizeof(SDCD1.csd));
        return RES_OK;
#if _USE_ERASE
    case CTRL_ERASE_SECTOR:
        mmcErase(&MMCD1, *((DWORD *)buff), *((DWORD *)buff + 1));
        return RES_OK;
#endif
    default:
        return RES_PARERR;
    }
#else
  case SDC:
    switch (cmd) {
    case CTRL_SYNC:
        return RES_OK;
    case GET_SECTOR_COUNT:
        *((DWORD *)buff) = mmcsdGetCardCapacity(&SDCD1);
        return RES_OK;
    case GET_SECTOR_SIZE:
        *((WORD *)buff) = MMCSD_BLOCK_SIZE;
        return RES_OK;
    case GET_BLOCK_SIZE:
        *((DWORD *)buff) = 1; /* Unknown, TODO: implement? */
        return RES_OK;
    case MMC_GET_TYPE:
        *((BYTE *)buff) = SDCD1.cardmode;
        return RES_OK;
    case MMC_GET_CSD:
        memcpy(buff, &SDCD1.csd, sizeof(SDCD1.csd));
        return RES_OK;
#if _USE_ERASE
    case CTRL_ERASE_SECTOR:
        sdcErase(&SDCD1, *((DWORD *)buff), *((DWORD *)buff + 1));
        return RES_OK;
#endif
    default:
        return RES_PARERR;
    }
#endif
  }
  return RES_PARERR;
}
Exemplo n.º 5
0
/**
 * Kill all data in storage.
 * @param[in] bsp   pointer to storage device
 */
void bnapStorageWipe(BnapStorage_t *bsp){
  chDbgCheck(bsp != NULL, "");
  mmcErase(bsp->mmcp, 0, bsp->mmcp->capacity - 1);
  bsp->tip = 0;
}