亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? yampp7_usb.c

?? DIY自己的MP3的參考價值極高的代碼。含有詳細的解釋
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* ***********************************************************************
**
**  Copyright (C) 2002  Jesper Hansen <jesperh@telia.com> and 
**			Romuald Bialy (MIS) <romek_b@o2.pl>.
**
**
**  Yampp-7/USB - main file
**
**  File yampp7_usb.c
**
*************************************************************************
**
**   This file is part of the yampp system.
**
**  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.
**
*************************************************************************
**
**  Revision History
**
**  when         what  who	why
**
**  2002-09-13   0.9   Jesper   
				-initial test release
**  2002-09-22   1.0   MIS	
				-change automatic power off time to 2 minutes (in stop mode)
				-added card present checking, if no card present or card removed - go to sleep mode
				-added LED output on PB0
				-changed wakeup from sleep - now we must press and hold "Play" key for two seconds
				-added some beeps and blinks
				-added beep during playlist change. Playlist <TOTAL> have different tone from other.
				-added little delay in keypress checking for avoid accidental key pressing.
				-added FastForward, Random, Loudness and Repeat functions.
				-all functions is handled by 4 keys, layout is depending on playing state. 
				-added trap for vs1001 lockup if MP3 has garbage
				-added manual power off -> longpress STOP key in Stop mode.
				-added auto power of from pause state after 30 minutes
				-added battery level monitoring.
				-added battery charge indicator. See README.TXT for details.
**  2002-09-25   1.10  MIS	
				-added true random function (max 1024 songs in playlist)
**  2002-10-04   1.11  MIS	
				-added card removing checking during pause and stop mode
				-code speed-up and cleaning
				-added configurable CF standby time (in Constants.h)
**  2002-10-07   1.12  MIS	
				-added keyboard locking functions with autolock. See README.TXT for details.
**  2002-10-09   1.13  MIS	
				-fixed accidentally bootloader entering during keyboard locking
				-fixed accidentally change song after keyboard unlocking
				-added beep for manual lock/unlock confirmation (may be off in Constants.h)
				-added autolock turn ON/OFF while normal operation (if enabled)
**  2002-10-14   1.20  MIS	
				-beta version, added suport for Nokia LCD (not public)
**  2002-10-18 to1.45  MIS	
				-most bugfix (not public)
**  2002-10-20   2.00  MIS	
				-Public beta version of y7 firmware with LCD support.
**  2002-10-21   2.10  MIS	
				-added total song time displaying.
				-minior bugfix.
**  2002-10-23   2.11  MIS	
				-some improvements and bugfixes in displaying functions
				-bugfix in next playlist change. Stack overvriting generate this problem.
				-little change in keylock icons
**  2002-10-29   2.12  MIS	
				-eeprom is written only before power-off or USB connect, for extend eeprom life.
				-added suport for card-specific graphical logo.
				-bugfix in battery charge indication during stop.
				-bugfix in artist name displaying if name is short.
				-bugfix in fast forward volume decrease.
**  2002-10-30   2.13  MIS	
				-added support for national characters displaying
**  2002-11-02   2.14  MIS	
				-added support for vs1001 equalizer
				-some memory usage fixes 
**  2002-11-05   2.15  MIS	-changed scroll routines
**  2002-11-23   2.16  MIS	-fixed card removing checking
				-fixed "MENU" text length
				-fixed battery level monitoring
				-fixed randomizer
				-alternate scroll is back
**  2002-12-18   2.17  MIS	
				-added remain song time displaying
**  2003-01-13   2.18  MIS    	
				-added compatibility with new versions of GCC
				-some menu functionality extensions
				-removed uart calls
				-removed not used beep calls
				-some code optimisations
**  2003-02-23   2.20  MIS   	
				-added MMC card support
				-added support for new version of VS1001 equalizer library with 12 presets
				-changes in ATA library
				-many code optimisations
				-fixed contrast setting

**  2003-03-18	2.21 jesper
				- modifications for new Rev. D board.
				- charge input changed to PE1 instead of PE2
				- expanded contrast range

**  2003-03-19	2.22   MIS	-small fixes in jesper modifications
				-bugfix in processing garbaged song
				-support for any old and a new Rev D board (see Constants.h)

**  2003-05-18	2.23   MIS	-added balance control
				-enabled playlist change during STOP state
				-added info about backlight mode
				-code size optimization
				-some bugfix in visualisation, charging control ect.

**  2003-07-14	2.25b1   MIS	-Sources changed for compilation with AVR-GCC 3.3 !!!
				-added new optional "PREVOUS" key functionality (work like in normal CD players).
				-fixed problems with some large CF cards
				-fixed problems with yamppLink conect/disconnect on MMC cards.
				-fixed Pause Mode

**  2003-08-08	2.25b2  nilrog	-fixed playlists handling by changing the "get_offset_entry" function.
			MIS	-adding way to fix the CF card reset after card inserting problem solving.

**  2004-01-18	2.28    MIS	-added support for native mode of AtMega162 with crystal about 6-14MHz.
				 This cause speed up file transfer to about 400kb/s (at 14.318Mhz)
				-removed not used Uart and Base libraries code and not used part in usb.c file.
				-added confirmation before card formatting.
				-fixed low battery checking
				-fixed startup without card
				-speedup MMC card write

**  2004-02-05	3.00    MIS	-Test version for COLOR LCD
				-added 6 backlight modes with dimmer in M162 mode
				-fixed VS1001 hardware reset if VS not respond

**  2004-02-14	3.01    MIS	-fixed player crash after several changes of playlist.
				-some changes in audio data loading procedures

**  2004-02-15	3.02    MIS	-Changed all inp() and outp() macros to standard PORT = value.
				-Increased ContWrites value to 256.
				-Changed contrast setting image to number 5 and temoved text.
				-Changed randomizer function
				-Added display layout and colors configuration

**  2004-03-20	3.03    MIS	-Some bugfixes.
**  2004-04-09	3.04    MIS	-Speed-up the CPU, because it have problems with Bitrate > 160 and with VBR
				-Removed unused MS_BASS register writing

**  2004-04-11	3.10    MIS	-All strings moved to "lcd_layout.h" file for easy translation to other language
				-Fixed "Browse list" function.

**  2004-05-20	3.11    MIS	-Fixed MMC cards support.

**  2004-10-08	3.12    Nilrog	-fixed repeat one song function, thank's to Roger Nilson
			MIS	-fixed MMC size and name detection
				-fixed standby high current consumption with some MMC cards


*********************************************************************** */

#include "yampp7_usb.h"
#include "lcd_layout.h"
 
#define YAMPP_FIRMWARE_VERSION_MAJOR	3
#define YAMPP_FIRMWARE_VERSION_MINOR	12

#define DISK_LAYOUT_VERSION_MAJOR	1
#define DISK_LAYOUT_VERSION_MINOR	0


// The CPU is running with a 4.0 MHz (M161 CPU) or 4-15MHz (M162 CPU) clock

char firmware_scan_tag[] __attribute__ ((progmem)) = "yfwTAG";
char model_txt[]         __attribute__ ((progmem)) = "yampp-7";
char date_txt[]          __attribute__ ((progmem)) = __DATE__" / "__TIME__;
char version_txt[]       __attribute__ ((progmem)) = "3.12";

//------------------------------------------------------------------------------------------

extern u08 card_sbuf[512];

//------------------------------------------------------------------------------------------

void idle(void);
void next_song(u08 mode);
void feed_audio_data(void);
u08 IsCharging(void);
void set_cpu_speed(u08 speed);

event_e menu_event;

u08 isPlaying;				// Playing status
u08 bLoudness;				// Loudness modificator
u08 bRandom;				// Random modificator
u08 Repeat;				// Repeat mode modificator
u08 keylock;				// Keylock status
u08 autolock;				// Autolock ON/OFF
u08 lobatt;				// Battery status
u08 timemode;				// Remain time modificator
u08 light_mode;				// LCD backlight mode

u08 volume;				// Volume level
s08 balance;				// Balance
u08 vol_decrease;			// Modificator for fast forward function
u16 ClusterCount;			// Counter for Fast Forward calculations
u16 addtime;				// for Fast Forward time calculation
u16 curPlaylist;			// Current playlist number
u16 curIndex;				// Current song number inside playlist
u32 filesize;				// size of file to play (divided by 32)
u32 fileplayed;				// amount of played data (divided by 32)
u16 bitrate;				// song bitrate for fast forward time calculation
u16 songtime;

u08 time_flag;				// general time counter
u08 scroll_flag;			// scrolling flag
u08 info_flag;
u08 light_time;				// LCD backlight time
u16 sleepcount;				// counter for automatic power off
u16 lobatt_time;			// counter for low battery checking
u16 keylock_time;			// automatic keylock timer

u32 lcd_data_start;			// start sector of datas for LCD

u16 vs1001_fw;				// Pointer into vs1001 additional firmware pointer
u08 *outptr;				// pointer for sending data to vs1001
u08 ARTISTNAME_BUF[48];			// buffer for artist name scrolling
u08 SONGNAME_BUF[55];			// buffer for title name scrolling
u08 *artistname = (u08*)ARTISTNAME_BUF;	// pointer to artistname buffer
u08 *titlename = (u08*)SONGNAME_BUF;	// pointer to songname buffer
u08 scroll_length;			// size of scroll data
u08 scroll_length_2;			// size of scroll data 2
u08 scroll_pos;				// current position in scroll string
u08 scroll_pos_2;			// current position in scroll string 2
#ifdef ALTERNATE_SCROLL
 u08 scroll_dir, scroll_dir_2;
#endif

u32 MyCluster;				// current cluster number
u32 MySector = 2;			// current sector number
u16 SectorsLd;				// sectors in cluster counter
u08 colors[40];				// objects colors table

u08 *function_name[] __attribute__ ((progmem)) = {
(u08*)&fn0,(u08*)&fn1,(u08*)&fn2,(u08*)&fn3,(u08*)&fn4,(u08*)&fn5,(u08*)&fn6,(u08*)&fn7,(u08*)&fn8,(u08*)&fn9,(u08*)&fn10};

//---------------------------------------------------------------------------

u08 CARD_SW_Reset2(void)					// ATA Reset
{
#ifdef MMC_CARD
	u08 retry = 3;						// retry counter

	while(--retry)
	{
		if(MMC_Reset())
			return 1;
	}
	return 0;

#else
	u16 timeout = 5000;					// timeout = 500ms

	WriteBYTE(ATAPI_DevCtrl, 0x06);				// SRST and nIEN bits
	delay10();						// 10uS delay
	WriteBYTE(ATAPI_DevCtrl, 0x02);				// nIEN bit
	delay10();						// 10 uS delay
	while ((ATA_ReadStat() & 0xC0) != SR_DRDY)		// Wait for DRDY and !BUSY
	{
		if (--timeout == 0)				// Timeout check
			return (0);				// Return with ERROR
		delay100();					// 100 uS delay
	}
  	if (ReadBYTE(ATA_Sector) != 1)				// Checking for RESET signature
		return (0);					// Return with ERROR

	return 1;
#endif

}
//----------------------------------------------------------------------------

#define EVENT_QUEUE_SIZE	4
volatile event_e event_queue[EVENT_QUEUE_SIZE];
volatile u08 event_queue_head = 0;
volatile u08 event_queue_tail = 0;

void set_event(event_e e)
{
	event_queue[event_queue_head] = e;
	event_queue_head = (event_queue_head + 1) % EVENT_QUEUE_SIZE; 
}

event_e check_event(void)
{
	event_e tmp = EV_IDLE;
	
	//
	// check queue
	//
	if (event_queue_head != event_queue_tail)
	{
		tmp = event_queue[event_queue_tail];
		event_queue_tail = (event_queue_tail + 1) % EVENT_QUEUE_SIZE; 
	}
	return tmp;
}

event_e get_event(void)
{
	//
	// let the system have it's time
	//
	idle();
	return check_event();
}


//--------------------------------------------------------------------------
// States for	M162 mode	M161 mode
//
//    0  	Always OFF	Always OFF
//    1 	OFF/DIM		OFF/ON
//    2		OFF/ON		Always ON
//    3		Always DIM	not allowed
//    4		DIM/ON		not allowed
//    5		Always ON	not allowed


void backlight_off(void)
{
#if defined (__AVR_ATmega162__)

	if(light_mode < 3)			// OFF state
		OCR0 = 0;

	else if(light_mode < 5)
		OCR0 = BL_DIMMLEVEL;

#else

	if(light_mode < 2)
		cbi(PORTB,LED_PIN);		// OFF state

#endif
}

void backlight_on(void)
{
	light_time = BACKLIGHT_TIME;
#if defined (__AVR_ATmega162__)

	if(light_mode > 3 || light_mode == 2)
		OCR0 = 0xff;			// ON state
	else if(light_mode != 0)
		OCR0 = BL_DIMMLEVEL;		// DIMM state

#else

	if(light_mode != 0)
		sbi(PORTB,LED_PIN);		// ON state

#endif
}

//--------------------------------------------------------------------------

//
// External INT2 (Play key)
//

SIGNAL(SIG_INTERRUPT2)				// Need this for wake up from sleep
{
	asm volatile ("nop");
}


//--------------------------------------------------------------------------


SIGNAL(SIG_OVERFLOW1)				// timer 1 overflow every 100 mS
{
	TCNT1 = (u16)-(F_CPU / 2560);
	time_flag++;				// general time counter
	scroll_flag++;
	nKeyTime++;				// counter for keyboard
	lobatt_time++;				// counter for low battery routine
	sleepcount++;				// sleep counter

	if (light_time)
	{
		if (--light_time == 0)
		{
			asm volatile ("call backlight_off");
//			backlight_off();
		}
	}

	if (isPlaying && keylock==0 && autolock)
	{
		if (keylock_time <= AUTOLOCK_TIME)
			keylock_time++;
		else
			keylock = 1;
	}
}

//--------------------------------------------------------------------------

void LoudSet(void)
{
	if (vs1001_fw)
	{
		if(bLoudness)
		{
			vs1001_write(0x0A,vs1001_fw);
			vs1001_write(0x0D,0);
			vs1001_write(0x0D,bLoudness);
		}
		else
		{
			vs1001_write(0x0D,0);
			vs1001_write(0x0A,0);
		}
	}
	else
		vs1001_write(VS1001_MODE, 0x0080 * (bLoudness != 0));	// write bit SM_BASS to VS1001K

	vs1001_setvolume(volume,balance);
}

//--------------------------------------------------------------------------

static u08 buf[] __attribute__ ((progmem)) = {0x53, 0xEF, 0x6E, 0x45, 0x78, 0x69, 0x74};

void beep(u08 freq, u16 time)
{
	u08 i;
	vs1001_write(0x0D,0);
	vs1001_write(0x0A,0);
	if (isPlaying)
	{
		addtime += vs1001_read(VS1001_PLAYTIME);
		vs1001_reset();
	}
	vs1001_setvolume(volume+24,balance);		// -12dB
	vs1001_nulls(8);
	for (i=0;i<3;i++)				// beep on
		vs1001_send_data(PRG_RDB(&buf[i]));
	vs1001_send_data(freq);
	vs1001_nulls(4);

	delayms(time);

	for (i=3;i<7;i++)				// sine OFF
		vs1001_send_data(PRG_RDB(&buf[i]));
	vs1001_nulls(4);
	LoudSet();					// restore Loudness settings and Volume
}
//--------------------------------------------------------------------------

void send_sinewave_beeps(void)
{
	u08 j = 3;
	
	delayms(100);
	while (j--)
	{
		beep(SINE_1000,100);
		delayms(100);
	}
}

//--------------------------------------------------------------------------

void pump_audio(void)
{
	if(isPlaying)
	{
		while(CARD_Read(MySector))
		    	CARD_SW_Reset2();
		feed_audio_data();
	}
	else
		set_cpu_speed(CLKDIV);				// CPU clock = XTAL / M162CLKDIV

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久久久久免费丝袜| 亚洲女同女同女同女同女同69| 亚洲午夜av在线| 3751色影院一区二区三区| 国产日本一区二区| 亚洲欧洲成人精品av97| 亚洲一区二区三区四区五区中文| 国产亚洲人成网站| 玖玖九九国产精品| 91成人免费电影| 自拍视频在线观看一区二区| 99久久99精品久久久久久| 欧美三级日韩三级| 精品福利一区二区三区免费视频| 亚洲视频免费观看| 久久爱www久久做| 欧美日韩国产首页在线观看| 亚洲视频一二区| 在线91免费看| 国产一区三区三区| 国产亚洲综合在线| 国产精品一区在线| 一区二区三区小说| 精品国产青草久久久久福利| 成人理论电影网| 天堂va蜜桃一区二区三区| 精品少妇一区二区三区视频免付费 | 成人免费视频视频在线观看免费 | 91麻豆精东视频| 午夜精品久久久久久久| 国产精品美女www爽爽爽| 欧美日韩国产免费一区二区| 国产不卡高清在线观看视频| 亚洲国产一区二区三区| 国产视频一区在线观看| 成人动漫在线一区| 国产精品18久久久久久vr| 亚洲成av人片在线| 亚洲一区二区三区激情| 国产精品乱码妇女bbbb| 精品国产乱码久久久久久牛牛| 欧美日韩一区二区三区四区五区| 久久99热99| 极品美女销魂一区二区三区免费| 亚洲综合图片区| 尤物视频一区二区| 亚洲精品va在线观看| 一区二区三区四区av| 亚洲欧美怡红院| 国产日韩欧美精品在线| 国产精品久久久久精k8| 亚洲小少妇裸体bbw| 日韩精品成人一区二区在线| 日韩精品亚洲专区| 精品一区二区三区影院在线午夜| 久久精品国产亚洲aⅴ| 国产高清无密码一区二区三区| 国产很黄免费观看久久| 国产乱淫av一区二区三区| 岛国一区二区在线观看| 色一情一伦一子一伦一区| 99国产精品国产精品毛片| 日本道免费精品一区二区三区| 欧美三级欧美一级| 欧美日韩国产成人在线91| 色中色一区二区| 精品国产91亚洲一区二区三区婷婷| 中文字幕二三区不卡| 日韩电影网1区2区| 99视频国产精品| 精品va天堂亚洲国产| 亚洲国产综合人成综合网站| 亚洲成av人片在线观看| 成人精品国产福利| 日韩欧美中文一区二区| 丝袜美腿一区二区三区| 91黄色小视频| 亚洲欧美另类小说| 全国精品久久少妇| 91猫先生在线| 欧美人狂配大交3d怪物一区| 91精品久久久久久久91蜜桃| 波多野结衣视频一区| 99精品热视频| 欧美性猛交一区二区三区精品| 欧美日韩一区二区三区在线| 日韩一区二区在线观看视频| 一色桃子久久精品亚洲| 高清成人在线观看| 日韩美女精品在线| 成人免费av在线| 欧美日韩国产首页| 热久久久久久久| 日韩欧美电影在线| 国产经典欧美精品| 亚洲桃色在线一区| 欧美日韩日日夜夜| 麻豆高清免费国产一区| 国产区在线观看成人精品| 国产suv精品一区二区6| 午夜a成v人精品| 日本一区二区三区电影| 91色.com| 国产一区二区三区黄视频| 久久亚区不卡日本| 在线观看亚洲a| 激情深爱一区二区| 亚洲少妇中出一区| 国产婷婷精品av在线| 欧美日韩高清一区二区三区| 国产乱码精品一区二区三区忘忧草| 亚洲激情图片qvod| 亚洲欧美综合色| 久久久亚洲高清| 日韩一区二区不卡| 欧美在线不卡视频| 欧美男同性恋视频网站| 国产呦萝稀缺另类资源| 天天色天天爱天天射综合| 中文字幕综合网| 国产欧美精品国产国产专区| 精品美女一区二区| 欧美一区二区三区播放老司机| 不卡一二三区首页| 国产成人自拍网| jvid福利写真一区二区三区| 国产成人一级电影| 国产精品亚洲专一区二区三区 | 成人一区二区三区视频| 亚洲福利视频一区| 亚洲成人精品影院| 免费视频最近日韩| 久久99九九99精品| 国产成人精品午夜视频免费| 久久99深爱久久99精品| 国产制服丝袜一区| 国产麻豆91精品| 在线免费观看日本欧美| 国产成人精品网址| 在线免费观看视频一区| 日韩亚洲欧美中文三级| 国产精品福利一区| 精品一区二区三区在线观看国产 | 欧美国产97人人爽人人喊| 亚洲超丰满肉感bbw| 国产成人综合在线| 欧美日韩国产一二三| 亚洲欧洲精品一区二区精品久久久| 亚洲福利电影网| 色综合中文字幕国产 | 天堂蜜桃一区二区三区| 成人久久18免费网站麻豆| 日韩欧美国产成人一区二区| 正在播放一区二区| 亚洲国产精品传媒在线观看| 国产精品中文欧美| 91在线观看视频| 欧美日韩高清一区二区| 欧美日韩美女一区二区| 欧美第一区第二区| 亚洲你懂的在线视频| 亚洲一区二区三区四区五区中文| 国产成人av资源| 久久久美女艺术照精彩视频福利播放| 国产人伦精品一区二区| 久久99九九99精品| 久久婷婷一区二区三区| 国产一区二区三区在线观看免费| 日韩精品专区在线影院重磅| 精品在线亚洲视频| 国产欧美日韩另类一区| 97久久人人超碰| 亚洲成人激情社区| 欧美tickling挠脚心丨vk| 久久97超碰国产精品超碰| 中文字幕巨乱亚洲| 欧美美女直播网站| 国产老肥熟一区二区三区| 中文成人综合网| 欧美网站大全在线观看| 久久99九九99精品| 亚洲天堂a在线| 日韩精品一区二区三区中文精品 | 中文字幕五月欧美| 日本电影亚洲天堂一区| 精品一区二区影视| 日韩av网站在线观看| 中文字幕乱码一区二区免费| 色老头久久综合| 懂色av中文字幕一区二区三区| 午夜视频一区二区三区| 国产精品午夜春色av| 久久久久99精品一区| 4438x成人网最大色成网站| aa级大片欧美| 不卡一区二区在线| 成人av高清在线| aaa欧美日韩| 在线免费不卡电影| 欧美羞羞免费网站|