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

📄 startup.c

📁 A MP3 Player Source Code, Enjoy it!
💻 C
字号:
/* * MP3 Player, Startup Code, http://www.pjrc.com/tech/mp3 * Copyright (c) 2000, PJRC.COM, LLC * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * As a specific exception to the GPL, the executable object code built * from this source code may be combined with hardware configuration data * files.  A hardware configuration data file is a set of data that is * transmitted to an intergrated circuit that is not a general purpose * microprocessor or microcontroller, in order to establish its normal * operation.  The process of combining the executable ojbect code built * from the GPL licensed source code with the hardware configuration data * shall be considered an aggregation of another work not based on the * Program.  While the GPL does not restrict use of the program, any * use restriction associated with the hardware configuration data (for * example, that it only be used with particular hardware) shall apply * to the combined file which includes a copy of the hardware configuration * data. * * Contact: paul@pjrc.com */#include "paulmon2.h"#include "as31glue.h"#include "startup.h"char check_old_firmware(void);void run_old_firmware_rev(void);/* Initialize all the hardware and device drivers.  Return 0 for *//* success of non-zero if there is a problem with the hardware *//* If the simm is missing, the an attempt if made to run the old *//* firmware, instead of returning */unsigned char _sdcc_external_startup(void){	unsigned char retry_count;	pm2_pstr("\\[\\@ 0MP3 Player Startup\r\n\\]\r\n");	drivers_init();	for (retry_count=0; retry_count < 4; retry_count++) {		pm2_pstr("\\[Config FPGA: \\]\r\n");		//pm2_pstr("Configuring Xilinx XCS10XL FPGA Chip: ");		if (xilinx_download() != 0) {			pm2_pstr("\\[Error\r\n\\]");			continue;		}		// there should be some simple test to read/write		// some xilinx-based registers to verify that the		// xilinx chip really did initialize		pm2_pstr("\\[OK\r\n\\]");		if (retry_count == 0) {			/* this ought to start the drive spinning */			pm2_pstr("\\[Reset IDE Devices\r\n\\]");			ide_hard_reset();		}		if (detect_simm_size() == 0) {			pm2_pstr("\\[SIMM Not Found\r\n\\]");			run_old_firmware_rev();		}		/* TODO: move STA013 to main.c */		pm2_pstr("\\[Config STA013: \\]");		if (sta013_init() != 0) {			pm2_pstr("\\[Error!\r\n\\]");			continue;		}		pm2_pstr("\\[OK\r\n\\]");		pm2_pstr("\\[Test STA013: \\]");		if (test_sta013() != 0) {			pm2_pstr("\\[Error!\r\n\\]");			continue;		}		pm2_pstr("\\[OK\r\n\\]");		pm2_pstr("\\[Init Memory: \\]");		if (init_memory_mgr() != 0) run_old_firmware_rev();		return 0;	/* everything initialized ok */	}	pm2_pstr("Unable to start\r\n");	run_old_firmware_rev();}/* attempt to run the old firmware that doesn't use the SIMM */void run_old_firmware_rev(void){	if (check_old_firmware() == 0) {		pm2_pstr("Running Old Firmware, that doesn't use the SIMM\r\n");		run_old_firmware();	}	pm2_exit();}char check_old_firmware(void){	_asm        mov     dptr, #0xF000        clr     a        movc    a, @a+dptr        cjne    a, #0xA5, cant_find_old_rev        inc     dptr        clr     a        movc    a, @a+dptr        cjne    a, #0xE5, cant_find_old_rev        inc     dptr        clr     a        movc    a, @a+dptr        cjne    a, #0xE0, cant_find_old_rev        inc     dptr        clr     a        movc    a, @a+dptr        cjne    a, #0xA5, cant_find_old_rev        inc     dptr        clr     a        movc    a, @a+dptr        cjne    a, #0x23, cant_find_old_rev        mov     dptr, #0xF030        clr     a        movc    a, @a+dptr        //cjne    a, #'0', cant_find_old_rev        cjne    a, #0x30, cant_find_old_rev        inc     dptr        clr     a        movc    a, @a+dptr        //cjne    a, #'.', cant_find_old_rev        cjne    a, #0x2E, cant_find_old_rev        inc     dptr        clr     a        movc    a, @a+dptr        //cjne    a, #'1', cant_find_old_rev        cjne    a, #0x31, cant_find_old_rev        mov     dpl, #0	retcant_find_old_rev:        mov     dpl, #1	ret	_endasm;}

⌨️ 快捷键说明

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