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

📄 mineon.bak

📁 image capture billing control system
💻 BAK
字号:
/*
	8MB disable
*/

#include <reg52.h>
#include <DEF.H>

void Delay(Dword j)
{
	Dword i;
	for( i=0 ; i<j ; i++ );
}

void Delay_10us(Byte time)
{
// one loop = 6 instruction = 6*0.25us = 1.5us
	Byte i, j;

	for(j=0 ; j<time ; j++)
	{
		for(i=0 ; i<6 ; i++);	// 6*1.5 = 9	// 9 + etc = approx. 10
	}
}

/*
void Delay_Sec(Byte sec)
{
// 66 machine cycle
// 1 machine cycle = 0.25us
// 66*0.25
// 33*3 = 100us = 0.1ms
// 1sec = 0.25us * 4000000 = 0.25us * (66*60606)
	Byte i;
	for(i=0 ; i<sec ; i++) Delay(50000);
}
*/

#define	TIME1	(65535-20000)	// 10ms

void Init_Timer1()
{
	TMOD &= 0x0f;
	TMOD |= 0x10;	// b'xxxx0001' : Timer1 = mode1, 16-bit timer
}

void Delay_10ms(Byte time)
{
// 1/24MHz * 6 x 40000 = 10ms
	Init_Timer1();

	while(time)
	{
		TH1 = TIME1/256;
		TL1 = TIME1%256;
		TF1=0;
		TR1=1;
		while(!TF1);
		TR1=0;
		time--;
	}
}

void Delay_100ms(Byte time)
{
	Init_Timer1();

	while(time)
	{
		Delay_10ms(10);
		time--;
	}
}

void Delay_Sec(Byte time)
{
	Init_Timer1();

	while(time)
	{
		Delay_10ms(100);
		time--;
	}
}

void Yellow_On()
{
	Green_On();
	Red_On();
}

void Yellow_Off()
{
	Green_Off();
	Red_Off();
}

void Red_Light(Byte x, Byte delay)
{
	Yellow_Off();
	Delay_100ms(delay);
	while(x)
	{
		Red_On();
		Delay_100ms(delay);
		Red_Off();	
		Delay_100ms(delay);
		x--;
	}
}

void Green_Light(Byte x, Byte delay)
{
	Yellow_Off();
	Delay_100ms(delay);
	while(x)
	{
		Green_On();
		Delay_100ms(delay);
		Green_Off();	
		Delay_100ms(delay);
		x--;
	}
}

void Yellow_Light(Byte x, Byte delay)
{
	Yellow_Off();
	Delay_100ms(delay);
	while(x!=0)
	{
		Yellow_On();
		Delay_100ms(delay);
		Yellow_Off();
		Delay_100ms(delay);
		x--;
	}
}


/*
Word Byte2Word(Byte a, Byte b)
{
	return(a*0x100 + b);
}
*/

/*
Dword Byte2Dword(Byte a, Byte b, Byte c, Byte d)
//Dword Byte2Dword(Dword a, Dword b, Dword c, Dword d)
{
//	return((a<<24) + (b<<16) + (c<<8) + d);
	return(a*0x1000000 + b*0x10000 + c*0x100 + d);
}
*/
/*
Dword Square( Word x, Byte y )
{
	Byte i;
	Dword z;

	z = 1;
	for( i=0 ; i<y ; i++)
	{
		z = z*x;
	}
	return(z);
}
*/
/*
Byte Dword2Byte(Dword x, Byte i)
{
	Byte y;
	y = x/Square(0x100, i);
	return(y);
}
*/
#include <mmu.c>
#include <smc.c>
#include <iic.c>

void Timer0_Start(Word);
void Start_Power_Off_Time()
{
//	Timer0_Start(100*60*AUTO_OFF_TIME);
	Timer0_Start(100*10);
	Power_Off_Time = 1;
}

#include <command.c>
void Power_Off()
{
	Volume_Mute();

	MMU_Reset();
	DMA_Mode_Off();

	Flash_Mem_Read(0,0);

	if(Flash_Mem_Erase(0))
	{
		Write_MMU(1, Volume);
		Write_MMU(2, EQ_Mode);

		Flash_Mem_Write(0, 0);
	}

//	VDD_Off();

//	Yellow_On();
//	Red_Light(2,2);
	WSEN_Off();
	DCEN_Off();
	Power_Down();
}

void Battery_Check()
{
/*
	if(USB_Checked)
	{
		if(USB_Connected) return;
	}
	else
	{
		if(!USB_Connected) USB_Checked=1;
	}
*/
//	return;
	if(USB_Connected)
	{
		Power_Off_Time=0;
		return;
	}
	else
	{
		BIM_Refreshed=0;
		SMC_Refreshed=0;
	}

	if(~BAT_Check)
	{
		Red_Light(3,2);
		Power_Off();
	}
}

void Power_Check()
{
	Byte i;

	if(DCEN_Check == 0 )
	{
		for( i=0 ; i<20 ; i++)
		{
			if(DCEN_Check == 1) return;
		}

		Red_Light(1,2);
		Power_Off();
/*
CHECK_AGAIN:
			while(!DCEN_Check)
			{
//				Red_Light(1,1);
//				Delay_100ms(9);
			}

			for( i=0 ; i<100 ; i++)
			{
				if(DCEN_Check == 0) goto CHECK_AGAIN;
			}

			goto MAIN_START;
*/
	}
}

