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

📄 yampp2.c

📁 yampp的MP3资料 非常好大家来看一看
💻 C
📖 第 1 页 / 共 2 页
字号:


/*
  Copyright (C) 2000 Jesper Hansen <jesperh@telia.com>.

  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.
*/


/*

	Power requirements
	
	CPU	(@4MHz)			4/8 mA	(3.3V/5V)
	SRAM				90 mA (active, 20 mA stby)
	DAC					5/8 mA	(3.3V/5V)
	MAS					55 mA
	Other				10 mA
						------
	Total				150-170 mA

	Disk				450-500 mA
	
	Grand finale		600-700 mA				


	Measurements show about 200-250 mA standby (no disk powerdown), and
	about 470 mA playing.
	
*/



/*
	PIN assignements on test board
	
	PA0-PA7		data bus 0..7 + Address 0..7
	PC0-=C7		address 8..15	
	
	PB0		T0		DIOW
	PB1		T1		DIOR
	PB2		AIN0	DEMAND
	PB3		AIN1	I2CD		
	PB4		SS		I2CC
	PB5		MOSI	SID
	PB6		MISO 	(not available)
	PB7		SCK		SIC
	

	PD0		RxD		RS-232
	PD1		TxD		RS-232
	PD2		INT0	IR_INPUT
	PD3		INT1	
	PD4		T0		MAS_RESET + ATA_RESET
	PD5		T1		LCD_E
	PD6		WR		RD
	PD7		RD		WR	


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	MAS DEMAND PIN @ 8 MHz
	
	 	 ___				____
	____|	|______________|	|____________

		1.5 mS     11 mS

	SIC frequency = 2 MHz  ( Prescaler = fClk/4 )

	About 3 kBits are sent in each burst

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
*/


#include <io.h>
#include <progmem.h>

#include "uart.h"
#include "lcd.h"
#include "ata_if.h"
#include "delay.h"
#include "spi.h"
#include "i2c.h"
#include "fat.h"
#include "mas.h"
#include "dac.h"
#include "mem.h"

#include "rec80.h"



//#define HEXDUMP 1
//#define MAS_INFO 1


extern unsigned char *SectorBuffer;

#ifdef HEXDUMP

void HexDump( unsigned char *buffer, int len ) 
{
    int i,j,k = 0;

    EOL();
    for(i=0;i<len/16;i++,k+=16)
    {
        UART_Printfu16(k);	
        UART_SendByte(' ');
        for(j=0;j<16;j++)
        {
            UART_Printfu08(buffer[i*16+j]);	
            UART_SendByte(' ');
        }
        PRINT("    ");
        for(j=0;j<16;j++)
        {
            if (buffer[i*16+j] >= 0x20)
                UART_SendByte(buffer[i*16+j]);
            else
                UART_SendByte('.');
        }
        EOL();
    }

}

void sectordump(unsigned long sector)
{
	ATA_Read_Sectors_LBA(DRIVE0,sector,1,SectorBuffer);
	UART_Printfu32(sector);
	HexDump(SectorBuffer, 512);
}

#endif


unsigned int scroll_length;
unsigned int scroll_pos = 0;
unsigned char scroll_flag = 0;
unsigned char time_flag = 0;
char * scroll_line;


int isPlaying = 0;
unsigned char * outptr;

unsigned char *buffer1;
unsigned char *buffer2;
unsigned char *buffer3;
unsigned char *buffer4;


unsigned char *i2cdata;

unsigned long mycluster;


extern unsigned int  Sectors_Per_Cluster;

unsigned long lbasector = 0;
unsigned long temp;
unsigned char *updbuf;


typedef enum
{	
	EV_IDLE,
	EV_RESET,
	EV_PLAY,
	EV_STOP,
	EV_NEXT,
	EV_PREV,
	EV_VOLUP,
	EV_VOLDN,
	EV_BASSUP,
	EV_BASSDN,
	EV_TREBUP,
	EV_TREBDN,
	EV_NEUTRAL,
	EV_MUTE,
	EV_LASTEVENT	
} event_e;	


