示例#1
0
//! This function initializes the memory for a write operation
//! from ram buffer to SD/MMC (1 sector)
//!
//!         DATA FLOW is: RAM => SD/MMC
//!
//! (sector = 512B)
//! @param addr         Sector address to write
//! @param ram          Ram buffer pointer
//!
//! @return                Ctrl_status
//!   It is ready      ->    CTRL_GOOD
//!   An error occurs  ->    CTRL_FAIL
//!
Ctrl_status    sd_mmc_spi_ram_2_mem(uint32_t addr, const void *ram)
{
   Sd_mmc_spi_access_signal_on();
   sd_mmc_spi_check_presence();

   if (!sd_mmc_spi_init_done)
   {
      sd_mmc_spi_mem_init();
   }

   if (sd_mmc_spi_init_done)
   {
     sd_mmc_spi_write_open(addr);
     if (!sd_mmc_spi_write_sector_from_ram(ram))
     {
       sd_mmc_spi_write_close();
       Sd_mmc_spi_access_signal_off();
       return CTRL_NO_PRESENT;
     }
     sd_mmc_spi_write_close();
     Sd_mmc_spi_access_signal_off();
     return CTRL_GOOD;
   }
   Sd_mmc_spi_access_signal_off();

   return CTRL_NO_PRESENT;
}
示例#2
0
Ctrl_status sd_mmc_spi_mem_2_ram(uint32_t addr, void *ram)
{
   Sd_mmc_spi_access_signal_on();
   sd_mmc_spi_check_presence();

   if (!sd_mmc_spi_init_done)
   {
      sd_mmc_spi_mem_init();
   }

   if (!sd_mmc_spi_init_done)
     return CTRL_NO_PRESENT;

   if( !sd_mmc_spi_read_open(addr) )
     goto sd_mmc_spi_mem_2_ram_fail;

   if( !sd_mmc_spi_read_sector_to_ram(ram))
     goto sd_mmc_spi_mem_2_ram_fail;

   if( !sd_mmc_spi_read_close() )
     goto sd_mmc_spi_mem_2_ram_fail;

   Sd_mmc_spi_access_signal_off();
   return CTRL_GOOD;

sd_mmc_spi_mem_2_ram_fail:
   Sd_mmc_spi_access_signal_off();
   return CTRL_FAIL;
}
Ctrl_status sd_mmc_spi_mem_2_ram(U32 addr, void *ram)
{
   Sd_mmc_spi_access_signal_on();
   sd_mmc_spi_check_presence();

   if (sd_mmc_spi_init_done == FALSE)
   {
      sd_mmc_spi_mem_init();
   }

   if (sd_mmc_spi_init_done == TRUE)
   {
     sd_mmc_spi_read_open(addr);
     if (KO == sd_mmc_spi_read_sector_to_ram(ram))
     {
       sd_mmc_spi_write_close();
       Sd_mmc_spi_access_signal_off();
       return CTRL_NO_PRESENT;
     }
     sd_mmc_spi_read_close();
     Sd_mmc_spi_access_signal_off();
     return CTRL_GOOD;
   }
   Sd_mmc_spi_access_signal_off();

   return CTRL_NO_PRESENT;
}
/**
 * \brief Checks the presence of the SD/MMC card
 *
 * This function will simply test the output of the function
 * \ref sd_mmc_spi_check_presence and returns an error in case of failure.
 *
 * \param test Current test case.
 */
static void run_check_presence_test(const struct test_case *test)
{
	bool status;

	status = sd_mmc_spi_check_presence();
	test_assert_true(test, status == true, "SD/MMC card not present");
}
示例#5
0
static ai_device_status_t ai_sd_mmc_get_device_status(ai_async_status_t *cmd_ai_status)
{
  *cmd_ai_status = CMD_DONE;

#if defined(SD_MMC_CARD_DETECT_PIN)
  if (gpio_get_pin_value(SD_MMC_CARD_DETECT_PIN))
#endif
#if defined(SUPPORT_SD_MMC_MCI) && SUPPORT_SD_MMC_MCI == true
  if (sd_mmc_mci_mem_check(SD_SLOT))
  {
    volatile uint32_t card_size;
    sd_mmc_mci_read_capacity(SD_SLOT, (uint32_t *) &card_size);
    return AI_DEVICE_STATUS_CONNECTED;
  }
#else
  if (sd_mmc_spi_check_presence() == true)
    return AI_DEVICE_STATUS_CONNECTED;
#endif

  return AI_DEVICE_STATUS_NOT_PRESENT;
}