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

📄 common.h

📁 威望公司MP3 + USB MCU 的参考软件
💻 H
字号:
/****************************************************************
*                      Viaon Technology (Suzhou) Co.,Ltd
*
*    Copyright 2007, Viaon Technology (Suzhou) Co.,Ltd,Suzhou,China
*                    All rights reserved.
*
*
* Filename:      	common.h
*
* Programmer:    	Greg
*
* Created: 	 	1/2/2008
*
* Description: 		public functions 
*              
*        
* Change History (most recent first):	2008.1.2
****************************************************************/
#ifndef __COMMON_H__
#define __COMMON_H__

#include "config.h"
#include "reg51.h"
#include "utiltypedef.h"
#include "libfatif.h"
#include "4010UI.h"

/*---------------------------------------------------------------------------------------------*/
/*------------------------------------------Definition--------------------------------------------*/
/*---------------------------------------------------------------------------------------------*/

#define  SD_DISK    					0
#define  USB_DISK    					1

#define SD_TEST						0
#define USB_TEST					1
#define DISK_TEST					USB_TEST	

#define FSMSTATE_IDLE				1
#define FSMSTATE_ATTACHED			2
#define FSMSTATE_INIT				3
#define FSMSTATE_USB				0x0f
#define FSMSTATE_SD				0xf0

#define SECT_LEN					512
#define BLKSIZE_512 					512
#define BLKSIZE_512_EXP     			9


#define MP3STATUS_IDLE				1
#define MP3STATUS_PLAY				2
#define MP3STATUS_PAUSE			3
#define MP3STATUS_WAKEUP			4

#define BUFFER_LENGTH				512

#define KEY_STATUS_PLAYMODE		0x00
#define KEY_STATUS_FM				0x01
#define KEY_STATUS_FM_DECREASE	0x02
#define KEY_STATUS_VOLUP			0x03
#define KEY_STATUS_VOLDOWN		0x04
#define KEY_STATUS_EQ				0x05

#define KEY_STATUS_FSEEK			0x06
#define KEY_STATUS_RSEEK			0x07
#define KEY_STATUS_JUMP			0x08
#define KEY_STATUS_PLAYPAUSE		0x09

//#define KEY_STATUS_DEVCHG			0x0a
#define KEY_STATUS_STOP			0x0a

#define KEY_STATUS_NOKEY			0xFF
#define KEY_STATUS_WITHDEV		KEY_STATUS_FSEEK	//The Key status big than this should be only executed with device.
#define KEY_STATUS_MAX				(KEY_STATUS_STOP + 1)


extern BYTE data keystatus;
extern BYTE data mp3status;
extern BYTE data FSMState;
typedef struct _XXG_FLAGS
{
//	unsigned char bTimer        :1;
	unsigned char bIN_ISR		:1;
//	unsigned char bCOM_ERR		:1;
//	unsigned char bTimeout		:1;
//	unsigned char bData1		:1;
//	unsigned char bUartInDone	:1;
//	unsigned char bMassDevice	:1;
	unsigned char bToggle       :1;

	//unsigned char SLAVE_IS_ATTACHED	:1;
	unsigned char SLAVE_REMOVED	:1;
	unsigned char SLAVE_FOUND	:1;	// Slave USB device found
//	unsigned char SLAVE_ENUMERATED	:1;	// slave USB device enumeration done
//	unsigned char SLAVE_ONLINE	:1;
	unsigned char SLAVE_STALLED     :1;
//	unsigned char TIMEOUT_ERR	:1; 	// timeout error during data endpoint transfer
	unsigned char DATA_STOP		:1;	// device unplugged during data transfer
} XXGFLAGS;

/*-------------------------------------------------------------------------------------------*/
/*-------------------------------------------API---------------------------------------------*/
/*-------------------------------------------------------------------------------------------*/
WORD WordSwap(WORD input);
void DelayMs(BYTE nFactor);
void DelayUs(BYTE nFactor);
DWORD SwapINT32(DWORD dData);
void memclr(void* a, WORD c);
BYTE memcomp(const BYTE* a, const BYTE* b, BYTE c);
void *memcopy(BYTE* a, const BYTE* b, BYTE c);
BYTE Value2Exp(WORD wVal);

#if (UART_DEBUG == UART_DEBUG_ENABLE)
void UartOutText(unsigned char *buffer);
void UartOutValue(unsigned long value, unsigned char length);
#else
#define UartOutText(x)
#define UartOutText1(x, y)
#define UartOutValue(x, y)
#endif

#endif //__COMMON_H__

⌨️ 快捷键说明

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