⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mem_task.c

📁 漫步者S4.1音箱线控程序 89C52+1602液晶 附带音箱接口说明
💻 C
📖 第 1 页 / 共 2 页
字号:
      #if (MEM_CARD_TYPE != CARD_NONE)
        if (Card_check_presence() == OK)   /* if we detect a medium */
          mem_state = MEM_CARD_INIT;  /* init this medium */
      #endif
      break;
    }

  }
}


/*F**************************************************************************
* NAME: mem_status
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   memory status:  MEM_BUSY:   install in progress
*                   MEM_READY:  install done
*                   MEM_FORMAT: install done but memory not formated
*----------------------------------------------------------------------------
* PURPOSE: 
*   Return memory status
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Byte mem_status (void)
{
  #if (MEM_CARD_TYPE != CARD_NONE)
    if ((gl_memory == MEM_CARD) && (mem_state != MEM_CARD_INIT) && (mem_state != MEM_CHIP_INIT))
    {  /* don't check card presence when mem_state = CARD_INIT. This can modify init sequence */
      if (Card_check_presence() == KO) /* if no card present */
      {
        return MEM_NO_CARD;
      }
    }

    if (mem_state == MEM_CARD_NO_CARD)  /* else if we detect a new medium */
      return MEM_BUSY;
  #endif

  if ((mem_state == MEM_CHIP_IDLE) ||
      (mem_state == MEM_CARD_IDLE))
  {
    return (MEM_READY);
  }
  if ((mem_state == MEM_CHIP_ERR_FMT) ||
      (mem_state == MEM_CARD_ERR_FMT))
  {
    return (MEM_FORMAT);
  }
  else
  {
    return (MEM_BUSY);
  }
}


/*F**************************************************************************
* NAME: mem_check_card
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   OK: card present or on-board memory
*   KO: card not present
*----------------------------------------------------------------------------
* PURPOSE: 
*   Start card status checking
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit mem_check_card (void)
{
  #if (MEM_CARD_TYPE != CARD_NONE)
    switch (mem_state)
    {
      case MEM_CARD_IDLE:
      case MEM_CARD_ERR_FMT:
          #if CARD_SOCKET_NB == 1
            if (Card_check_presence() == KO)
              mem_state = MEM_CARD_NO_CARD;
          #endif
      case MEM_CARD_NO_CARD:
      {
        return (Card_check_presence());
      }
      default:
      {
        return OK;
      }
    }
  #else
    return OK;
  #endif
}


/*F**************************************************************************
* NAME: mem_card_select
*----------------------------------------------------------------------------
* PARAMS:
*   force:  - TRUE:  continue selecting MMC1 in case of error
*           - FALSE: select next device in case of error
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Mass storage memory selection
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   Call from mass storage routines:
*     - when Test_Unit returns not ready
*     - when exiting download mode for mounting new FAT
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void mem_card_select (bit force)
{
  #if (MEM_CARD_TYPE != CARD_NONE)

    mem_force_mmc = force;
    mem_state = MEM_CARD_INIT;
    #if CARD_SOCKET_NB == 2
      if (Card_get_socket() == MEM_CARD_2)
      {
        Card_select_next();   
      }
    #endif
  #else
    if (force); /* avoid warning message */
  #endif
}


/*F**************************************************************************
* NAME: mem_select_next
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Select next on-board or card memory
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void mem_select_next (void)
{
  switch (mem_state)
  {
    case MEM_CHIP_IDLE:
    case MEM_CHIP_ERR_FMT:
    {
      #if MEM_CARD_TYPE != CARD_NONE
        mem_state = MEM_CARD_INIT;
      #endif
      break;
    }
    case MEM_CARD_INIT:
    case MEM_CARD_IDLE:
    case MEM_CARD_ERR_FMT:
    {
      #if (MEM_CARD_TYPE != CARD_NONE)

        #if CARD_SOCKET_NB == 2
          if (Card_get_socket() == MEM_CARD_2)
          {
            #if MEM_CHIP_TYPE != CHIP_NONE
              mem_state = MEM_CHIP_INIT;
            #else
              mem_state = MEM_CARD_INIT;
            #endif
          }
          else
          {
            mem_state = MEM_CARD_INIT;
          }
          Card_select_next();                  /* select next card source */          
          break;
        #else
            #if MEM_CHIP_TYPE != CHIP_NONE
              mem_state = MEM_CHIP_INIT;
            #endif
          break;
        #endif
      #endif
    }
  }
}


/*F**************************************************************************
* NAME: mem_select_format
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   File system mount status
*----------------------------------------------------------------------------
* PURPOSE:
*   Re-mount memory after format or mass storage update 
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit mem_select_format (void)
{
  gl_mem_tick = MEM_WRITE_TIME;

  switch (mem_state)
  {
    case MEM_CHIP_ERR_FMT:
    case MEM_CHIP_IDLE:
    {
      #if (MEM_CHIP_TYPE != CHIP_NONE)
        while (gl_mem_tick != MEM_TIME_OUT)
        {
          if (File_mount() == OK)             /* check if format ok */
          {
            mem_state = MEM_CHIP_IDLE;
            return OK;
          }
        }
      #endif
      return KO;
    }

    case MEM_CARD_ERR_FMT:
    case MEM_CARD_IDLE:
    {
      #if (MEM_CARD_TYPE != CARD_NONE)
        while (gl_mem_tick != MEM_TIME_OUT)
        {
          if (File_mount() == OK)             /* check if format ok */
          {
            mem_state = MEM_CARD_IDLE;
            return OK;
          }
        }
      #endif
      return KO;
    }

    default:
    {
      return KO;
    }
  }
}


/*F**************************************************************************
* NAME: mem_load_card
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   
*----------------------------------------------------------------------------
* PURPOSE:
*   Load a card medium (like Compact disk) 
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void mem_load_card(void)
{
#if (MEM_CARD_TYPE != CARD_NONE)
  mem_state = MEM_CARD_INIT;
#endif
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -