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

📄 update.c

📁 基于EP7312的MP3播放器源代码,包括MCU和PC端代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
//****************************************************************************//// UPDATE.C - Handles updating of the Internet audio player software.//// Copyright (c) 2000,2001 Cirrus Logic, Inc.////****************************************************************************#include "../hwport.h"#include "../hwdefs.h"//****************************************************************************//// Prototypes for the functions in the USB code which we call.////****************************************************************************extern void USBEnable(void);extern void USBDisable(void);extern void USBForceConfiguration(unsigned long bConfigured);extern void USBISR(void);extern void USBDownload(unsigned char *pucData);//****************************************************************************//// Prototypes for the functions in the user interface code which we will call.////****************************************************************************extern void UIEnable(void);extern void UIDisable(void);extern void UIRequestUpdate(void);extern void UIUpdate(void);//****************************************************************************//// Prototypes for the FLASH programming routines.////****************************************************************************extern void EraseFLASH(unsigned long ulBase, unsigned long ulLength,                       unsigned long bIs16BitWide);extern void WriteFLASH(unsigned char *pucData, unsigned long ulOffset,                       unsigned long ulLength, unsigned long bIs16BitWide);//****************************************************************************//// The variable which contains the address of the first unused word in// internal SRAM.////****************************************************************************extern unsigned long ulEndOfRAM;//****************************************************************************//// A boolean which is true if the program FLASH is 16 bits wide and false if// it is 32 bits wide.////****************************************************************************unsigned long bIs16Bit;//****************************************************************************//// The system flags used in the player, which is updated by the USB code.// This exists here simply to satisfy the linker; the value in not used in any// way.////****************************************************************************unsigned long ulSystemFlags;//****************************************************************************//// The offset into the NOR FLASH where the next block of data will be written.////****************************************************************************unsigned long ulOffset;//****************************************************************************//// Disable the IRQ interrupt.////****************************************************************************voidDisableIRQ(void){    //    // Do nothing since we never enable the IRQ interrupt.    //}//****************************************************************************//// Enable the IRQ interrupt.////****************************************************************************voidEnableIRQ(void){    //    // Do nothing since we never enable the IRQ interrupt (we poll the USB    // controller instead).    //}//****************************************************************************//// Wait for and handle an interrupt from the USB controller.////****************************************************************************voidHalt(void){    volatile unsigned long *pulPtr = (unsigned long *)HwBaseAddress;    //    // Wait until the USB interrupt has been asserted.    //    while(!(pulPtr[HwIntStatus >> 2] & HwIrqUSB))    {        //        // Put the EP7209 into HALT mode.        //        pulPtr[HwHalt >> 2] = 0;    }    //    // Call the USB interrupt handler.    //    USBISR();}//****************************************************************************//// SupportUpdate determines if we support updating the software.////****************************************************************************unsigned longSupportUpdate(void){    //    // Since we are the update software, then we by implication do support    // updates.    //    return(1);}//****************************************************************************//// StartUpdate branches to the code which performs the software update.////****************************************************************************voidStartUpdate(void){    //    // Indicate that an update is in progress.    //    UIUpdate();    //    // Since we are the update software, there is nothing to be done.  We    // therefore simply return.    //}//****************************************************************************//// FSSetWriteScratch sets the address of the scratch buffer to be used during// write operations.////****************************************************************************voidFSSetWriteScratch(unsigned char *pucWriteScratch){    //    // We do not need to use the write scratch buffer, so don't bother    // remembering where it is located.    //}//****************************************************************************//// FSGetMediaID returns the media unique ID for the given drive, if it exists.////****************************************************************************unsigned longFSGetMediaID(unsigned long ulDrive, unsigned char *pucMediaIDBuffer,             unsigned long *pulLength){    //    // We do not support a media unique ID for the NOR FLASH.    //    return(0);}//****************************************************************************//// FSGetMediaName returns the name of the drive.////****************************************************************************unsigned longFSGetMediaName(unsigned long ulDrive, unsigned short *pusName,               unsigned long *pulLength){    //    // We do not support a name for the NOR FLASH.    //    return(0);}//****************************************************************************//// FSNumDrives returns the number of drives supported by the file system// layer.////****************************************************************************unsigned longFSNumDrives(void){    //    // There is only one drive (the NOR FLASH).    //    return(0);}//****************************************************************************//// FSOpen opens or creates the specified file on the specified drive.////****************************************************************************unsigned longFSOpen(void *pFile, unsigned long ulDrive, const char *pcFileName,       unsigned long ulFlags){    //    // We do not support opening a file, or creating a file through the open    // interface.    //    return(0);}//****************************************************************************//// FSCreate creates the specified file with the given size on the specified// drive.////****************************************************************************unsigned longFSCreate(void *pFile, unsigned long ulDrive, const char *pcFileName,         unsigned long ulFileLength){    //    // Make sure that the specified length is valid.    //    if((HwPlayerAddress + ulFileLength) > 0x00100000)    {        //        // The image is too large to fit into the available FLASH, so return a        // failure.        //        return(0);    }    //    // Erase enough of the NOR FLASH to store the entire program image.    //    EraseFLASH(HwPlayerAddress, ulFileLength, bIs16Bit);    //    // Initialize the offset to the beginning of the player image.    //    ulOffset = HwPlayerAddress;    //    // Success.    //    return(1);}//****************************************************************************//// FSRead reads data from the opened file.////****************************************************************************unsigned longFSRead(void *pFile, void *pvBuffer, unsigned long ulNumBytes){    //    // We do not support reading from the NOR FLASH.    //    return(0);}//****************************************************************************//// FSReadBS reads data from the opened file, performing a byte-swap on each// 32-bit word in the read data.////****************************************************************************unsigned longFSReadBS(void *pFile, void *pvBuffer, unsigned long ulNumBytes){    //    // We do not support reading from the NOR FLASH.    //    return(0);}//****************************************************************************//// FSWrite writes data to the opened file.////****************************************************************************unsigned longFSWrite(void *pFile, void *pvBuffer, unsigned long ulNumBytes){    //    // Write the data into the NOR FLASH.    //    WriteFLASH((unsigned char *)pvBuffer, ulOffset, (ulNumBytes + 31) & ~31,               bIs16Bit);    //    // Increment the offset by the number of bytes written.    //    ulOffset += ulNumBytes;    //    // Success.    //    return(ulNumBytes);}//****************************************************************************//// FSSeek moves the read/write pointer for the opened file to the specified

⌨️ 快捷键说明

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