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

📄 smartmed.c

📁 基于EP7312的MP3播放器源代码,包括MCU和PC端代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
            if(ulParam3 & FLASH_ADDR_4_CYCLE)            {                //                // This SmartMedia card has 512 bytes per page and requires 4                // address cycles.                //                NANDWriteRedt_512_4(HwNANDAddress, ulParam1,                                    (unsigned char *)ulParam2);            }            else            {                //                // This SmartMedia card has 512 bytes per page and requires 3                // address cycles.                //                NANDWriteRedt_512_3(HwNANDAddress, ulParam1,                                    (unsigned char *)ulParam2);            }            //            // Indicate that the SmartMedia card is busy.            //            DisableIRQ();            sSmartMedia.ulFlags |= FLAG_IS_BUSY;            EnableIRQ();            //            // We're done with this request.            //            break;        }        //        // We should never get here, but just in case...        //        default:        {            //            // Deselect the SmartMedia card.            //            pulGPIO[HwPortABCD >> 2] |= HwPortABCD_SmartMedia_CS;            //            // Return a failure.            //            return(0);        }    }    //    // Deselect the SmartMedia card.    //    pulGPIO[HwPortABCD >> 2] |= HwPortABCD_SmartMedia_CS;    //    // Success.    //    return(1);}//****************************************************************************//// The file system IOCTL entry point for the SmartMedia card.////****************************************************************************unsigned longSMIoctl(unsigned char *pucScratch, unsigned char *pucWriteBuffer,        unsigned long ulIoctl, unsigned long ulInstance,        unsigned long ulParam1, unsigned long ulParam2){    volatile unsigned long *pulPtr = (unsigned long *)HwBaseAddress;    unsigned long ulRet;    //    // If we are being initialized, then we need to setup our global variables.    //    if(ulIoctl == IOCTL_FS_INIT)    {        //        // Set the address of the FLASH driver to be used by the FTL layer.        //        sSmartMedia.sFTL.pfnFlashDriver = SMFLASHIoctl;        //        // Set the address of the FTL layer to be used by the FAT layer.        //        sSmartMedia.sFAT.pfnBlockDriver = FTLIoctl;        sSmartMedia.sFAT.pvBlockDriverState = &sSmartMedia.sFTL;        //        // Clear the state of the SmartMedia FLASH driver's state flags.        //        sSmartMedia.ulFlags = 0;#ifdef HwIrqSmartMediaInsert        //        // Enable the SmartMedia insert interrupt.        //        pulPtr[HwIntMask >> 2] |= HwIrqSmartMediaInsert;        //        // Success.        //        return(1);#else        //        // Since we do not have an insert/remove interrupt, we simply assume        // the card is inserted all the time.  This means that the card must be        // inserted at bootup time and can never be removed (without a cold        // boot).        //        sSmartMedia.ulFlags = FLAG_CARD_INSERTED | FLAG_CARD_INITIALIZED;#endif    }    //    // If the name of the media is being requested, then return it.    //    if(ulIoctl == IOCTL_FS_GETMEDIANAME)    {        //        // Return the name of the drive.        //        memcpy((void *)ulParam1, pusDriveName, sizeof(pusDriveName));        //        // Return the length of the drive name.        //        *((unsigned long *)ulParam2) = sizeof(pusDriveName);        //        // Success.        //        return(1);    }    //    // See if there is a SmartMedia card inserted.    //    if(!(sSmartMedia.ulFlags & FLAG_CARD_INSERTED))    {        //        // See if this is a close request.        //        if((ulIoctl == IOCTL_FS_CLOSE) || (ulIoctl == IOCTL_FS_CLOSEDIR))        {            //            // Return success.            //            return(1);        }        //        // Fail all other requests.        //        return(0);    }    //    // Power on the SmartMedia card.    //#ifdef HwPortABCD_SmartMedia_Power    pulPtr[HwPortABCD >> 2] &= ~HwPortABCD_SmartMedia_Power;    //    // Wait for the SmartMedia card to complete its power on sequence.    //    for(ulRet = 0; ulRet < 768; ulRet++)    {    }#endif    //    // If the SmartMedia card has not been initialized, then do so now.    //    if(!(sSmartMedia.ulFlags & FLAG_CARD_INITIALIZED))    {        //        // Initiailize the FAT code.        //        if(FATIoctl(&sSmartMedia.sFAT, pucScratch, 0, IOCTL_FS_INIT, 0, 0,                    0) == 0)        {#ifdef HwPortABCD_SmartMedia_Power            pulPtr[HwPortABCD >> 2] |= HwPortABCD_SmartMedia_Power;#endif            return(0);        }        //        // Indicate that the card has been initialized.        //        sSmartMedia.ulFlags |= FLAG_CARD_INITIALIZED;    }    //    // Call the FAT code.    //    ulRet = FATIoctl(&sSmartMedia.sFAT, pucScratch, pucWriteBuffer, ulIoctl,                     ulInstance, ulParam1, ulParam2);    //    // If the SmartMedia card could be busy, then wait until it is not.    //    if(sSmartMedia.ulFlags & FLAG_IS_BUSY)    {        //        // Select the SmartMedia card.        //        pulPtr[HwPortABCD >> 2] &= ~HwPortABCD_SmartMedia_CS;        //        // Wait until the SmartMedia card is not busy.        //        NANDWaitTilNotBusy(HwNANDAddress);        //        // Deselect the SmartMedia card.        //        pulPtr[HwPortABCD >> 2] |= HwPortABCD_SmartMedia_CS;        //        // Indicate that the SmartMedia card is not busy.        //        DisableIRQ();        sSmartMedia.ulFlags &= ~FLAG_IS_BUSY;        EnableIRQ();    }    //    // Power off the SmartMedia card.    //#ifdef HwPortABCD_SmartMedia_Power    pulPtr[HwPortABCD >> 2] |= HwPortABCD_SmartMedia_Power;#endif    //    // Return to the caller.    //    return(ulRet);}//****************************************************************************//// SMISR is the interrupt service routine that handles the SmartMedia// insertion/removal interrupt.////****************************************************************************#ifdef HwIrqSmartMediaInsertvoidSMISR(void){    volatile unsigned long *pulPtr = (unsigned long *)HwBaseAddress;    unsigned long ulStatus;    //    // Get the current interrupt source status.    //    ulStatus = pulPtr[HwIntStatus >> 2] & pulPtr[HwIntMask >> 2];    //    // If the SmartMedia insert interrupt is asserted, then handle it now.    //    if(ulStatus & HwIrqSmartMediaInsert)    {        //        // Indicate that we have a SmartMedia card inserted in the slot.        //        sSmartMedia.ulFlags |= FLAG_CARD_INSERTED;        //        // Mask the insert interrupt and unmask the remove interrupt so we can        // detect a removal.        //        pulPtr[HwIntMask >> 2] ^= HwIrqSmartMediaInsert |                                  HwIrqSmartMediaRemove;        //        // Indicate that a removeable media device has been inserted.        //        ulSystemFlags |= SYSFLAG_MEDIA_INSERT;    }    //    // If the SmartMedia remove interrupt is asserted, then handle it now.    //    else if(ulStatus & HwIrqSmartMediaRemove)    {        //        // The first thing we need to do is to turn off the power to the        // SmartMedia card.        //#ifdef HwPortABCD_SmartMedia_Power        pulPtr[HwPortABCD >> 2] |= HwPortABCD_SmartMedia_Power;#endif        //        // Indicate that we no longer have a SmartMedia card inserted in the        // slot.        //        sSmartMedia.ulFlags &= ~(FLAG_CARD_INSERTED | FLAG_CARD_INITIALIZED);        //        // Mask the remove interrupt and unmask the insert interrupt so we can        // detect an insert.        //        pulPtr[HwIntMask >> 2] ^= HwIrqSmartMediaInsert |                                  HwIrqSmartMediaRemove;        //        // If there is a pending removeable media insert, then clear it.        //        if(ulSystemFlags & SYSFLAG_MEDIA_INSERT)        {            ulSystemFlags &= ~SYSFLAG_MEDIA_INSERT;        }                //        // Otherwise, indicate that a removeable media device has been removed.        //        else        {            ulSystemFlags |= SYSFLAG_MEDIA_REMOVE;        }    }}#endif

⌨️ 快捷键说明

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