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

📄 commswitch.h

📁 此程序为DP256的SPI实验程序,已经通过实验证明
💻 H
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************************
*							Commbo Switch Module of LIN system
*Orginator:	Wang junpeng
*Date:		31th, May, 2005
*Basic Function: Sample Commbo switch signal, and transfered through LIN Bus.
*Integrated with LINDriver_Slave:
*1. Add LIN Transceiver chip Enable Control, this is defined in LIN_Defines.h
*
*
*
*
*
********************************************************************************************
*/
#ifndef __COMMSWITCH_H__
#define __COMMSWITCH_H__

#ifdef COMMBOSWITCH_GLOBALS
    #define COMMBOSWITCH_EXT
#else
    #define COMMBOSWITCH_EXT extern
#endif

#define MC33993_INT_EN			INTKBIER_KBIE2
//Constant definations
#define MC33993_CMD_INDEX		0
#define MC33993_DATA_LOW		2
#define MC33993_DATA_HIGH		1

//MC33993 Channel usable selection
#define MC33993_SP0_EN			0
#define MC33993_SP1_EN			0
#define MC33993_SP2_EN			0
#define MC33993_SP3_EN			0
#define MC33993_SP4_EN			0
#define MC33993_SP5_EN			0
#define MC33993_SP6_EN			0
#define MC33993_SP7_EN			0

#define MC33993_SG0_EN			1
#define MC33993_SG1_EN			1
#define MC33993_SG2_EN			1
#define MC33993_SG3_EN			1
#define MC33993_SG4_EN			1
#define MC33993_SG5_EN			1
#define MC33993_SG6_EN			0
#define MC33993_SG7_EN			0
#define MC33993_SG8_EN			1
#define MC33993_SG9_EN			1
#define MC33993_SG10_EN			1
#define MC33993_SG11_EN			0
#define MC33993_SG12_EN			0
#define MC33993_SG13_EN			0


#define MC33993_CMD_SETTING		1
#define MC33993_CMD_SP_INT		2
#define MC33993_CMD_SG_INT		3
#define MC33993_CMD_SP_META		4
#define MC33993_CMD_SG_META		5
#define MC33993_CMD_AN			6
#define MC33993_CMD_SP_WET		7
#define MC33993_CMD_SG_WET		8
#define MC33993_CMD_SP_TRI		9
#define MC33993_CMD_SG_TRI		10
#define MC33993_CMD_CALIBRATION	11
#define MC33993_CMD_RESET		0x7F
#define MC33993_CMD_SLEEP		12
#define MC33993_CMD_TEST		0x80

//Default: SPx used as high side input switch
#define MC33993_SP0_HS			1
#define MC33993_SP1_HS			1
#define MC33993_SP2_HS			1
#define MC33993_SP3_HS			1
#define MC33993_SP4_HS			1
#define MC33993_SP5_HS			1
#define MC33993_SP6_HS			1
#define MC33993_SP7_HS			1

#define MC33993_SP0				MC33993_SP0_HS
#define MC33993_SP1				(MC33993_SP1_HS << 1)
#define MC33993_SP2				(MC33993_SP2_HS << 2)
#define MC33993_SP3				(MC33993_SP3_HS << 3)
#define MC33993_SP4				(MC33993_SP4_HS << 4)
#define MC33993_SP5				(MC33993_SP5_HS << 5)
#define MC33993_SP6				(MC33993_SP6_HS << 6)
#define MC33993_SP7				(MC33993_SP7_HS << 7)

//SPX WAKEUP/INTERRUPTS COMMAND
#define MC33993_SP0_INT			MC33993_SP0_EN
#define MC33993_SP1_INT			(MC33993_SP1_EN << 1)
#define MC33993_SP2_INT			(MC33993_SP2_EN << 2)
#define MC33993_SP3_INT			(MC33993_SP3_EN << 3)
#define MC33993_SP4_INT			(MC33993_SP4_EN << 4)
#define MC33993_SP5_INT			(MC33993_SP5_EN << 5)
#define MC33993_SP6_INT			(MC33993_SP6_EN << 6)
#define MC33993_SP7_INT			(MC33993_SP7_EN << 7)

//SGX WAKEUP/INTERRUPTS COMMAND
#define MC33993_SG0_INT			MC33993_SG0_EN
#define MC33993_SG1_INT			(MC33993_SG1_EN << 1)
#define MC33993_SG2_INT			(MC33993_SG2_EN << 2)
#define MC33993_SG3_INT			(MC33993_SG3_EN << 3)
#define MC33993_SG4_INT			(MC33993_SG4_EN << 4)
#define MC33993_SG5_INT			(MC33993_SG5_EN << 5)
#define MC33993_SG6_INT			(MC33993_SG6_EN << 6)
#define MC33993_SG7_INT			(MC33993_SG7_EN << 7)
#define MC33993_SG8_INT			(MC33993_SG8_EN << 0)
#define MC33993_SG9_INT			(MC33993_SG9_EN << 1)
#define MC33993_SG10_INT		(MC33993_SG10_EN << 2)
#define MC33993_SG11_INT		(MC33993_SG11_EN << 3)
#define MC33993_SG12_INT		(MC33993_SG12_EN << 4)
#define MC33993_SG13_INT		(MC33993_SG13_EN << 5)

//SPX Metallic COMMAND
#define MC33993_SP0_META		MC33993_SP0_EN
#define MC33993_SP1_META		(MC33993_SP1_EN << 1)
#define MC33993_SP2_META		(MC33993_SP2_EN << 2)
#define MC33993_SP3_META		(MC33993_SP3_EN << 3)
#define MC33993_SP4_META		(MC33993_SP4_EN << 4)
#define MC33993_SP5_META		(MC33993_SP5_EN << 5)
#define MC33993_SP6_META		(MC33993_SP6_EN << 6)
#define MC33993_SP7_META		(MC33993_SP7_EN << 7)

//SGX Metallic COMMAND
#define MC33993_SG0_META		MC33993_SG0_EN
#define MC33993_SG1_META		(MC33993_SG1_EN << 1)
#define MC33993_SG2_META		(MC33993_SG2_EN << 2)
#define MC33993_SG3_META		(MC33993_SG3_EN << 3)
#define MC33993_SG4_META		(MC33993_SG4_EN << 4)
#define MC33993_SG5_META		(MC33993_SG5_EN << 5)
#define MC33993_SG6_META		(MC33993_SG6_EN << 6)
#define MC33993_SG7_META		(MC33993_SG7_EN << 7)
#define MC33993_SG8_META		(MC33993_SG8_EN << 0)
#define MC33993_SG9_META		(MC33993_SG9_EN << 1)
#define MC33993_SG10_META		(MC33993_SG10_EN << 2)
#define MC33993_SG11_META		(MC33993_SG11_EN << 3)
#define MC33993_SG12_META		(MC33993_SG12_EN << 4)
#define MC33993_SG13_META		(MC33993_SG13_EN << 5)


//SPX Wetinng Current COMMAND
#define MC33993_SP0_WET			MC33993_SP0_EN
#define MC33993_SP1_WET			(MC33993_SP1_EN << 1)
#define MC33993_SP2_WET			(MC33993_SP2_EN << 2)
#define MC33993_SP3_WET			(MC33993_SP3_EN << 3)
#define MC33993_SP4_WET			(MC33993_SP4_EN << 4)
#define MC33993_SP5_WET			(MC33993_SP5_EN << 5)
#define MC33993_SP6_WET			(MC33993_SP6_EN << 6)
#define MC33993_SP7_WET			(MC33993_SP7_EN << 7)

//SGX Wetting Current COMMAND
#define MC33993_SG0_WET			MC33993_SG0_EN
#define MC33993_SG1_WET			(MC33993_SG1_EN << 1)
#define MC33993_SG2_WET			(MC33993_SG2_EN << 2)
#define MC33993_SG3_WET			(MC33993_SG3_EN << 3)
#define MC33993_SG4_WET			(MC33993_SG4_EN << 4)
#define MC33993_SG5_WET			(MC33993_SG5_EN << 5)
#define MC33993_SG6_WET			(MC33993_SG6_EN << 6)
#define MC33993_SG7_WET			(MC33993_SG7_EN << 7)
#define MC33993_SG8_WET			(MC33993_SG8_EN << 0)
#define MC33993_SG9_WET			(MC33993_SG9_EN << 1)
#define MC33993_SG10_WET		(MC33993_SG10_EN << 2)
#define MC33993_SG11_WET		(MC33993_SG11_EN << 3)
#define MC33993_SG12_WET		(MC33993_SG12_EN << 4)
#define MC33993_SG13_WET		(MC33993_SG13_EN << 5)


//SPX Tri-State COMMAND
#define MC33993_SP0_TRI			MC33993_SP0_EN
#define MC33993_SP1_TRI			(MC33993_SP1_EN << 1)
#define MC33993_SP2_TRI			(MC33993_SP2_EN << 2)
#define MC33993_SP3_TRI			(MC33993_SP3_EN << 3)
#define MC33993_SP4_TRI			(MC33993_SP4_EN << 4)
#define MC33993_SP5_TRI			(MC33993_SP5_EN << 5)
#define MC33993_SP6_TRI			(MC33993_SP6_EN << 6)
#define MC33993_SP7_TRI			(MC33993_SP7_EN << 7)

//SGX Tri-State COMMAND
#define MC33993_SG0_TRI			MC33993_SG0_EN
#define MC33993_SG1_TRI			(MC33993_SG1_EN << 1)
#define MC33993_SG2_TRI			(MC33993_SG2_EN << 2)
#define MC33993_SG3_TRI			(MC33993_SG3_EN << 3)
#define MC33993_SG4_TRI			(MC33993_SG4_EN << 4)
#define MC33993_SG5_TRI			(MC33993_SG5_EN << 5)
#define MC33993_SG6_TRI			(MC33993_SG6_EN << 6)
#define MC33993_SG7_TRI			(MC33993_SG7_EN << 7)
#define MC33993_SG8_TRI			(MC33993_SG8_EN << 0)
#define MC33993_SG9_TRI			(MC33993_SG9_EN << 1)
#define MC33993_SG10_TRI		(MC33993_SG10_EN << 2)
#define MC33993_SG11_TRI		(MC33993_SG11_EN << 3)
#define MC33993_SG12_TRI		(MC33993_SG12_EN << 4)
#define MC33993_SG13_TRI		(MC33993_SG13_EN << 5)

