Beispiel #1
0
Ctrl_status ram_2_memory(U8 lun, U32 addr, const void *ram)
{
  Ctrl_status status;
#if MAX_LUN==0
  UNUSED(lun);
#endif

  if (!Ctrl_access_lock()) return CTRL_FAIL;

  memory_start_write_action(1);
  status =
#if MAX_LUN
           (lun < MAX_LUN) ? lun_desc[lun].ram_2_mem(addr, ram) :
#endif
#if LUN_USB == ENABLE
                             Lun_usb_ram_2_mem(addr, ram);
#else
                             CTRL_FAIL;
#endif
  memory_stop_write_action();

  Ctrl_access_unlock();

  return status;
}
//! This fonction trabsfer a data from ram to memory
//!
//! @param lun          Logical unit number
//! @param addr         Sector address to start write (sector = 512B)
//! @param ram          Adresse of ram buffer (only xdata)
//!
//! @return TRUE  -> The memory is removal
//!
Ctrl_status    ram_2_memory( U8 lun , const U32 _MEM_TYPE_SLOW_ *addr , U8 _MEM_TYPE_SLOW_ * ram )
{
   Ctrl_status status;

   switch( lun )
   {
#     if (LUN_0 == ENABLE)
      case LUN_ID_0:
         status = Lun_0_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_0_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_1 == ENABLE)
      case LUN_ID_1:
         status = Lun_1_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_1_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_2 == ENABLE)
      case LUN_ID_2:
         status = Lun_2_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_2_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_3 == ENABLE)
      case LUN_ID_3:
         status = Lun_3_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_3_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_4 == ENABLE)
      case LUN_ID_4:
         status = Lun_4_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_4_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_5 == ENABLE)
      case LUN_ID_5:
         status = Lun_5_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_5_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_6 == ENABLE)
      case LUN_ID_6:
         status = Lun_6_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_6_ram_2_mem_write();
         }
         break;
#     endif
 #     if (LUN_7 == ENABLE)
      case LUN_ID_7:
         status = Lun_7_ram_2_mem(*addr , ram);
         if (CTRL_GOOD == status)
         {
            status = Lun_7_ram_2_mem_write();
         }
         break;
#     endif
#     if (LUN_USB == ENABLE)
      default:
         return  Lun_usb_ram_2_mem(*addr , ram);
         break;
#     endif
   }
   return   status;
}