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

📄 lv24ekit.h

📁 LV24000的单片机DEMO程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// Lv24Ekit.h: project include file

//-----------------------------------------------------------------------------
// General include (for type definitions)
//-----------------------------------------------------------------------------
#include "LvErr.h"			// For error codes

//-----------------------------------------------------------------------------
// Code options
//-----------------------------------------------------------------------------
// ---- System clock
//#define	CF8MHZ
#define	CF12MHZ

//#define USE_LV2400x			// Select LV2400x code (FM)
#define USE_LV2410x				// Select LV2410x code (FM/AM)

#define USE_USB				// Enable USB code
#define USE_IRQSCRIPT		// Enable handling device IRQ through script, received from USB host
#define USE_PRESET			// Enable saving user' settings in LC87F1564 flash
#define USE_LCD				// Enable LCD code
#define USE_EXTCLK			// Enable measuring with external clock code

// ---- LV24-EVK hardware level
//#define PCB_L2			// LV24-EVK L2
#define PCB_L3				// LV24-EVK L3

// ---- Internal switches - don't modify them
#ifdef USE_LV2410x			// LV2410x
	#define SUPPORT_AMFM	// Enable AM code
#endif //USE_LV2410x
#ifndef SUPPORT_AMFM
	#define FM_ONLY
#endif //SUPPORT_AMFM

// LCD module (depend on PCB level and display enabling state)
#ifdef PCB_L2
#ifdef USE_LCD
	#define HITACHI_LCD		// Enable Hitachi-LCD code in lcd.c for PCB L2
#endif //USE_LCD
#endif //PCB_L2

#ifdef PCB_L3
#ifdef USE_LCD
	#define BOLYMIN_LCD		// Enable BOLYMIN_LCD in IIC_Lcd.c for PCB L3
#endif //USE_LCD
#endif //PCB_L3

#ifdef USE_EXTCLK
#define EXT_CLK_12MHZ	((DWORD)12000000)
#endif //USE_EXTCLK
//-----------------------------------------------------------------------------
// Firmware version
//-----------------------------------------------------------------------------
#define I3W_MAJ_VER	'0'		// Also modify the version string!!!
#define I3W_MIN_VER	'1'
#define I3W_SUB_VER	'4'
#define STR_VERSION	"V0.14"

#define STR_SIGNON1	"LV2400x Eval.Kit"
#define STR_SIGNON2	" Sanyo/ItoM"
#define STR_USBMODE	"USB mode "

//-----------------------------------------------------------------------------
// Delay time base on 8MHz main clock (tcyc=375ns)/12 MHz (tcyc=250ns) 
// with PRR is 1 (so 1 count is 2*tcyc=750ns for 8MHz/500ns for 12 MHz)
//-----------------------------------------------------------------------------
#ifdef CF8MHZ
// ----
#define LC8715XX_TCYC_NS	375	// ns, (SysClock=8MHz)

#define DLT_10us	13
#define DLT_40us	53
#define DLT_100us	133
#define DLT_1ms		1333
#define DLT_2ms		2666
#define DLT_5ms		6666 
#define DLT_15ms	20000
#define DLT_20ms	26666
// ----
#endif //CF8MHZ

#ifdef CF12MHZ
// ----
#define LC8715XX_TCYC_NS	250	// ns, (SysClock=12MHz)

#define DLT_10us	20
#define DLT_40us	80
#define DLT_100us	200
#define DLT_1ms		2000
#define DLT_2ms		4000
#define DLT_5ms		10000
#define DLT_15ms	30000
#define DLT_20ms	40000
// ----
#endif //CF12MHZ

//-----------------------------------------------------------------------------
// LC87F1564 GPIO Mapping for LV2400x Evaluation kit
//-----------------------------------------------------------------------------
// ----- 3-wire bus 1 -------
#define I3W_PORT			_P2		// Use GPIO port 2 to control the 3-wire bus
#define I3W_DIRPORT			_P2DDR	// Direction port (Use port A: 0 is input, 1 is output)

#ifdef PCB_L2
// ---- 3-wire on PCB-L2
#define I3W_CLK_PIN			7		// P2.7: clock pin (Output)
#define I3W_DATA_PIN		6		// P2.6: data pin (Bi-direction)
#define I3W_NRW_PIN			5		// P2.5: nRW pin   (Output)
// ----
#endif //PCB_L2

#ifdef PCB_L3
// ---- 3-wire on PCB-L3 
#define I3W_CLK_PIN			5		// P2.7: clock pin (Output)
#define I3W_DATA_PIN		6		// P2.6: data pin (Bi-direction)
#define I3W_NRW_PIN			7		// P2.5: nRW pin   (Output)
// ----
#endif //PCB_L3

#define I3W_CLK_PIN_BM		((BYTE)1<<I3W_CLK_PIN)
#define I3W_DATA_PIN_BM		((BYTE)1<<I3W_DATA_PIN)
#define I3W_NRW_PIN_BM		((BYTE)1<<I3W_NRW_PIN)

// ---- 3-wire bus 2  -------
#define I3W2_PORT			_P2		// Use GPIO port 2 to control the 3-wire bus
#define I3W2_DIRPORT		_P2DDR	// Direction port (Use port 2: 0 is input, 1 is output)

#define I3W2_CLK_PIN		3		// P2.3: clock pin (Output)
#define I3W2_DATA_PIN		2		// P2.2: data pin (Bi-direction)
#define I3W2_NRW_PIN		1		// P2.1: nRW pin   (Output)

#define I3W2_CLK_PIN_BM		((BYTE)1<<I3W2_CLK_PIN)
#define I3W2_DATA_PIN_BM	((BYTE)1<<I3W2_DATA_PIN)
#define I3W2_NRW_PIN_BM		((BYTE)1<<I3W2_NRW_PIN)

// ---- External RDS  -------
#define EXRDS_PORT			_P2		// Use GPIO port 2 to control the external RDS chip
#define EXRDS_DIRPORT		_P2DDR	// Direction port (Use port 2: 0 is input, 1 is output)

#define EXRDS_CLK_PIN		0		// P2.0: RDS clock pin (Input + Interrupt)
#define EXRDS_DATA_PIN		4		// P2.4: RDS data pin (Input)

#define EXRDS_CLK_PIN_BM	(1<<EXRDS_CLK_PIN)
#define EXRDS_DATA_PIN_BM	(1<<EXRDS_DATA_PIN)

// ---- LCD hardware config -----
#ifdef HITACHI_LCD
// ----
#define LCD_DATA_PORT	_P1		// Port for driving the LCD-Data
#define LCD_DDIR_PORT	_P1DDR	// Port for controlling the LCD-data direction (input/output)

#define LCD_DATAPIN_MASK 0xF0	// 4 bits LCD data D[7:4] at Port 1[7:4] (Bi-direction)

#define LCD_CONTROL_PORT _P1	// Port for driving the LCD-control signals
#define LCD_CDIR_PORT	_P1DDR	// Port for controlling the LCD-control direction (input/output)
#define LCD_E			3		// Port 1.3: E			(Output)
#define LCD_RW			2		// Port 1.2: RW			(Output)
#define LCD_RS			1		// Port 1.1: RS			(Output)
#define LCD_CONTRAST	0		// Port 1.0: Contrast	(Output)

#define LCD_CTRLPIN_MASK 0x0F	// 4 bits LCD control Port 1[3:0] (Output)
// ----
#endif //HITACHI_LCD

#ifdef BOLYMIN_LCD
// ----
#define LCD_I2C_ADDR_W	0x74	// I2C addess of LCD device for writing (bit 0=0)
#define LCD_I2C_ADDR_R	0x75	// I2C addess of LCD device for reading (bit 0=1)

// System IO
#define I2CLCD_IO_PORT	_P1		// Port for driving the I2C line of the LCD
#define I2CLCD_DIR_PORT	_P1DDR	// Port for controlling the LCD IO direction (input/output)

#define LCD_RST			1		// Port 1.1: Reset LCD	(Output)
#define I2C_SDA			2		// Port 1.2: SDA	(Output)
#define I2C_SCL			3		// Port 1.3: SCL	(Output)

#define LCD_CTRLPIN_MASK 0x0E	// 3 bits LCD control Port 1[3:0]
// ----
#endif //BOLYMIN_LCD

// ---- Keypad -------
#define KB_COLUMN_PORT		_P1	// Keyboard Column-port: P1[7:4] - Shared with LCD-Data - (Output - always low)
#define KB_ROW_PORT			_P7	// Keyboard Row-port: P7[3:0] - Input with pullup and interrupt

#define KB_COLUMN_MASK		0xF0	// Bit [7:4]
#define KB_COL_MASK_0		0x10	// Mask for column 0
#define KB_ROW_MASK			0x0F	// Bit [3:0]