#include <key.c>
#include <usb.c>
//#include <adc.c>


/*
#define	TIME1	(65535-40000)
Bit Time_Err;
Word Time1;

void Timer1_Start()
{
// 1/4 x 40000 = 10ms
	TMOD &= 0x0f;
	TMOD |= 0x10;	// b'0001xxxx' : Timer1 = mode1, 16-bit counter
	TH1 = TIME1/256;
	TL1 = TIME1%256;
	Time1 = 0;
	TR1 = 1;	// Timer0 start
	ET1 = 1;	// Timer0 interrupt enable
}

IntTimer1()	interrupt	3
{
	Time1++;
	if(Time1 == 20)	// 10ms x 50 = 0.5sec
	{
		Time1 = 0;
		TH1 = TIME1/256;
		TL1 = TIME1%256;

		if(Memory==1)
		{
			P10=0;
			return;
		}
		if(P10) {P10=0;} else {P10=1;}
//		ET1 = 0;	// Timer0 interrupt disable
//		return;
	}
}
*/
void Next_Block_Search(Byte turn)
{
	Byte i;

	for(i=0 ; i<turn ; i++)
	{
		Play_Block = FAT_Read(Play_Block, NEXT_CHECK_LOCATION);
		Total_Played_Blocks ++;

		if( (Play_Block==LAST_BLOCK) || (Play_Block>=Current_Flash_Mem_Blocks) )
		{
			Volume_Mute();
			File_Num_Inc();
			Play_Cnt=0;
			Play_Block = File_Start_Block;
			Total_Played_Blocks = 0;
			return;
		}
	}
}

void Prev_Block_Search(Byte turn)
{
	Byte i;

	for(i=0 ; i<turn ; i++)
	{
		Play_Block = FAT_Read(Play_Block, PREV_CHECK_LOCATION);
		Total_Played_Blocks --;

		if( (Play_Block==START_BLOCK) || (Play_Block>=Current_Flash_Mem_Blocks) )
		{
			Volume_Mute();
			File_Num_Dec();
			Play_Cnt=0;
			Play_Block = File_Last_Block;
			Total_Played_Blocks = File_Blocks-1;
			return;
		}
	}
}

void Poll_Status()
{

	if(Hold)Yellow_On();
	else	Yellow_Off();

	switch (SystemStatus)
	{
		case STATUS_STOP:
			Red_On();

			break;

		case STATUS_PLAY:
			Green_On();

			if(mmu_swappable)
			{
				if(Play_Cnt < 5)
				{
					Play_Cnt++;
				}
				else if(Play_Cnt == 5)
				{
					Play_Cnt++;
					Volume_Adj();
				}

				if(Play_Page == 32)
				{
					Play_Page = 0;
					if(RW_Enable|FF_Enable) 
					{
						Volume_Mute();
						if(RW_Enable) Prev_Block_Search(10);	// case 128kbps : 1 sec = 1 block
						else Next_Block_Search(10);
						Status_Change(STATUS_PLAY);
					}
					else
					{
						Error = 0;
						Next_Block_Search(1);
						if(Error) return;
						MMU_Reset();
					}

				}

				if( (Play_Block == File_Last_Block)&&(Play_Page>=Last_Pages) )
				{
					Play_Page = 32;
					return;
				}

				Flash_Mem_Read(Play_Block, Play_Page);
				MP3_Enable();
				Play_Page++;
			}
			break;

		case STATUS_PAUSE:
			Red_On();

			break;

		case STATUS_DOWNLOAD:
			break;

		default:
			break;
	}
}

void main(void)
{
	Bit a=0;
	Byte i;

// Port Configuration
/*
	00 : Open Drain
	01 : High Impedance
	10 : Internal Pull-Up
	11 : Push Pull
*/

	P0CfgA	= 0xFF;
	P0CfgB	= 0x00;
	P1CfgA	= 0xFF;
	P1CfgB	= 0x00;

	P2CfgA	= 0xFF;
	P2CfgB	= 0x00;

//	P3CfgA	= 0xFF;
//	P3CfgB	= 0x00;
	P3CfgA	= 0xFF;	// b'11101111'
	P3CfgB	= 0x00;	// b'00000000'

//	Freq_Ctrl=0;
	Freq_12M();
	Delay_100ms(1);

	Yellow_Off();
	Power_Check();
	Battery_Check();
	Green_Light(1,2);

	smi_write_protect = 1;
	SMC_In_Out=0;

	Init_USB();
	Init_IIC();
	Init_EQ();
	Init_Key();

	Green_Light(1,2);

	Status_Change(STATUS_STOP);

	EX0 = 1;	// USB Interrupt enable
	EX1	= 1;	// SMC Interrupt enable

	EA = 1;	// Interrupt enable

	if(a)
	{
		i=i;
		Download_Byte();
		Delay_10us(1);
		Delay_100ms(3);
		Delay_Sec(1);
		Yellow_Light(1,3);
		Red_Light(1,1);
		Green_Light(1,1);
	}

	while(1)
	{
//		if(a){
		Power_Check();
		Battery_Check();
		SMC_In_Out_Check();

		Poll_USB();		// in usb.c
//		}
		Poll_Key();		// in key.c

		Poll_Status();	// in mineon.c
	}
}

⌨️ 快捷键说明

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