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

📄 d13ci.c

📁 基于菲利普USB接口芯片ISP1161A1从口的USB设备开发
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzhou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			D13CI.h
** Last modified Date:	2004-12-10
** Last Version:		V1.0
** Descriptions:		USB驱动程序软件包: ISP1181B(D13) 设备端驱动程序 协议层
**						Soft Packet of USB Driver: the Driver of Device of ISP1181B(D13) 
**												   Interface Control Layer
*******************************************************************************************************/

#include "config.h"
#include "D13Config.h"
#include "D13HAL.h"
#include "D13CI.h"
#include "Chap_9.h"

/*
*************************************************************************************************************
									 与CPU 无关, 与 USB 器件相关的函数
*************************************************************************************************************
*/
/************************************************************************************************************
** 函数名称: D13_ReadChipID()		  				Name:	  D13_ReadChipID()
** 功能描述: 读取ISP1181B芯片ID						Function: read ISP1181B ChipID
** 输   入: 无										Input:	  NULL
** 输   出: ISP1181B的ID号							Output:	  ISP1181B ChipID
*************************************************************************************************************/
INT16U D13_ReadChipID(void)
{
	INT16U chipid;
	
	outportc(D13CMD_DEV_RD_CHIPID);					//发送读ID号命令 	send the command of Read ChipID			
#if	D13_16BIT_EN 
	chipid = inportd();								//读ID号(16位) 		read the ChipID(16-bit)
#else 							
	chipid = inportd();								//读ID号的低字节	read the low byte of ChipID
	chipid = (INT16U)(inportd() << 8) + chipid;		//读ID号的高字节	read the upper byte of ChipID
#endif												//并组成16位

	return chipid;
}


/**************************************************************************************************************
** 函数名称: D13_SetEndpointConfig()				Name:	   D13_SetEndpointConfig()  
** 功能描述: 写端点配置寄存器						Function:  write the endpoint configuration register
** 输    入: INT8U bEPConfig: 配置值				Input:	   INT8U bEPConfig: the configuration value	  
		     INT8U bEPIndex:  端点索引号	  	  			   INT8U bEPIndex:  the index of the endppoint	
** 输   出: 无 									Output:    NULL
***************************************************************************************************************/
void D13_SetEndpointConfig(INT8U bEPConfig, INT8U bEPIndex)
{
	outportc(D13CMD_EP_WR_CNFG + bEPIndex);			//发送设置端点状态命令	send the command of set endpoint status
	outportd(bEPConfig);							//发送设置值			send the configuration value 
}

/***************************************************************************************************************
** 函数名称: D13_SetAddressEnable()					Name:	  D13_SetAddressEnable()	 
** 功能描述: 1. 设置地址   2. 使能设备				Function: 1.configure the address of device  2.enable device  
** 输   入: INT8U bAddress:  设备地址				Input:	  INT8U bAddress: the address of device 
	     	 INT8U bEnable :  0 --- 禁止					  INT8U bEnable : 0 --- disable		
	     		     		  1 --- 使能	     						      1 --- enable
** 输   出: 无										Output:	  NULL
****************************************************************************************************************/
void D13_SetAddressEnable(INT8U bAddress,INT8U bEnable)
{
	outportc(D13CMD_DEV_WR_ADDR);					//发送写地址寄存器命令   send the command of set address enable
 	if(bEnable)
		bAddress |= D13REG_DEVADDR_EN;				//使能设备地址			 enable address of device
    else
		bAddress &= D13REG_DEVADDR_MASK;			//禁止设备地址			 disable address of device
	outportd(bAddress);								//输出命令				 output command
}

/***************************************************************************************************************
** 函数名称: D13_SetMode()   						Name:	  D13_SetMode()
** 功能描述: 设置模式寄存器							Function: configure the mode register
** 输   入: INT8U bMode: 模式值					Input:	  INT8U bMode: the mode value
** 输   出: 无										Ouput:	  NULL
****************************************************************************************************************/
void D13_SetMode(INT8U bMode)
{
	outportc(D13CMD_DEV_WR_MODE);					//发送设置模式值命令		send the command of SetMode
	outportd(bMode);								//输出设置模式值			send the SetMode value
}

/****************************************************************************************************************
** 函数名称: D13_SetDevConfig()						Name:	  D13_SetDevConfig()
** 功能描述: 设置硬件配置寄存器						Function: configure the hardware configuration register
** 输   入: INT16U wDevCnfg: 设置值				Input:	  INT16U wDevCnfg: the configuration value	
** 输   出: 无										Output:	  NULL
*****************************************************************************************************************/
void D13_SetDevConfig(INT16U wDevCnfg)
{
	outportc(D13CMD_DEV_WR_CNFG);					//发送命令				    send command

#if D13_16BIT_EN
	outportd(wDevCnfg);								//输出配置值(16-bit)		output configuration value(16-bit)
#else
	outportd((INT8U)wDevCnfg);						//输出配置值(低字节)		output configuration value(lower byte)	
	outportd((INT8U)(wDevCnfg >> 8));				//输出配置值(高字节)		output configuration value(upper byte)
#endif
}

/*****************************************************************************************************************
** 函数名称: D13_SetIntEnable()						Name:	  D13_SetIntEnable()
** 功能描述: 设置中断使能寄存器值(4个字节)			Function: configure interrupt enable register
** 输   入: INT32U dIntEn:中断使能寄存器值			Input:    INT32U dIntEn: the value of the interrupt enable register
** 输   出: 无										Output:	  NULL
*****************************************************************************************************************/
void D13_SetIntEnable(INT32U dIntEn)
{
	outportc(D13CMD_DEV_WR_INTEN);					//发送命令				send command	

#if D13_16BIT_EN
	outportd((INT16U)dIntEn);						//输出使能值(低字)		output the Enable Value(lower word)
	outportd((INT16U)(dIntEn >> 16));				//输出使能值(高字)		output the Enable Value(upper word)	
#else
	outportd((INT8U)dIntEn);						//输出使能值(8-bit)		output the Enable Value(the lowest byte)
	outportd((INT8U)(dIntEn >> 8));	
	outportd((INT8U)(dIntEn >> 16));
	outportd((INT8U)0x0);
#endif
}

/*****************************************************************************************************************
** 函数名称: D13_SetDMAConfig()						Name:	  D13_SetDMAConfig()
** 功能描述: 设置DMA工作方式						Fuction:  configure the DMA mode
** 输   入: INT8U bMode: 设置值					Input:	  INT8U bMode:  the configuration value		
** 输   出: 无										Output:	  NULL
******************************************************************************************************************/
void D13_SetDMAConfig(INT16U wDMACnfg)
{
    outportc(D13CMD_DMA_WR_CNFG);					//发送设置DMA命令		send the command that configure DMA				
    		
#if D13_16BIT_EN    
    outportd(wDMACnfg);								//输出设置值(16位)		output configuration value				
#else
    outportd((INT8U)wDMACnfg);						//输出设置值低8位		output the lower byte of the configuration value
	outportd((INT8U)(wDMACnfg>>8));					//输出设置值高8位		output the upper byte of the configuration value
#endif
}

/******************************************************************************************************************
** 函数名称: D13_GetDMAConfig()	 					Name:	   D13_GetDMAConfig()
** 功能描述: 设置DMA计数寄存器

⌨️ 快捷键说明

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