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

📄 tool_task.c

📁 MP3设计源代码 使用atmel的单片机
💻 C
字号:
/*C**************************************************************************
* NAME:         tool_task.c
*----------------------------------------------------------------------------
* Copyright (c) 2002 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-demo-df-sd-3_0_0      
* REVISION:     1.13     
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the tool task and attached routines
*
* NOTES:
* Global Variables:
*   - gl_key_press: bit in bdata space
*   - gl_key:       byte in idata space
*****************************************************************************/

/*_____ I N C L U D E S ____________________________________________________*/

#include "config.h"                         /* system configuration */
#include "board.h"                          /* board definition */
#include "modules\display\disp.h"           /* display definition */
#include "modules\file\file.h"              /* file definition */
#include "modules\mem\mem_task.h"           /* memory task definition */
#include "modules\mode\mode_task.h"         /* mode task definition */
#include "tool_task.h"                      /* tool task definition */


/*_____ M A C R O S ________________________________________________________*/


/*_____ D E F I N I T I O N ________________________________________________*/

extern  bdata   bit     gl_key_press;   /* set to TRUE if a key is decoded */
extern  idata   Byte    gl_key;         /* value of the key pressed */

extern          bit     reserved_disk_space;

static  idata   Byte  tool_index;           /* index in tool menu */
static  data    Byte  tool_state;           /* task state */

code    St_menu tool_menu[] =
                {
                  {TOOL_FORMAT,     "\2 Format...     \r"},
                  {TOOL_FORMAT_RSVD,"\2 Format rsvd...\r"},
                };


/*_____ D E C L A R A T I O N ______________________________________________*/


/*F**************************************************************************
* NAME: tool_task_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Tool task initialization
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void tool_task_init (void)
{
  tool_state = TOOL_INIT;
}


/*F**************************************************************************
* NAME: tool_task
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Tool task
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   STATES:
*   TOOL_INIT   screen initialization
*   TOOL_IDLE   idle state of this task
*   TOOL_CONF   configuration menu
*   TOOL_MEM    memory menu
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void tool_task (void)
{
  switch (tool_state)
  {
    case TOOL_INIT:
    {
      if (mem_status() != MEM_BUSY)         /* wait end of memory install */
      {
        print_mode_tool();                  /* select song icon */
        print_state_stop();
        print_screen(TOOL_SCREEN);          /* display tool screen */
        tool_index = 0;                     /* reset menu index */
        print_string(tool_menu[0].disp);    /* print first tool command */
        tool_state = TOOL_IDLE;
      }
      break;
    }

    /* Tool Menu */
    case TOOL_IDLE:
    {
      if (gl_key_press)
      {
        switch (gl_key)
        {
          case KEY_MEM:
          {
            mem_select_next();              /* select next memory */
            tool_state = TOOL_INIT;
            break;
          }

          case KEY_DEC:
          {
            if (tool_index == (sizeof(tool_menu) / sizeof(St_menu)) - 1)
            {
              tool_index = 0;               /* point on first item */
            }
            else
            {
              tool_index++;                 /* point next item */
            }
            print_string(tool_menu[tool_index].disp);
            break;
          }

          case KEY_INC:
          {
            if (tool_index == 0)
            {
              tool_index = (sizeof(tool_menu) / sizeof(St_menu) - 1);  /* point on last item */
            }
            else
            {
              tool_index--;                 /* point previous item */
            }
            print_string(tool_menu[tool_index].disp);
            break;
          }

          case KEY_ENTER:
          {
            /* validate menu item */
            tool_state = tool_menu[tool_index].state;
            break;
          }

          case KEY_MODE:
          {
            mode_set_init();                /* exit from tool task */
            tool_state = TOOL_INIT;
            break;
          }
        }
        gl_key_press = FALSE;               /* ack key usage */
      }
      else
      { /* check card presence */
        if (mem_check_card() == KO)
        {
          mem_select_next();
          tool_state = TOOL_INIT;           /* card has been unplugged */
        }
      }
      break;
    }

    case TOOL_FORMAT:
    {
      print_string(tool_menu[tool_index].disp);
      print_state_play();                   /* format in progress */
      reserved_disk_space = FALSE;
      Fformat();
      if (mem_select_format() != OK)        /* check file system */
      {
        print_string(TOOL_FORMAT_ERROR);
      }
      print_state_stop();
      tool_state = TOOL_IDLE;
      break;
    }

    case TOOL_FORMAT_RSVD:
    {
      print_string(tool_menu[tool_index].disp);
      print_state_play();                   /* format in progress */
      reserved_disk_space = TRUE;
      Fformat();
      if (mem_select_format() != OK)        /* check file system */
      {
        print_string(TOOL_FORMAT_ERROR);
      }
      print_state_stop();
      tool_state = TOOL_IDLE;
      break;
    }

  }
}

⌨️ 快捷键说明

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