📄 omap730_gints.c
字号:
/******************* Paragon Wireless *****************
*
* Purpose:
*
* Author:
*
* Date: 2006/03/27 $
*
* Revision: #1.0 $
*
*******************************************************/
#include "omap730_gspx.h"
//static const GUID DEVICE_IFC_GPIO_GUID;
/*-----------------------------------------------------------
*
* Name: IstThread()
*
* Description: IST Thread
*
* Arguments:PINTS_INFO pIntrInfo
*
* Return Value: BOOL
*
*
* Notes:
--------------------------------------------------------------*/
BOOL IstThread(PINTS_INFO pIntrInfo)
{
// RETAILMSG(1,(TEXT("*****IstThread-Priority : %d*********\n\n\n"), CeGetThreadPriority(GetCurrentThread())));
while(pIntrInfo->bQuitIst == FALSE)
{
// RETAILMSG(1, (TEXT("*** IstThread WaitForSingleObject hIntrEvent***\r\n\n")));
WaitForSingleObject(pIntrInfo->hIntrEvent, INFINITE);//
//Callback the registered ist function outside intr module
pIntrInfo->istFunc(pIntrInfo->pIstParam);
//Finish the interrupt
InterruptDone(pIntrInfo->dwSysIntID);
}
//SetEvent(pIntrInfo->hWaitObject);
return TRUE;
}
/*-----------------------------------------------------------
*
* Name: SetupInterrupt()
*
* Description: setup Interrupt
*
* Arguments:PINTS_INFO pIntrInfo
*
* Return Value: int
*
*
* Notes:
--------------------------------------------------------------*/
int SetupInterrupt(PINTS_INFO pIntrInfo)
{
pIntrInfo->hIntrEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(!pIntrInfo->hIntrEvent)
{
DEBUGMSG(1, (TEXT("*****SPI Intr Create hIntrEvent Event FAILED *******\n\n")));
return -1;
}
pIntrInfo->dwSysIntID = Omap_gspx_get_sysintr();
if(!pIntrInfo->dwSysIntID)
{
pIntrInfo->dwSysIntID = SYSINTR_UNDEFINED;
return -1;
}
//RETAILMSG(1, (TEXT("dwSysIntID: %d!\n"), pIntrInfo->dwSysIntID));
//Create a thread that waits for signals
pIntrInfo->hIstThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)IstThread, pIntrInfo, CREATE_SUSPENDED, NULL);
if(!pIntrInfo->hIstThread)
{
DEBUGMSG(1, (TEXT("*****SPI Intr Create Thread FAILED*******\n")));
return -1;
}
CeSetThreadPriority(pIntrInfo->hIstThread, 118);
// CeSetThreadQuantum(pIntrInfo->hIstThread, 10);
if(!InterruptInitialize(pIntrInfo->dwSysIntID, pIntrInfo->hIntrEvent, NULL, 0))
{
DEBUGMSG(1, (TEXT("*****SPI Intr InterruptInitialize Failed*******\n")));
return -1;
}
pIntrInfo->bQuitIst = FALSE;
ResumeThread(pIntrInfo->hIstThread);
// DEBUGMSG(1, (TEXT("*****SPI Intr ResumeThread hIstThread*******\n")));
return 0; //success
}
/*-----------------------------------------------------------
*
* Name: DeviceIst()
*
* Description: Device IST
*
* Arguments:PGSPI_HW_INFO pGspiHwInfo
*
* Return Value: BooL
*
*
* Notes:
--------------------------------------------------------------*/
BOOL DeviceIst(PGSPI_HW_INFO pGspiHwInfo)
{
WORD dwHostIntStatus = 0;
//The driver shutdown or not. FALSE: No, TRUE:Yes
if(pGspiHwInfo->IntsInfo.bDriverShutdown == TRUE)
return FALSE;
//whether there is a pending intrrupt?
//Note: HCR_HOST_INT_STATUS_REGISTER = 0x5c
// Omap_gspx_read_reg16(pGspiHwInfo, 0x5c, &dwHostIntStatus);
// if(0x00 == dwHostIntStatus)
// return FALSE;
//We use GPIO_22 as our interrupt source. We need to clear the GEDR (GPIO Edge Detect Status Register)
// manually. Otherwise, the BSP will think the interrupt has not been served & come to IST continually
InterruptDone(pGspiHwInfo->IntsInfo.dwSysIntID);
//Doing the ISR service routine;
if(pGspiHwInfo->isrFunc != NULL)
pGspiHwInfo->isrFunc(pGspiHwInfo->hIsrParam);
return TRUE;
}
/*-----------------------------------------------------------
*
* Name: Omap_interrupt_initialize()
*
* Description: Interrupt initialize
*
* Arguments:PGSPI_HW_INFO pHC
*
* Return Value: BooL
*
*
* Notes:
--------------------------------------------------------------*/
int Omap_interrupt_initialize(PGSPI_HW_INFO pHC)
{
if(pHC == NULL)
return -1;
pHC->IntsInfo.istFunc = (ISTFUNC)DeviceIst;
pHC->IntsInfo.pIstParam = (LPVOID)pHC;
//Initialize the interrupt,
SetupInterrupt(&pHC->IntsInfo);
return 0;
}
/*-----------------------------------------------------------
*
* Name: ClearInterrupt()
*
* Description: clear initialize
*
* Arguments:PINTS_INFO pIntsInfo
*
* Return Value: void
*
*
* Notes:
--------------------------------------------------------------*/
void ClearInterrupt(PINTS_INFO pIntsInfo)
{
///Clean up the handler
if(pIntsInfo->hIntrEvent)
SetEvent(pIntsInfo->hIntrEvent);
//if(pIntrInfo->hGIIsr)
// FreeIntChainHandler(pIntrInfo->hGIIsr);
if(pIntsInfo->hIstThread)
{
pIntsInfo->bQuitIst = TRUE;
//WaitForSingleObject(pIntsInfo->hWaitObject, INFINITE);
//CloseHandle(pIntsInfo->hWaitObject);
CloseHandle(pIntsInfo->hIstThread);
}
memset(pIntsInfo, 0, sizeof(PINTS_INFO));
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -