csl_usbhcaux.h

来自「dsp在音频处理中的运用」· C头文件 代码 · 共 842 行 · 第 1/2 页

H
842
字号
/**==========================================================================
 *   @file  csl_usbhcAux.h
 *
 *   @path  $(CSLPATH)\arm\usbhc\src
 *
 *   @desc  API Auxilary header file for USBHC CSL.
 *
  */

/*===========================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004
 *
 *   Use of this software is controlled by the terms and conditions found in the
 *   license agreement under which this software has been supplied.
 *===========================================================================
  */
 
/*  @(#) PSP/CSL 3.00.01.00[5912] (2004-06-22)   */

#ifndef _CSL_USBHC_AUX_H_
#define _CSL_USBHC_AUX_H_

#ifdef __cplusplus
extern "C" {
#endif

static inline
void
	CSL_usbhcIntrRouteEnable (
		/** Pointer to the object that holds reference to the
     	  * instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCCONTROL,USBHC_HCCONTROL_IR,ENABLE);
	return;
}

static inline
void
	CSL_usbhcIntrRouteDisable (
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCCONTROL,USBHC_HCCONTROL_IR,DISABLE);
	return;
}


static inline
void
	CSL_usbhcHcFuncStateSet(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_UsbhcFuncState*       cmdArg)
{
	CSL_FINS(hUsbhc->regs->HCCONTROL,USBHC_HCCONTROL_HCFS,*((CSL_UsbhcFuncState*)cmdArg));
}


static inline
void
	CSL_usbhcListEnable(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_BitMask16*           cmdArg)
{
	Uint32 _temp_reg;

	_temp_reg = hUsbhc->regs->HCCONTROL;
	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_BULK)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_BLE,ENABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_CTRL)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_CLE,ENABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_PER)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_PLE,ENABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_ISOCH)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_IE,ENABLE);
	hUsbhc->regs->HCCONTROL = _temp_reg;
}

static inline
void
	CSL_usbhcListDisable(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_BitMask16*            cmdArg)
{
	Uint32 _temp_reg;

	_temp_reg = hUsbhc->regs->HCCONTROL;
	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_BULK)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_BLE,DISABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_CTRL)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_CLE,DISABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_PER)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_PLE,DISABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_ISOCH)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_IE,DISABLE);
	hUsbhc->regs->HCCONTROL = _temp_reg;
}


static inline
void
	CSL_usbhcCtrlBulkRatioSet(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_UsbhcCtrlBulkRatio*       cmdArg)
{
	 CSL_FINS(hUsbhc->regs->HCCONTROL,USBHC_HCCONTROL_CBSR,*((CSL_UsbhcCtrlBulkRatio*)cmdArg));
}


static inline
void
	CSL_usbhcOwnershipReq(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCCOMMANDSTATUS,USBHC_HCCOMMANDSTATUS_OCR,ENABLE);
}

static inline
void
	CSL_usbhcListFill(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle         hUsbhc,
		/** Optional argument @a void* casted */
		CSL_BitMask16*       	cmdArg)
{
	Uint32 _temp_reg;

	_temp_reg = hUsbhc->regs->HCCOMMANDSTATUS;
	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_BULK)
	CSL_FINST(_temp_reg,USBHC_HCCOMMANDSTATUS_BLF,ENABLE);

	if ((*(CSL_BitMask16*)cmdArg) & CSL_USBHC_LIST_CTRL)
	CSL_FINST(_temp_reg,USBHC_HCCOMMANDSTATUS_CLF,ENABLE);
	hUsbhc->regs->HCCOMMANDSTATUS = _temp_reg;
}

static inline
void
	CSL_usbhcHcReset (
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCCOMMANDSTATUS,USBHC_HCCOMMANDSTATUS_HCR,RESET);
}


static inline
void
	CSL_usbhcIntrEventsEnable (
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_BitMask32*       	cmdArg)
{
	hUsbhc->regs->HCINTERRUPTENABLE = *((CSL_BitMask32*)cmdArg);
}


static inline
void
	CSL_usbhcIntrEventsDisable (
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_BitMask32*       	cmdArg)
{
	hUsbhc->regs->HCINTERRUPTDISABLE = *((CSL_BitMask32*)cmdArg);
	return;
}

static inline
void
	CSL_usbhcIntrEventsClear (
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		CSL_BitMask32*       	cmdArg)
{
	hUsbhc->regs->HCINTERRUPTSTATUS = *((CSL_BitMask32*)cmdArg);
}

static inline
void
	CSL_usbhcFrmIntervalSet (
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint32*       	cmdArg)
{
	Bool _toggleBit;

	/* Setting the Frame Interval */
	CSL_FINS(hUsbhc->regs->HCFMINTERVAL,USBHC_HCFMINTERVAL_FI,*((Uint32*)cmdArg));
	/* As per specification, the Frame Interval field must toggle when this field is written into */
	_toggleBit = (Bool)CSL_FEXT(hUsbhc->regs->HCFMINTERVAL,USBHC_HCFMINTERVAL_FIT);
	_toggleBit = ~_toggleBit;
	CSL_FINS(hUsbhc->regs->HCFMINTERVAL,USBHC_HCFMINTERVAL_FIT,_toggleBit);
}

static inline
void
	CSL_usbhcLargestDataPkt(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint16*       	cmdArg)
{
    CSL_FINS(hUsbhc->regs->HCFMINTERVAL,USBHC_HCFMINTERVAL_FSMPS,*((Uint16*)cmdArg));
}

static inline
void
	CSL_usbhcBusTimeoutEnable(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HOSTTIMEOUTCTRL,USBHC_HOSTTIMEOUTCTRL_TO_DIS,ENABLE);
}

static inline
void
	CSL_usbhcBusTimeoutDisable(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HOSTTIMEOUTCTRL,USBHC_HOSTTIMEOUTCTRL_TO_DIS,DISABLE);
}

static inline
void
	CSL_usbhcCurrenedBulk(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint32*       	cmdArg)
{
	hUsbhc->regs->HCBULKCURRENTED =  *(Uint32*)cmdArg;
}

static inline
void
	CSL_usbhcCurrentedCtrl(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint32*       	cmdArg)
{
	hUsbhc->regs->HCCONTROLCURRENTED = *(Uint32*)cmdArg;
}

static inline
void
	CSL_usbhcCurrentedPer(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint32*       	cmdArg)
{
	hUsbhc->regs->HCPERIODCURRENTED = *(Uint32*)cmdArg;
}

static inline
void
	CSL_usbhcHeadedBulk(
 		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint32*       	cmdArg)
{
	hUsbhc->regs->HCBULKHEADED = *(Uint32*)cmdArg;
}

static inline
void
	CSL_usbhcHeadedCtrl(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle           hUsbhc,
		/** Optional argument @a void* casted */
		Uint32*       	cmdArg)
{
	hUsbhc->regs->HCCONTROLHEADED = *(Uint32*)cmdArg;
}

static inline
void
	CSL_usbhcStart(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle     hUsbhc,
		/** Optional argument @a void* casted */
		CSL_UsbhcHwStart*       		cmdArg)
{
	Uint32 _temp_reg;

	/* Taking a bakup of the HcFrameInterval Register */
	_temp_reg = hUsbhc->regs->HCFMINTERVAL;
	/* Asserting a soft reset */
	CSL_FINST(hUsbhc->regs->HCCOMMANDSTATUS,USBHC_HCCOMMANDSTATUS_HCR,RESET);
	/* Wait till reset is done i.e as per documentation, till this
	register is not read as zero */
	while (hUsbhc->regs->HCCOMMANDSTATUS != 0);
	/* Restoring the value of the FrameInterval Register */
	hUsbhc->regs->HCFMINTERVAL = _temp_reg;
	/* Obtaining the periodic start value */
	_temp_reg = CSL_FEXT(hUsbhc->regs->HCFMINTERVAL,USBHC_HCFMINTERVAL_FI);
	_temp_reg *= 0.9;
	/* Writing the periodic start register value */
	CSL_FINS(hUsbhc->regs->HCPERIODICSTART,USBHC_HCPERIODICSTART_PS,_temp_reg);

	/* Writing the HcHCCA Register , this should be aligned to a 256
	byte boundary */
	hUsbhc->regs->HCHCCA = ((CSL_UsbhcHwStart*)cmdArg)->hcca;
	/* Writing the Hc Control Head register, this should be
	aligned on a 16 byte boundary*/
	hUsbhc->regs->HCCONTROLHEADED = ((CSL_UsbhcHwStart*)cmdArg)->controlHeadED;
	/* Writing the Hc Bulk Head register, this should be
	aligned on a 16 byte boundary*/
	hUsbhc->regs->HCBULKHEADED = ((CSL_UsbhcHwStart*)cmdArg)->bulkHeadED;

	/* Setting the low speed threshold value */
	CSL_FINS(hUsbhc->regs->HCLSTHRESHOLD,USBHC_HCLSTHRESHOLD_LST,((CSL_UsbhcHwStart*)cmdArg)->lowSpeedThreshold);

	/* Forming the Control Register Settings */
	_temp_reg = hUsbhc->regs->HCCONTROL;
	CSL_FINS(_temp_reg,USBHC_HCCONTROL_CBSR,((CSL_UsbhcHwStart*)cmdArg)->ctrlbulkRatio);
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_HCFS,OPERATIONAL);
	if (((CSL_UsbhcHwStart*)cmdArg)->listEnable & CSL_USBHC_LIST_BULK)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_BLE,ENABLE);
	if (((CSL_UsbhcHwStart*)cmdArg)->listEnable & CSL_USBHC_LIST_CTRL)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_CLE,ENABLE);
	if (((CSL_UsbhcHwStart*)cmdArg)->listEnable & CSL_USBHC_LIST_PER)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_PLE,ENABLE);
	if (((CSL_UsbhcHwStart*)cmdArg)->listEnable & CSL_USBHC_LIST_ISOCH)
	CSL_FINST(_temp_reg,USBHC_HCCONTROL_IE,ENABLE);
	hUsbhc->regs->HCCONTROL = _temp_reg;
	/* Setting the Interrupt Enable mask */
	hUsbhc->regs->HCINTERRUPTENABLE = ((CSL_UsbhcHwStart*)cmdArg)->interruptEnable;
}

static inline
void
	CSL_usbhcRHubCtrlRemWkupEnClr(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle     hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCRHSTATUS,USBHC_HCRHSTATUS_CRWE,SET);
}

static inline
void
	CSL_usbhcRHubCtrlRemWkupEnSet(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle     hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCRHSTATUS,USBHC_HCRHSTATUS_DRWE,SET);
}

static inline
void
	CSL_usbhcRHubCtrlGlblPwrClr(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle     hUsbhc)
{
	CSL_FINST(hUsbhc->regs->HCRHSTATUS,USBHC_HCRHSTATUS_LPS,SET);
}

static inline
void
	CSL_usbhcRHubCtrlGlblPwrSet(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle     hUsbhc)
{
   	CSL_FINST(hUsbhc->regs->HCRHSTATUS,USBHC_HCRHSTATUS_LPSC,SET);
}

static inline
void
	CSL_usbhcRHutCtrlOvrCurrIndClr(
		/** Pointer to the object that holds reference to the
     	* instance of USBHC requested after the call */
		CSL_UsbhcHandle     hUsbhc)
{

⌨️ 快捷键说明

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