//-----------------------------------------------------------------------------
// Macro's
//-----------------------------------------------------------------------------
#define LSB(x)				((BYTE)(x & 0xFF))
#define MSB(x)				((BYTE)(x >> 8))
#define MAKEWORD(byLo, byHi)( ((WORD)byHi<<8) | (byLo) )

#define Hz		1
#define KHz 	1000
#define MHz 	1000000
#define GHz 	1000000000

//-----------------------------------------------------------------------------
// Some type def
//-----------------------------------------------------------------------------
typedef BYTE (*FPTR_WRITE_OSC)(WORD wOscValue);	// Function pointer to be used by LinTuneDac

//-----------------------------------------------------------------------------
// Equations for Callback-function
//-----------------------------------------------------------------------------
// Callback reasons
#define CRSN_STN_CHNG		1	// Station (frequency, fieldstrength...) changed
#define CRSN_SCAN_UPD		2	// Update frequency during scanning
#define CRSN_ASCAN_FOUND 	3	// A station is found during auto scan
#define CRSN_FS_CHNG		4	// Field strength changed
#define CRSN_MS_CHNG		5	// Mono stereo state changed
#define CRSN_AFC_FAILED		6	// AFC failed

//-----------------------------------------------------------------------------
// Time constances used by CountPulse
//-----------------------------------------------------------------------------
#define LV_MSR_TIME_8ms			8000	// us
#define LV_MSR_TIME_32ms		32000	// us
#define LV_MSR_TIME_64ms		64000	// us
#define LV_MSR_TIME_100ms		100000	// us

//-----------------------------------------------------------------------------
// Precision level used by CalculateRfCapOsc
//-----------------------------------------------------------------------------
#define QSSF_PRECISION_NONE	0
#define QSSF_PRECISION_LOW	1
#define QSSF_PRECISION_MED	2
#define QSSF_PRECISION_HIGH	3

//-----------------------------------------------------------------------------
// Audio types used by AudioFeedback
//-----------------------------------------------------------------------------
#define AUDFB_TYPE1		((BYTE)1)	// Short key feedback
#define AUDFB_TYPE2		((BYTE)2)	// Long key feedback

//-----------------------------------------------------------------------------
// Radio default frequencies
//-----------------------------------------------------------------------------
#define DEFAULT_IF_FREQ			((WORD)11000)	// Default IF value (in 10Hz unit)
#define DEFAULT_SD_FREQ			((WORD)38000)	// Default SD value for V6

#ifdef USE_LV2410x				// LV2410x-ES1 default
#define DEFAULT_AM_IF_FREQ		((WORD)5000)	// Default IF value (in 10Hz unit)
#endif //USE_LV2410x
//-----------------------------------------------------------------------------
// Constances used by SetUpChipMode/GetOutputSelect/SetOutputSelect
//-----------------------------------------------------------------------------
// Equations for virtualizing chip output select (used by SetUpChipMode/GetOutputSelect)
// The whole Output config (WORD) is currently mapped as following:
// Bit [3:0]:	Clock source to be measured (CO_xxx)
// Bit [7:4]:	TBD
// Bit 8:		Want measuring mode 
// Bit 9:		TBD
// Bit 10:		Adjust AFC flag
// Bit 11:		AFC value to be set
// Bit 12:		Adjust chip measure mode flag
// Bit 13:		Chip measure state to be set
// Bit [14:15]:	TBD						NA
#define CO_SELECT_MASK			((WORD)0x0F<<0)			// Bit [3:0]: output select mask. Below outputs are defined:
														// Bit [7:4]: free
#define CHIP_MEASURE_MODE		(WORD)((WORD)1<<8)		// Bit 8: Measuring mode required if 1
														// Bit 9: free
#define CHIP_SET_AFC			(WORD)((WORD)1<<10)		// Bit 10: Adjust AFC mark
#define CHIP_AFC_STATE			(WORD)((WORD)1<<11)		// Bit 11: AFC state
	#define CHIP_AFC_ON			(WORD)(CHIP_SET_AFC|CHIP_AFC_STATE)	// Set AFC on
	#define CHIP_AFC_OFF		(WORD)(CHIP_SET_AFC|0)	// Set AFC off
#define CHR01_MSR_MODE_FLG		(WORD)((WORD)1<<12)		// Bit 12: chip measure mode change mark
#define CHR01_MSR_MODE_ON		(WORD)((WORD)1<<13)		// Bit 13: Chip measure mode bit is on if 1

⌨️ 快捷键说明

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