示例#1
0
/*******************************************************************************
* Function Name  : MAL_Write
* Description    : Write sectors
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t MAL_Write(uint8_t lun, uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length)
{

  switch (lun)
  {
    case 0:
#ifdef USE_STM3210E_EVAL
      Status = SD_WriteBlock(Memory_Offset, Writebuff, Transfer_Length);
      if ( Status != SD_OK )
      {
        return MAL_FAIL;
      }      
#else
      MSD_WriteBlock((uint8_t*)Writebuff, Memory_Offset, Transfer_Length);
#endif
      break;
#ifdef USE_FSMC_NAND
      case 1:
      NAND_Write(Memory_Offset, Writebuff, Transfer_Length);
      break;
#endif
    default:
      return MAL_FAIL;
  }
  return MAL_OK;
}
示例#2
0
/*******************************************************************************
* Function Name  : MAL_Write
* Description    : Write sectors
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t MAL_Write(uint8_t lun, uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length)
{

  switch (lun)
  {
    case 0:
    Status = SD_WriteMultiBlocks((uint8_t*)Writebuff, Memory_Offset, Transfer_Length,1);
#if defined(USE_STM3210E_EVAL) || defined(USE_STM32L152D_EVAL)
    Status = SD_WaitWriteOperation();  
    while(SD_GetStatus() != SD_TRANSFER_OK);
      if ( Status != SD_OK )
      {
        return MAL_FAIL;
      }      
#endif /* USE_STM3210E_EVAL ||USE_STM32L152D_EVAL*/      
      break;
#ifdef USE_STM3210E_EVAL
    case 1:
      NAND_Write(Memory_Offset, Writebuff, Transfer_Length);
      break;
#endif /* USE_STM3210E_EVAL */  
    default:
      return MAL_FAIL;
  }
  return MAL_OK;
}
示例#3
0
/*******************************************************************************
* Function Name  : MAL_Write
* Description    : Write sectors
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t MAL_Write(uint8_t lun, uint32_t Memory_Offset, volatile uint8_t * Writebuff, uint32_t Transfer_Length)
{
  switch (lun)
  {
    case 0:/* Physical drive number (0) */
      while(Sd_Spi_Called_From_USB_MSC){;}
      Status = disk_write (0, (const BYTE *)Writebuff, Memory_Offset/512, Transfer_Length/512);//assume integer sectors - 512 bytes
      //Status = SD_WriteBlock((uint8_t*)Writebuff, Memory_Offset, Transfer_Length);
#ifdef USE_STM3210E_EVAL
      if ( Status != SD_OK )
      {
        return MAL_FAIL;
      }      
#endif /* USE_STM3210E_EVAL */      
      break;
#ifdef USE_STM3210E_EVAL
    case 1:
      NAND_Write(Memory_Offset, Writebuff, Transfer_Length);
      break;
#endif /* USE_STM3210E_EVAL */  
    default:
      return MAL_FAIL;
  }
  return MAL_OK;
}
示例#4
0
void NAND_Fatwritesects(uint32_t startsector,uint8_t* buf,uint32_t cnt)
{
   uint32_t j;

	 for(j=0;j<cnt;j++){
   	 	 NAND_Write((startsector*2048)+(j*2048), (uint32_t *)(buf+j*2048), 2048);
	 }
	 printf("\r\n startsector(%d)  cnt(%d)\r\n",startsector,cnt);
}
示例#5
0
DRESULT disk_write (
	BYTE drv,			/* Physical drive nmuber (0..) */
	const BYTE *buff,	/* Data to be written */
	DWORD sector,		/* Sector address (LBA) */
	BYTE count			/* Number of sectors to write (1..255) */
)
{
	NAND_Write((uint32_t)sector << 9, (uint32_t *)buff, (uint16_t)count << 9);



return 	RES_OK;
}
示例#6
0
/*******************************************************************************
* Function Name  : MAL_Write
* Description    : Write sectors
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t MAL_Write(uint8_t lun, uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length)
{

  switch (lun)
  {
    case 0:
      break;
    case 1:
      NAND_Write(Memory_Offset, Writebuff, Transfer_Length);
      break;
    default:
      return MAL_FAIL;
  }
  return MAL_OK;
}
示例#7
0
/*******************************************************************************
* Function Name  : MAL_Write
* Description    : Write sectors
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
uint16_t MAL_Write(uint8_t lun, uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length) {
  switch (lun) {
    case 0:
      Status = SD_WriteBlock(Memory_Offset, Writebuff, Transfer_Length);
      if ( Status != SD_OK )  return MAL_FAIL;
      break;
    case 1:
      NAND_Write(Memory_Offset, Writebuff, Transfer_Length);
      printf("Transfer_Length_w = %d\r\n", Memory_Offset);
      break;
    default:
      return MAL_FAIL;
  }
  
  return MAL_OK;
}