//Analog COMMAND
#define MC33993_SG0_AN		1
#define MC33993_SG1_AN		2
#define MC33993_SG2_AN		3
#define MC33993_SG3_AN		4
#define MC33993_SG4_AN		5
#define MC33993_SG5_AN		6
#define MC33993_SG6_AN		7
#define MC33993_SG7_AN		8
#define MC33993_SG8_AN		9
#define MC33993_SG9_AN		10
#define MC33993_SG10_AN		11
#define MC33993_SG11_AN		12
#define MC33993_SG12_AN		13
#define MC33993_SG13_AN		14
#define MC33993_SP0_AN		15
#define MC33993_SP1_AN		16
#define MC33993_SP2_AN		17
#define MC33993_SP3_AN		18
#define MC33993_SP4_AN		19
#define MC33993_SP5_AN		20
#define MC33993_SP6_AN		21
#define MC33993_SP7_AN		22

//Sleep Command
#define MC33993_INT_PERIOD_32	0
#define MC33993_INT_PERIOD_64	(1 << 3)
#define MC33993_INT_PERIOD_128	(2 << 3)
#define MC33993_INT_PERIOD_256	(3 << 3)
#define MC33993_INT_PERIOD_512	(4 << 3)
#define MC33993_INT_PERIOD_1024	(5 << 3)
#define MC33993_INT_PERIOD_2048	(6 << 3)
#define MC33993_INT_PERIOD_4096	(7 << 3)

#define MC33993_SCAN_PERIOD_NONE	0
#define MC33993_SCAN_PERIOD_1		1
#define MC33993_SCAN_PERIOD_2		2
#define MC33993_SCAN_PERIOD_4		3
#define MC33993_SCAN_PERIOD_8		4
#define MC33993_SCAN_PERIOD_16		5
#define MC33993_SCAN_PERIOD_32		6
#define MC33993_SCAN_PERIOD_64		7

#define CMBSWT_SP0					0x40
#define CMBSWT_SP1					0x80
#define CMBSWT_SP2					0x01
#define CMBSWT_SP3					0x02
#define CMBSWT_SP4					0x04
#define CMBSWT_SP5					0x08
#define CMBSWT_SP6					0x10
#define CMBSWT_SP7					0x20
#define	MC33992_INT_FLAG			0x40
#define MC33993_THEM_FLAG			0x80


#define CMBSWT_BRUSH1				MC33993_SG0_EN
#define CMBSWT_BRUSH2				(MC33993_SG1_EN << 1)
#define CMBSWT_BRUSH3				(MC33993_SG2_EN << 2)
#define CMBSWT_BRUSH4				(MC33993_SG3_EN << 3)
#define CMBSWT_BRUSH1_DATA			2
#define CMBSWT_BRUSH2_DATA			2
#define CMBSWT_BRUSH3_DATA			2
#define CMBSWT_BRUSH4_DATA			2

#define CMBSWT_TURNLEFT				(MC33993_SG4_EN << 4)
#define CMBSWT_TURNRIGHT			(MC33993_SG5_EN << 5)
#define CMBSWT_TURNLEFT_DATA		2
#define CMBSWT_TURNRIGHT_DATA		2

#define CMBSWT_LAMP1				MC33993_SG8_EN << 0
#define CMBSWT_LAMP2				(MC33993_SG9_EN << 1)
#define CMBSWT_LAMP3				(MC33993_SG10_EN << 2)
#define CMBSWT_LAMP1_DATA			1
#define CMBSWT_LAMP2_DATA			1
#define CMBSWT_LAMP3_DATA			1

#define CMBSWT_RESERVED				(MC33993_SG6_EN << 6)
#define CMBSWT_RESERVED_DATA		2

#define CMBSWT_STATE_OK				1
#define CMBSWT_STATE_ERR			2
#define CMBSWT_STATE_DEBOUNCE		4
#define CMBSWT_STATE_UNKNOWN		0x10
#define CMBSWT_ERR_MAX				3

#define BRUSH_CMD_INT	2
#define	BRUSH_CMD_LOW	3
#define	BRUSH_CMD_HIGH	4
#define BRUSH_CMD_STOP	0
#define BRUSH_CMD_ERROR	14

#define MC33993_ERR_MAX_COUNT		100

#define	MC33993_INIT_NONE			0
#define	MC33993_INIT_SGINT			1
#define	MC33993_INIT_SGMET			2
#define	MC33993_INIT_SGWET			3
#define	MC33993_INIT_SPINT			4
#define	MC33993_INIT_SPMET			5
#define	MC33993_INIT_SPWET			6

⌨️ 快捷键说明

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