event_e get_char_event(void)
{
	unsigned char c;
	
	switch ((c = UART_ReceiveByte())) 
    {
      	case 'H' : return EV_RESET;
//				case 'r' : ATA_SW_Reset(); break;

#ifdef HEXDUMP
		case '0' : case '1' : case '2' : case '3' : case '4' : 				
		case '5' : case '6' : case '7' : case '8' : case '9' :
			temp = temp*10 + c-'0';
			break;
			
		case 0x0d :
			lbasector = temp;
			temp = 0;
			break;

		case '+':
			sectordump(++lbasector);
			break;	      		
		case '-':
			sectordump(--lbasector);
			break;	      		
#endif
		
/*		      	case 'R': 	
      		ShowRegisters(DRIVE0); 
      		break;
*/

		case 'V' : return EV_VOLUP;
		case 'v' : return EV_VOLDN;
//		case 'B' : return EV_BASSUP;
//		case 'b' : return EV_BASSDN;
//		case 'T' : return EV_TREBUP;
//		case 't' : return EV_TREBDN;
		case 'N' : return EV_NEUTRAL;
		case 'm' : return EV_MUTE;
		

		case 'p' : return EV_PREV;
		case 'n' : return EV_NEXT;
		case 'g' : return EV_PLAY;
		case 'G' : return EV_STOP;
		default:   return EV_IDLE;
    }
}

event_e ir_event(void)
{
	switch (get_rec80())
	{
		default:
		case 0: return EV_IDLE;
		case IR_PLAY: return EV_PLAY;
		case IR_STOP: return EV_STOP;
		case IR_PREV: return EV_PREV;
		case IR_NEXT: return EV_NEXT;
		case IR_RESET: return EV_RESET;
		case IR_VOLUP: return EV_VOLUP;
		case IR_VOLDN: return EV_VOLDN;
	}
}


#ifdef MAS_INFO

void mas_info(void)
{
    // request some MAS chip info
    i2c_send(0x3a,0x68, 6, "\xf0\x00\x00\x0a\x0f\xf6");		// ???
    delay(1000);
    i2c_receive(0x3a,0x69, 40, i2cdata );
	
    EOL();

    a1  = (ULONG) i2cdata[3] << 16;
    a1 += (ULONG) i2cdata[0] << 8;
    a1 += (ULONG) i2cdata[1];

    PRINT("MAS Version: ");
    UART_Printfu32(a1);
    EOL();

    a1  = (ULONG) i2cdata[7] << 16;
    a1 += (ULONG) i2cdata[4] << 8;
    a1 += (ULONG) i2cdata[5];

    PRINT("Design code: ");
    UART_Printfu32(a1);
    EOL();

    a1  = (ULONG) i2cdata[11] << 16;
    a1 += (ULONG) i2cdata[8] << 8;
    a1 += (ULONG) i2cdata[9];

    PRINT("Date: ");
    UART_Printfu32(a1);
    EOL();

    for (i=12;i<40;i+=4)
    {
    	UART_SendByte(i2cdata[i]);
    	UART_SendByte(i2cdata[i+1]);
	}
    EOL();
}

#endif

// these table values needs to be shifted 
// left 8 bits before use
/*prog_int ROM_bass_table[31] = {
0x618, 	// +15 dB
0x5d4,
0x588,
0x538,
0x4e4,
0x488,
0x428,
0x3c0,
0x358,
0x2e4,
0x270,
0x1f8,
0x17c,
0x100,
0x008, // ?? very low value
0x0,	// 0 dB
0xf7c,
0xefc,
0xe80,
0xe04,
0xd8c,
0xd18,
0xca4,
0xc3c,
0xbd4,
0xb74,
0xb18,
0xac4,
0xa74,
0xa28,
0x9e4 };	// -15 dB

prog_int ROM_treb_table[31] = {
0x5f8,	// +15 dB
0x584,	
0x518,
0x49c,
0x3c2,
0x354,
0x2ec,
0x284,
0x220,
0x1c0,
0x160,
0x104,
0x0ac,
0x054,
0x0,	// 0 dB
0xfac,
0xf5c,
0xf0c,
0xec0,
0xe7e,
0xe28,
0xde0,
0xd98,
0xd50,
0xd04,
0xcbc,
0xc6c,
0xc18,
0xbb4,
0xb2c }; // -15 dB
*/
/*
unsigned int prescaler_table[15] = {
0xe94, 	// +15 dB
0xe68,	// +14 dB
0xe34,
0xdfc,
0xdc0,
0xd78,
0xd25, // really should be 0xd25c !!
0xcd0,
0xc6c,
0xbfc,
0xb80,
0xaf4,
0xa58,
0x9a4,
0x8e0 };// +1 dB
*/

/*
unsigned int *tonetable;
unsigned int *bass_table;
unsigned int *treb_table;
*/



//----------------------------------------------------------------------------
// Main part
//----------------------------------------------------------------------------

⌨️ 快捷键说明

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