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

📄 mmc_drv.lst

📁 这是atmel公司的89C51SND1C的mp3源程序
💻 LST
字号:
C51 COMPILER V6.20c  MMC_DRV                                                               07/10/2002 15:17:35 PAGE 1   


C51 COMPILER V6.20c, COMPILATION OF MODULE MMC_DRV
OBJECT MODULE PLACED IN ..\obj\mmc_drv.obj
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE ..\..\..\lib\mmc\mmc_drv.c BROWSE INCDIR(..\src\system;..\..\..\lib) DEFINE
                    -(KEIL) DEBUG OBJECTEXTEND PRINT(.\mmc_drv.lst) OBJECT(..\obj\mmc_drv.obj) 

stmt level    source

   1          /*C**************************************************************************
   2          * $RCSfile: mmc_drv.c,v $
   3          *----------------------------------------------------------------------------
   4          * Copyright (c) 2002 Atmel.
   5          *----------------------------------------------------------------------------
   6          * RELEASE:      $Name: DEMO_FAT_1_2_5 $      
   7          * REVISION:     $Revision: 1.4 $     
   8          * FILE_CVSID:   $Id: mmc_drv.c,v 1.4 2002/05/24 09:51:13 njourdan Exp $       
   9          *----------------------------------------------------------------------------
  10          * PURPOSE:
  11          * This file contains the MMC driver routines
  12          *
  13          * NOTES:
  14          * Driver Configuration:
  15          *   - None
  16          * Global Variables:
  17          *   - None
  18          *****************************************************************************/
  19          
  20          /*_____ I N C L U D E S ____________________________________________________*/
  21          
  22          #include "config.h"                         /* system configuration */
  23          #include "mmc_drv.h"                        /* mmc driver definition */
  24          
  25          
  26          /*_____ M A C R O S ________________________________________________________*/
  27          
  28          
  29          /*_____ D E F I N I T I O N ________________________________________________*/
  30          
  31          static  Byte    mmc_state;
  32          static  bit     mmc_ready;                  /* MMC in prog state */
  33          
  34          
  35          /*_____ D E C L A R A T I O N ______________________________________________*/
  36          
  37          void    mmc_set_prio (Byte);
  38          void    mmc_send_cmd (Byte, Uint32, Byte);
  39          bit     mmc_check_response (void);
  40          
  41          
  42          /*F**************************************************************************
  43          * NAME: mmc_set_prio
  44          *----------------------------------------------------------------------------
  45          * PARAMS:
  46          *
  47          * return:
  48          *----------------------------------------------------------------------------
  49          * PURPOSE:
  50          *   Set the MMC controller priority interrupt
  51          *----------------------------------------------------------------------------
  52          * EXAMPLE:
  53          *----------------------------------------------------------------------------
  54          * NOTE:
C51 COMPILER V6.20c  MMC_DRV                                                               07/10/2002 15:17:35 PAGE 2   

  55          *----------------------------------------------------------------------------
  56          * REQUIREMENTS: 
  57          * ram/xram:
  58          * cycle:
  59          * stack: 
  60          * code:
  61          *****************************************************************************/
  62          void mmc_set_prio (Byte priority)
  63          {
  64   1        if ((priority == 1) || (priority == 3))     /* set LSB priority bit */
  65   1        {
  66   2          IPL1 |=  MSK_ESPI;
  67   2        }
  68   1        if ((priority == 2) || (priority == 3))     /* set MSB priority bit */
  69   1        {
  70   2          IPH1 |= MSK_ESPI;
  71   2        }
  72   1      }
  73          
  74          
  75          /*F**************************************************************************
  76          * NAME: mmc_send_cmd
  77          *----------------------------------------------------------------------------
  78          * PARAMS:
  79          *   index:    command index
  80          *   argument: argument (32 bits) of the command to send
  81          *   response: expected response to the command to send
  82          *
  83          * return:
  84          *----------------------------------------------------------------------------
  85          * PURPOSE:
  86          *   Send a command on the bus
  87          *----------------------------------------------------------------------------
  88          * EXAMPLE:
  89          *----------------------------------------------------------------------------
  90          * NOTE:
  91          *   The fifo lock flag is not tested it is under firmware responsability to
  92          *   take care of inter-command delays 
  93          *----------------------------------------------------------------------------
  94          * REQUIREMENTS: 
  95          * ram/xram:
  96          * cycle:
  97          * stack: 
  98          * code:
  99          *****************************************************************************/
 100          void mmc_send_cmd (Byte index, Uint32 argument, Byte response)
 101          {
 102   1        MMCMD = index;
 103   1        MMCMD = ((Byte*)&argument)[0];
 104   1        MMCMD = ((Byte*)&argument)[1];
 105   1        MMCMD = ((Byte*)&argument)[2];
 106   1        MMCMD = ((Byte*)&argument)[3];
 107   1      
 108   1        switch (response)
 109   1        {
 110   2          case MMC_RESP_R1:
 111   2          case MMC_RESP_R4:
 112   2          case MMC_RESP_R5:
 113   2          {
 114   3            MMCON0 |= MSK_RFMT;                   /* set 48 bits response */
 115   3            MMCON0 &= ~MSK_CRCDIS;                /* set response with CRC7 */
 116   3            MMCON1 |= (MSK_CMDEN|MSK_RESPEN);
C51 COMPILER V6.20c  MMC_DRV                                                               07/10/2002 15:17:35 PAGE 3   

 117   3            MMCON1 &= ~(MSK_CMDEN|MSK_RESPEN);    /* send command with response */
 118   3            break;
 119   3          }
 120   2          case MMC_RESP_R2:
 121   2          {
 122   3            MMCON0 &= ~(MSK_RFMT | MSK_CRCDIS);   /* set 136 bits response with CRC7 */
 123   3            MMCON1 |= (MSK_CMDEN|MSK_RESPEN);
 124   3            MMCON1 &= ~(MSK_CMDEN|MSK_RESPEN);    /* send command with response */
 125   3            break;
 126   3          }
 127   2          case MMC_RESP_R3:
 128   2          {
 129   3            MMCON0 |= (MSK_RFMT | MSK_CRCDIS);    /* set 48 bits response without CRC7 */
 130   3            MMCON1 |= (MSK_CMDEN|MSK_RESPEN);
 131   3            MMCON1 &= ~(MSK_CMDEN|MSK_RESPEN);    /* send command with response */
 132   3            break;
 133   3          }
 134   2          case MMC_NO_RESP:
 135   2          default:
 136   2          {
 137   3            MMCON1 |= MSK_CMDEN;
 138   3            MMCON1 &= ~MSK_CMDEN;                 /* send command without response */
 139   3            break;
 140   3          }
 141   2        }
 142   1      }
 143          
 144          
 145          /*F**************************************************************************
 146          * NAME: mmc_send_scmd
 147          *----------------------------------------------------------------------------
 148          * PARAMS:
 149          *   index:    command index
 150          *   response: expected response to the command to send
 151          *
 152          * return:
 153          *----------------------------------------------------------------------------
 154          * PURPOSE:
 155          *   Send a short command on the bus
 156          *----------------------------------------------------------------------------
 157          * EXAMPLE:
 158          *----------------------------------------------------------------------------
 159          * NOTE:
 160          *   The fifo lock flag is not tested it is under firmware responsability to
 161          *   take care of inter-command delays 
 162          *----------------------------------------------------------------------------
 163          * REQUIREMENTS: 
 164          * ram/xram:
 165          * cycle:
 166          * stack: 
 167          * code:
 168          *****************************************************************************/
 169          void mmc_send_scmd (Byte index, Byte response)
 170          {
 171   1        MMCMD = index;
 172   1        MMCMD = (Byte)MMC_NO_ARG;
 173   1        MMCMD = (Byte)MMC_NO_ARG;
 174   1        MMCMD = (Byte)MMC_NO_ARG;
 175   1        MMCMD = (Byte)MMC_NO_ARG;
 176   1      
 177   1        switch (response)
 178   1        {
C51 COMPILER V6.20c  MMC_DRV                                                               07/10/2002 15:17:35 PAGE 4   

 179   2          case MMC_RESP_R1:
 180   2          case MMC_RESP_R4:
 181   2          case MMC_RESP_R5:
 182   2          {
 183   3            MMCON0 |= MSK_RFMT;                   /* set 48 bits response */
 184   3            MMCON0 &= ~MSK_CRCDIS;                /* set response with CRC7 */
 185   3            MMCON1 |= (MSK_CMDEN|MSK_RESPEN);
 186   3            MMCON1 &= ~(MSK_CMDEN|MSK_RESPEN);    /* send command with response */
 187   3            break;
 188   3          }
 189   2          case MMC_RESP_R2:
 190   2          {
 191   3            MMCON0 &= ~(MSK_RFMT | MSK_CRCDIS);   /* set 136 bits response with CRC7 */
 192   3            MMCON1 |= (MSK_CMDEN|MSK_RESPEN);
 193   3            MMCON1 &= ~(MSK_CMDEN|MSK_RESPEN);    /* send command with response */
 194   3            break;
 195   3          }
 196   2          case MMC_RESP_R3:
 197   2          {
 198   3            MMCON0 |= (MSK_RFMT | MSK_CRCDIS);    /* set 48 bits response without CRC7 */
 199   3            MMCON1 |= (MSK_CMDEN|MSK_RESPEN);
 200   3            MMCON1 &= ~(MSK_CMDEN|MSK_RESPEN);    /* send command with response */
 201   3            break;
 202   3          }
 203   2          case MMC_NO_RESP:
 204   2          default:
 205   2          {
 206   3            MMCON1 |= MSK_CMDEN;
 207   3            MMCON1 &= ~MSK_CMDEN;                 /* send command without response */
 208   3            break;
 209   3          }
 210   2        }
 211   1      }
 212          
 213          
 214          /*F**************************************************************************
 215          * NAME: mmc_check_response
 216          *----------------------------------------------------------------------------
 217          * PARAMS:
 218          *
 219          * return:
 220          *   MMC_ERR_RESP: no response or bad format received
 221          *   MMC_RESP_OK:  response received
 222          *----------------------------------------------------------------------------
 223          * PURPOSE: 
 224          *   Check command response 
 225          *----------------------------------------------------------------------------
 226          * EXAMPLE:
 227          *----------------------------------------------------------------------------
 228          * NOTE:
 229          *----------------------------------------------------------------------------
 230          * REQUIREMENTS:
 231          * ram/xram:
 232          * cycle:
 233          * stack: 
 234          * code:
 235          *****************************************************************************/
 236          bit mmc_check_response (void)
 237          {
 238   1        if (Mmc_response_received())
 239   1        { /* response received */
 240   2          if ((MMCON0 & MSK_CRCDIS) != 0)
C51 COMPILER V6.20c  MMC_DRV                                                               07/10/2002 15:17:35 PAGE 5   

 241   2          {                                         /* CRC7 not computed */
 242   3            if ((MMSTA & MSK_RESPFS) != 0)
 243   3            {
 244   4              return (MMC_RESP_OK);
 245   4            }
 246   3            else
 247   3            {
 248   4              return (MMC_ERR_RESP);                /* format error */
 249   4            }
 250   3          }
 251   2          else
 252   2          {                                         /* CRC7 computed */
 253   3            if ((MMSTA & (MSK_RESPFS | MSK_CRC7S)) == (MSK_RESPFS | MSK_CRC7S))
 254   3            {
 255   4              return (MMC_RESP_OK);
 256   4            }
 257   3            else
 258   3            {
 259   4              return (MMC_ERR_RESP);                /* format or CRC7 error */
 260   4            }
 261   3          }
 262   2        }
 263   1        else
 264   1        { /* no response received */
 265   2          return (MMC_ERR_RESP);
 266   2        }
 267   1      }
 268          
 269          
 270          /*F**************************************************************************
 271          * NAME: mmc_read_response
 272          *----------------------------------------------------------------------------
 273          * PARAMS:
 274          *
 275          * return:
 276          *   4-byte argument of the response
 277          *----------------------------------------------------------------------------
 278          * PURPOSE: 
 279          *   Read command argument response 
 280          *----------------------------------------------------------------------------
 281          * EXAMPLE:
 282          *----------------------------------------------------------------------------
 283          * NOTE:
 284          *----------------------------------------------------------------------------
 285          * REQUIREMENTS:
 286          * ram/xram:
 287          * cycle:
 288          * stack: 
 289          * code:
 290          *****************************************************************************/
 291          Uint32 mmc_read_response (void)
 292          {
 293   1      Uint32  argument;
 294   1      
 295   1        ((Byte*)&argument)[0] = MMCMD;    /* dummy index read */
 296   1        ((Byte*)&argument)[0] = MMCMD;
 297   1        ((Byte*)&argument)[1] = MMCMD;
 298   1        ((Byte*)&argument)[2] = MMCMD;
 299   1        ((Byte*)&argument)[3] = MMCMD;
 300   1      
 301   1        return argument;
 302   1      }
C51 COMPILER V6.20c  MMC_DRV                                                               07/10/2002 15:17:35 PAGE 6   

 303          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    201    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1      10
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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