FreeCalypso > hg > freecalypso-sw
view nuc-fw/bsp/niq32.c @ 101:7029fe8ae0bc
pirexplore: FFS find command implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 02 Sep 2013 00:33:54 +0000 |
parents | 45911ad957fd |
children | 4179acab05f7 |
line wrap: on
line source
/****************************************************************************** TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION Property of Texas Instruments -- For Unrestricted Internal Use Only Unauthorized reproduction and/or distribution is strictly prohibited. This product is protected under copyright law and trade secret law as an unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All rights reserved. Filename : niq32.c Description : Nucleus IQ initializations Project : Drivers Author : proussel@ti.com Patrick Roussel. Version number : 1.12 Date and time : 02/19/01 14:01:50 Previous delta : 12/19/00 14:24:51 SCCS file : /db/gsm_asp/db_ht96/dsp_0/gsw/rel_0/mcu_l1/release_gprs/mod/emu_p/EMU_P_FRED_ADC/drivers1/common/SCCS/s.niq32.c Sccs Id (SID) : '@(#) niq32.c 1.12 02/19/01 14:01:50 ' *******************************************************************************/ #include "l1_sw.cfg" #if(!OP_L1_STANDALONE) #include "chipset.cfg" #include "debug.cfg" #include "board.cfg" #include "rv_defined_swe.h" #include "rtc_config.h" #endif #include "sys_types.h" #include "serialswitch.h" #include "mem.h" #include "inth.h" #include "sim.h" #include "abb_inth.h" // for External Interrupt #define IQ_H #include "iq.h" #include "ulpd.h" #if (defined RVM_DAR_SWE) && (defined _GSM) extern void dar_watchdog_reset(void); #endif #if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41) || (BOARD == 43) || (BOARD == 45)) #include "armio.h" #include "uartfax.h" #endif /* External declaration */ extern void GAUGING_Handler(void); extern void TMT_Timer_Interrupt(void); extern void kpd_key_handler(void); extern void TP_FrameIntHandler(void); #if (!OP_L1_STANDALONE) #if (defined RVM_MPM_SWE) extern void MPM_InterruptHandler(void); #endif #if (TI_PROFILER == 1) extern void ti_profiler_tdma_action(void); #endif extern void RTC_GaugingHandler(void); extern void RTC_ItTimerHandle(void); extern void RTC_ItAlarmHandle(void); #endif /* Global variables */ unsigned IQ_TimerCount1; /* Used to check if timer is incrementing */ unsigned IQ_TimerCount2; /* Used to check if timer is incrementing */ unsigned IQ_TimerCount; /* Used to check if timer is incrementing */ unsigned IQ_DummyCount; /* Used to check if dummy IT */ unsigned IQ_FrameCount; /* Used to check if Frame IT TPU*/ unsigned IQ_GsmTimerCount; /* Used to check if GSM Timer IT */ /* add this two variables for imported 188 functions, Jeffrey, 02/26/04 */ typedef struct GPIO_HISR_INFO { NU_HISR hisr; char hisr_stack[1024]; } T_GPIO_HISR_INFOS; static T_GPIO_HISR_INFOS gpio_hisr_infos = {0}; int g_interrupt = 0; extern void Hall_OC_IntHandler( void ) ; /*--------------------------------------------------------------*/ /* irqHandlers */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Table of interrupt handlers */ /* These MUST be 32-bit entries */ /*--------------------------------------------------------------*/ SYS_FUNC irqHandlers[IQ_NUM_INT] = { IQ_TimerHandler, /* Watchdog timer */ IQ_TimerHandler1, /* timer 1 */ IQ_TimerHandler2, /* timer 2 */ IQ_Dummy, /* AIRQ 3 */ IQ_FrameHandler, /* TPU Frame It AIRQ 4 */ IQ_Dummy, /* AIRQ 5 */ #if (OP_L1_STANDALONE) IQ_Dummy, #else SIM_IntHandler, /* AIRQ 6 */ #endif #if ((CHIPSET == 2) || (CHIPSET == 3)) SER_uart_handler, /* AIRQ 7 */ #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) SER_uart_modem_handler, /* AIRQ 7 */ #endif #if (CHIPSET == 12) IQ_KeypadHandler, /* AIRQ 8 */ #else #if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41)) IQ_KeypadGPIOHandler, /* AIRQ 8 */ #else IQ_KeypadHandler, /* AIRQ 8 */ #endif #endif IQ_Rtc_Handler, /* AIRQ 9 RTC Timer*/ #if ((CHIPSET == 2) || (CHIPSET == 3)) IQ_RtcA_GsmTim_Handler, /* AIRQ 10 RTC ALARM OR ULPD GSM TIMER*/ #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) IQ_RtcA_Handler, /* AIRQ 10 RTC ALARM */ #endif IQ_Gauging_Handler, /* AIRQ 11 ULPD GAUGING */ IQ_External, /* AIRQ 12 */ IQ_Dummy, /* AIRQ 13 */ IQ_Dummy, /* DMA interrupt */ #if (CHIPSET == 4) IQ_Dummy, /* LEAD */ IQ_Dummy, /* SIM card-detect fast interrupt */ IQ_Dummy, /* External fast interrupt */ SER_uart_irda_handler, /* UART IrDA interrupt */ IQ_GsmTim_Handler /* ULPD GSM timer */ #elif ((CHIPSET == 5) || (CHIPSET == 6)) IQ_Dummy, /* LEAD */ IQ_Dummy, /* SIM card-detect fast interrupt */ IQ_Dummy, /* External fast interrupt */ SER_uart_irda_handler, /* UART IrDA interrupt */ IQ_GsmTim_Handler, /* ULPD GSM timer */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* GEA interrupt */ #elif ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) IQ_Dummy, /* LEAD */ IQ_Dummy, /* SIM card-detect fast interrupt */ IQ_Dummy, /* External fast interrupt */ SER_uart_irda_handler, /* UART IrDA interrupt */ IQ_GsmTim_Handler, /* ULPD GSM timer */ IQ_Dummy /* GEA interrupt */ #elif (CHIPSET == 9) IQ_Dummy, /* LEAD */ IQ_Dummy, /* SIM card-detect fast interrupt */ IQ_Dummy, /* External fast interrupt */ SER_uart_irda_handler, /* UART IrDA interrupt */ IQ_GsmTim_Handler, /* ULPD GSM timer */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* Reserved */ #elif (CHIPSET == 12) IQ_Dummy, /* IRQ15 - LEAD */ IQ_Dummy, /* IRQ16 - GPIO */ IQ_Dummy, /* IRQ17 - External fast interrupt */ SER_uart_irda_handler, /* IRQ18 - UART IrDA interrupt */ IQ_GsmTim_Handler, /* IRQ19 - ULPD GSM timer */ IQ_Dummy, /* IRQ20 - GEA interrupt */ IQ_Dummy, /* IRQ21 - External general Purpose interrupt IRQ1 */ IQ_Dummy, /* IRQ22 - External general Purpose interrupt IRQ2 */ IQ_Dummy, /* IRQ23 - USIM card insertion/extraction */ IQ_Dummy, /* IRQ24 - USIM */ IQ_Dummy, /* IRQ25 - LCD */ IQ_Dummy, /* IRQ26 - USB */ IQ_Dummy, /* IRQ27 - MMC/SD/Memory Stick */ SER_uart_modem2_handler,/* IRQ28 - UART_MODEM2 */ IQ_Dummy, /* IRQ29 - 2nd level interrupt handler */ IQ_Dummy, /* IRQ30 - I2C or uWIRE */ IQ_Dummy /* IRQ31 - NAND FLASH */ #else IQ_Dummy /* LEAD */ #endif }; #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) /*--------------------------------------------------------------*/ /* fiqHandlers */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return :none */ /* Functionality : Table of interrupt handlers */ /* These MUST be 32-bit entries */ /*--------------------------------------------------------------*/ SYS_FUNC fiqHandlers[IQ_NUM_INT] = { IQ_Dummy, /* Watchdog timer */ IQ_Dummy, /* timer 1 */ IQ_Dummy, /* timer 2 */ IQ_Dummy, /* AIRQ 3 */ IQ_Dummy, /* TPU Frame It AIRQ 4 */ IQ_Dummy, /* AIRQ 5 */ IQ_Dummy, /* AIRQ 6 */ IQ_Dummy, /* AIRQ 7 */ IQ_Dummy, /* AIRQ 8 */ IQ_Dummy, /* AIRQ 9 RTC Timer */ IQ_Dummy, /* AIRQ 10 RTC ALARM */ IQ_Dummy, /* AIRQ 11 ULPD GAUGING */ IQ_Dummy, /* AIRQ 12 */ IQ_Dummy, /* AIRQ 13 Spi Tx Rx interrupt */ IQ_Dummy, /* DMA interrupt */ IQ_Dummy, /* LEAD */ #if (CHIPSET == 12) IQ_Dummy, /* IRQ16 - GPIO */ #else #if (OP_L1_STANDALONE) IQ_Dummy, #else /* glowing, 2004-06-08, replace SIM with Hall according to 188 */ Hall_OC_IntHandler, /* glowing,2003-12-18, Hall open-close fast interrupt, it replace SIM_CD_IntHandler */ //SIM_CD_IntHandler, /* SIM card-detect fast interrupt */ #endif #endif IQ_Dummy, /* External fast interrupt */ IQ_Dummy, /* UART_IRDA interrupt */ #if (CHIPSET == 4) IQ_Dummy /* ULPD GSM timer */ #elif ((CHIPSET == 5) || (CHIPSET == 6)) IQ_Dummy, /* ULPD GSM timer */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* GEA interrupt */ #elif ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) IQ_Dummy, /* ULPD GSM timer */ IQ_Dummy /* GEA timer */ #elif (CHIPSET == 9) IQ_Dummy, /* ULPD GSM timer */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* Reserved */ #elif (CHIPSET == 12) IQ_Dummy, /* IRQ19 - ULPD GSM timer */ IQ_Dummy, /* IRQ20 - GEA interrupt */ IQ_Dummy, /* IRQ21 - External general Purpose interrupt IRQ1 */ IQ_Dummy, /* IRQ22 - External general Purpose interrupt IRQ2 */ IQ_Dummy, /* IRQ23 - USIM card insertion/extraction */ IQ_Dummy, /* IRQ24 - USIM */ IQ_Dummy, /* IRQ25 - LCD */ IQ_Dummy, /* IRQ26 - USB */ IQ_Dummy, /* IRQ27 - MMC/SD/Memory Stick */ IQ_Dummy, /* IRQ28 - UART_MODEM2 */ IQ_Dummy, /* IRQ29 - 2nd level interrupt handler */ IQ_Dummy, /* IRQ30 - I2C or uWIRE */ IQ_Dummy /* IRQ31 - NAND FLASH */ #endif }; #endif /*--------------------------------------------------------------*/ /* IQ_Gauging_Handler */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle unused interrupts */ /*--------------------------------------------------------------*/ void IQ_Gauging_Handler(void) { GAUGING_Handler(); #if (!OP_L1_STANDALONE) RTC_GaugingHandler(); #endif } /*--------------------------------------------------------------*/ /* IQ_External */ /*--------------------------------------------------------------*/ /* Parameters : none */ /* Return : none */ /* Functionality : Handle External IRQ mapped on ABB. */ /*--------------------------------------------------------------*/ void IQ_External(void) { // Mask external interrupt (12) IQ_Mask(IQ_EXT); // The external IRQ is mapped on the ABB interrupt. // The associated HISR ABB_Hisr is activated on reception on the external IRQ. if(Activate_ABB_HISR()) { IQ_Unmask(IQ_EXT); } } /*--------------------------------------------------------------*/ /* IQ_Dummy */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle unused interrupts */ /*--------------------------------------------------------------*/ void IQ_Dummy(void) { IQ_DummyCount++; } /*--------------------------------------------------------------*/ /* IQ_RTCHandler */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle RTC Time interrupts */ /*--------------------------------------------------------------*/ void IQ_Rtc_Handler(void) { #if (!OP_L1_STANDALONE) RTC_ItTimerHandle(); #endif } /*--------------------------------------------------------------*/ /* IQ_RtcA_GsmTim_Handler */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle RTC ALARM or GAUGING interrupts */ /*--------------------------------------------------------------*/ #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) void IQ_RtcA_Handler(void) { #if (!OP_L1_STANDALONE) /* INTH_DISABLEONEIT(IQ_RTC_ALARM); *//* RTC ALARM IT */ if ( (* (SYS_WORD8 *) RTC_STATUS_REG) & RTC_ALARM ) RTC_ItAlarmHandle(); #endif } void IQ_GsmTim_Handler(void) { if ( (* (SYS_UWORD16 *) ULDP_GSM_TIMER_IT_REG) & ULPD_IT_TIMER_GSM ) { // it is GSM Timer it..... IQ_GsmTimerCount++; } } #else void IQ_RtcA_GsmTim_Handler(void) { #if (!OP_L1_STANDALONE) if ( (* (SYS_UWORD16 *) ULDP_GSM_TIMER_IT_REG) & ULPD_IT_TIMER_GSM ) { // it is GSM Timer it..... IQ_GsmTimerCount++; } else { /* INTH_DISABLEONEIT(IQ_RTC_ALARM); *//* RTC ALARM IT */ if ( (* (SYS_WORD8 *) RTC_STATUS_REG) & RTC_ALARM ) RTC_ItAlarmHandle(); } #endif } #endif /*--------------------------------------------------------------*/ /* IQ_TimerHandler */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle Timer interrupts */ /*--------------------------------------------------------------*/ void IQ_TimerHandler(void) { IQ_TimerCount++; TMT_Timer_Interrupt(); #if (defined RVM_DAR_SWE) && (defined _GSM) dar_watchdog_reset(); #endif } /*--------------------------------------------------------------*/ /* IQ_FramerHandler */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle Timer interrupts */ /*--------------------------------------------------------------*/ void IQ_FrameHandler(void) { IQ_FrameCount++; TMT_Timer_Interrupt(); TP_FrameIntHandler(); #if (!OP_L1_STANDALONE) #if (TI_PROFILER == 1) // TDMA treatment for profiling buffer ti_profiler_tdma_action(); #endif #endif } /*--------------------------------------------------------------*/ /* IQ_TimerHandler1 */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle Timer 1 interrupts */ /*--------------------------------------------------------------*/ void IQ_TimerHandler1(void) { IQ_TimerCount1++; } /*--------------------------------------------------------------*/ /* IQ_TimerHandler2 */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle Timer 2 interrupts */ /*--------------------------------------------------------------*/ void IQ_TimerHandler2(void) { IQ_TimerCount2++; } /*--------------------------------------------------------------*/ /* IQ_IRQ_isr */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : HHandle IRQ interrupts */ /*--------------------------------------------------------------*/ void IQ_IRQ_isr(void) { irqHandlers[((* (SYS_UWORD16 *) INTH_B_IRQ_REG) & INTH_SRC_NUM)](); /* ACK IT */ * (SYS_UWORD16 *) INTH_CTRL_REG |= (1 << INTH_IRQ); /* valid next IRQ */ } /*--------------------------------------------------------------*/ /* IQ_FIQ_isr */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle FIQ interrupts */ /*--------------------------------------------------------------*/ void IQ_FIQ_isr(void) { #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) fiqHandlers[((* (SYS_UWORD16 *) INTH_B_FIQ_REG) & INTH_SRC_NUM)](); /* ACK IT */ #endif * (SYS_UWORD16 *) INTH_CTRL_REG |= (1 << INTH_FIQ); /* valid next FIQ */ } #if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41)) /*--------------------------------------------------------------*/ /* IQ_KeypadGPIOHandler */ /*--------------------------------------------------------------*/ /* Parameters : none */ /* Return : none */ /* Functionality : Handle keypad and GPIO interrupts */ /*--------------------------------------------------------------*/ void IQ_KeypadGPIOHandler(void) { #if (!OP_L1_STANDALONE) /* * GPIO interrupt must be checked before the keypad interrupt. The GPIO * status bit is reset when the register is read. */ g_interrupt = 80; if (AI_CheckITSource (ARMIO_GPIO_INT)) { #if 0 #ifdef RVM_MPM_SWE /* check if the SWE has been started */ MPM_InterruptHandler (); #else UAF_DTRInterruptHandler (); #endif #endif /* Jeffrey, 02/26/04, add this line from 188 */ gpio_handler(); } if (AI_CheckITSource (ARMIO_KEYPDAD_INT)) kpd_key_handler (); #endif } /** * function: gpio_handler hall */ void gpio_handler(void) { /* 2003/11/01 Robert.Chen for melody interrupt from GPIO1*/ /* modify from */ /* AI_MaskIT(2); */ /* to */ AI_MaskIT(2); /* end Robert.Chen */ /* Activate HISR to process the key event */ NU_Activate_HISR(&gpio_hisr_infos.hisr); } /* 2003/11/01 Robert.Chen Melody HISR entry */ void MI_Melody_Hisr(void) { MaDevDrv_IntHandler(); AI_UnmaskIT(0x02); } /** * function: kpd_initialize_keypad_hardware */ void Gpio_hisr_initialize(void) { int i; /* 2003/11/01 Robert.Chen, modify for Melody HISR */ /* modify from */ #if 0 /* HISR creation */ NU_Create_HISR(&gpio_hisr_infos.hisr, "GPIO_HISR", gpio_hisr_entry, 2, gpio_hisr_infos.hisr_stack, sizeof(gpio_hisr_infos.hisr_stack)); AI_UnmaskIT(0x02); i = HallOnOff(); if(i){ AI_SelectIOForIT (2, 0);//ARMIO_FALLING_EDGE } else{ AI_SelectIOForIT (2, 1);//ARMIO_RISING_EDGE } #endif /* to */ NU_Create_HISR(&gpio_hisr_infos.hisr, "GPIO_HISR", MI_Melody_Hisr, 2, gpio_hisr_infos.hisr_stack, sizeof(gpio_hisr_infos.hisr_stack)); AI_EnableBit(5); /* MCSI_TXD as GPIO9 */ AI_ConfigBitAsInput(9); /* GPIO9 as input pin for YMU765 ~IRQ */ AI_SelectIOForIT (9, 0); /* GPIO9 as input, falling edge triggered */ AI_UnmaskIT(0x02); /* enable GPIO IRQ */ /* end modify, Robert.Chen */ } /* end of imported functins, Jeffrey, 02/26/04 */ /* ---------------------------------------------*/ #elif ((BOARD == 43) || (BOARD == 45)) /*--------------------------------------------------------------*/ /* IQ_KeypadHandler */ /*--------------------------------------------------------------*/ /* Parameters :none */ /* Return : none */ /* Functionality : Handle keypad interrupts */ /*--------------------------------------------------------------*/ void IQ_KeypadHandler(void) { #if (!OP_L1_STANDALONE) kpd_key_handler (); #endif } #endif