📄 isr.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name: ISR.c
** Last modified Date: 2005-04-22
** Last Version: V1.0
** Description:
**
**------------------------------------------------------------------------------------------------------
** Created By: Lishan Zhou
** Created date: 2005-04-22
** Version: V1.0
** Description:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
********************************************************************************************************/
#include "HostStack.h"
OS_EVENT *OS_rhsc_event;
volatile unsigned long g_sof_counter = 0;
unsigned long g_sof_counter_prev = 0;
unsigned long g_operation_time = 0;
volatile unsigned short g_isr_flag;
volatile unsigned short g_event_marker = 0;
volatile unsigned short g_event_counter = 0;
volatile funcPtr g_SOF_service_routine[ MAXMUM_NUMBER_OF_SOF_SERVICE_ROUTINE_METHOD ]
= SERVICE_ROUTINE_INITIALIZE;
volatile funcPtr g_ATLInt_service_routine[ MAXMUM_NUMBER_OF_SOF_SERVICE_ROUTINE_METHOD ]
= SERVICE_ROUTINE_INITIALIZE;
unsigned short hardware_configuration_setting;
unsigned short level = 0;
void interrupt_handler_USB_Hc( unsigned short intr );
void clear_HcuPInterrupt_bit( unsigned short flag );
void HcuInterrupt_OPR_Reg_handler( unsigned long intr_stat );
void clear_HcInterruptStatus_bit( unsigned long flag );
void USB_Host_Serve(void)
{
unsigned char err;
OSSemPend(OS_rhsc_event,0,&err);
if(g_event_marker&HUB_EVENT)
hub_handler();
}
void wait_ms( unsigned long timeout )
{
OSTimeDly(timeout/5);
}
void isr_USB_Hc( void )
{
unsigned short intr;
unsigned short inter_en;
disable();
inter_en = disable_Hc();
intr = read_register16( Com16_HcuPInterrupt );
clear_HcuPInterrupt_bit( intr );
interrupt_handler_USB_Hc( intr & inter_en );
enable_Hc( inter_en );
enable();
}
unsigned short disable_Hc( void )
{
unsigned short inter_en;
inter_en = read_register16( Com16_HcuPInterruptEnable );
write_register16( Com16_HcuPInterruptEnable, 0x0000 );
return ( inter_en );
}
void enable_Hc( unsigned short inter_en )
{
write_register16( Com16_HcuPInterruptEnable, inter_en );
}
void interrupt_handler_USB_Hc( unsigned short intr )
{
int i;
if ( intr & HcuInterrupt_AllEOTInterrupt )
;
if ( intr & HcuInterrupt_SOFITInt )
{
for ( i = 0; i < MAXMUM_NUMBER_OF_SOF_SERVICE_ROUTINE_METHOD; i++ )
if ( g_SOF_service_routine[ i ] )
(*g_SOF_service_routine[ i ])();
g_sof_counter = (g_sof_counter & 0xFFFF0000) | (read_register32( Com32_HcFmNumber ) & 0x0000FFFF);
}
if ( intr & HcuInterrupt_ATLInt )
{
for ( i = 0; i < MAXMUM_NUMBER_OF_SOF_SERVICE_ROUTINE_METHOD; i++ )
if ( g_ATLInt_service_routine[ i ] )
(*g_ATLInt_service_routine[ i ])();
}
if ( intr & HcuInterrupt_OPR_Reg )
{
unsigned long intr32;
intr32 = read_register32( Com32_HcInterruptStatus );
clear_HcInterruptStatus_bit( intr32 );
HcuInterrupt_OPR_Reg_handler( intr32 );
}
if ( intr & HcuInterrupt_HCSuspend )
;
if ( intr & HcuInterrupt_ClkReady )
;
}
void clear_HcuPInterrupt_bit( unsigned short flag )
{
g_isr_flag |= flag;
write_register16( Com16_HcuPInterrupt, flag );
}
void HcuInterrupt_OPR_Reg_handler( unsigned long cause )
{
unsigned long intr_stat;
intr_stat = cause & read_register32( Com32_HcInterruptEnable );
if ( intr_stat & HcInterruptStatus_SO )
;
if ( intr_stat & HcInterruptStatus_SF )
;
if ( intr_stat & HcInterruptStatus_RD )
;
if ( intr_stat & HcInterruptStatus_UE )
;
if ( intr_stat & HcInterruptStatus_RHSC )
{
g_event_marker = ROOT_HUB_EVENT;
OSSemPost(OS_rhsc_event);
}
if ( intr_stat & HcInterruptStatus_ATD )
;
if ( intr_stat & HcInterruptStatus_FNO )
g_sof_counter += (g_sof_counter & 0x00008000) ? 0 : (1L << 16);
}
void clear_HcInterruptStatus_bit( unsigned long flag )
{
g_isr_flag |= flag << 8;
write_register32( Com32_HcInterruptStatus, flag );
}
funcPtr install_SOF_service_routine( unsigned char number, funcPtr function_ptr )
{
funcPtr tmp;
if ( !(number < MAXMUM_NUMBER_OF_SOF_SERVICE_ROUTINE_METHOD) )
{
return (funcPtr) -1;
}
tmp = g_SOF_service_routine[ number ];
g_SOF_service_routine[ number ] = function_ptr;
return ( tmp );
}
funcPtr install_ATLInt_service_routine( unsigned char number, funcPtr function_ptr )
{
funcPtr tmp;
if ( !(number < MAXMUM_NUMBER_OF_SOF_SERVICE_ROUTINE_METHOD) )
{
return (funcPtr) -1;
}
tmp = g_ATLInt_service_routine[ number ];
g_ATLInt_service_routine[ number ] = function_ptr;
return ( tmp );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -