void AppInterruptsInit(void)
{
  
  pfEnableMacaInt     = (void(*)(void))EnableMacaInt;
  pfDisableMacaInt    = (void(*)(void))DisableMacaInt;
  pfIsMacaIntEnabled  = (unsigned int(*)(void))IsMacaIntEnabled;
  pfIsMacaIntAsserted = (unsigned int(*)(void))IsMacaIntAsserted;

  pfDisableProccessorIrqs = (int(*)(void))IntDisableAll;
  pfEnableProccessorIrqs = (void(*)(int))IntRestoreAll;

  /* Set priority and handler for Crm, timer, and maca*/

  IntAssignHandler(gTmrInt_c, (IntHandlerFunc_t)TmrIsr);  
  ITC_SetPriority(gTmrInt_c, gItcFastPriority_c);
  ITC_EnableInterrupt(gTmrInt_c);
  
  IntAssignHandler(gCrmInt_c, (IntHandlerFunc_t)CRM_Isr);
  ITC_SetPriority(gCrmInt_c, gItcFastPriority_c);
  ITC_EnableInterrupt(gCrmInt_c);
    
  IntAssignHandler(gMacaInt_c, MACA_Interrupt);
  ITC_SetPriority(gMacaInt_c, gItcFastPriority_c);
  ITC_EnableInterrupt(gMacaInt_c);

}
Example #2
0
void ItcInit(void)
{
  ITC_Init();
  IntDisableAll();
  
  IntAssignHandler(gMacaInt_c, (IntHandlerFunc_t)MACA_Interrupt);
  ITC_SetPriority(gMacaInt_c, gItcNormalPriority_c);
  ITC_EnableInterrupt(gMacaInt_c);
  IntAssignHandler(gTmrInt_c, (IntHandlerFunc_t)/*TmrIsr*/TMR_Interrupt);
  ITC_SetPriority(gTmrInt_c, gItcNormalPriority_c);
  ITC_EnableInterrupt(gTmrInt_c);
}
Example #3
0
void CRM_Init (void)
{
  //XtalAdjust
  //CRM_XTAL_CNTL.CTune = 0x15;//0x18;
  //CRM_XTAL_CNTL.FTune = 0x10;//0x0F;
  RTC_ExtRtcInit();
  
#if (HART_MODE != NONE)
  
  #if( (HART_DEV_KIT_REV == HART_DEV_KIT_REV3) ) 
    CRM_WU_CNTL_EXT_WU_EN   = 1;    // 1 = 0x0001 -> wake up on KBI_4
  #elif ( (HART_DEV_KIT_REV == HART_DEV_KIT_REV4) )   
    CRM_WU_CNTL_EXT_WU_EN   = 9;    // 9 = 0x1001 -> wake up on KBI_4 or KBI_7
  #endif 

#else
  
    CRM_WU_CNTL_EXT_WU_EN   = 0;    // no wake up    

#endif
    
  CRM_WU_CNTL_EXT_WU_POL &= ~4;   // internal Pullup for KBI_6(Wakeup and Status button)
    
  CRM_WU_CNTL_EXT_WU_IEN  = 0;    // without generating an interrupt
    
  CRM_WU_CNTL_TIMER_WU_EN   = 1;  // wake up from counter
  CRM_SLEEP_CNTL_RAM_RET    = 3;  // 3=96k
  CRM_SLEEP_CNTL_MCU_RET    = 1;  // e un must pt ticus
  CRM_SLEEP_CNTL_DIG_PAD_EN = 1;
    
  //  Set 32KHz pin in 1 to keep osc on ... only for old versions
  SET_GPIO_HI(KYB0_LINE);         // only for old versions of VN210 (C, D)
  CRM_WU_CNTL_EXT_OUT_POL = 0x01; // only for old versions of VN210 (C, D)

  //start the 32KHz osc
  _RINGOSC_CNTL.Bits.ROSC_EN=0;
  _XTAL32_CNTL.Bits.XTAL32_EN=1; //start the osc
  //XTAL32_CNTL = 1;  // !!!!!! wrong
  
  DelayLoop( 100 * 1000 );
  
  //source RTC_counter from 32KHz
  CRM_SYS_XTAL32_EXISTS = 1;  
  //reduce pwr consumption
  XTAL32_CNTL = 1;
          
  // set RTC interrupt    
  IntAssignHandler(gCrmInt_c, (IntHandlerFunc_t)RtcClock_Interrupt);
  ITC_SetPriority(gCrmInt_c, gItcFastPriority_c); //fiq
  ITC_EnableInterrupt(gCrmInt_c);
  g_ul250msStartTmr = RTC_COUNT; 
  RTC_TIMEOUT = RTC_32KHZ_250MS_TICS;
  CRM_WU_CNTL_RTC_WU_EN = 1;
  CRM_WU_CNTL_RTC_WU_IEN = 1;
}
Example #4
0
/*****************************************************************************
*   IIC_ModuleInit
*
*   Initialize the IIC module
******************************************************************************/
void IIC_ModuleInit()
{  
#if gIIC_Enabled_d     
  /* Configure the pin to be used for signaling the master host that data for read is available.
     Default configuration is 'No Data for Read', meaning GPIO is set to high */ 
  Gpio_EnPinPullup(gTxDataAvailablePin_c, TRUE);
  Gpio_SetPinDir(gTxDataAvailablePin_c, gGpioDirOut_c);
  Gpio_SetPinData(gTxDataAvailablePin_c, gGpioPinStateHigh_c);
       
  mI2cModuleEx.Rxi2cCallback = NULL;
  mI2cModuleEx.Txi2cCallback = NULL;
  
  mI2cModuleEx.i2cStatus = I2C_DEFAULT_STATUS;
  mI2cModuleEx.sendBuff = 0;
  mI2cModuleEx.sentBytesNo = 0;
  mI2cModuleEx.sendBuffLength = 0;
  mI2cModuleEx.recvBuffLength = 0;

  I2C.ClockEn = CLOCK_ENABLE;
  I2C.Address = I2C.Address & ~I2C_ADR_MASK;
  I2C.FreqDiv = I2C.FreqDiv & ~I2C_FDIV_MASK;
  I2C.Control = I2C.Control & ~I2C_CTRL_MASK;
  I2C.Status = 0x00;
  I2C.Data = 0x00;
  I2C.DigitalFilter = I2C.DigitalFilter & ~I2C_DFILT_MASK;
  I2C.ClockEn = I2C.ClockEn & ~I2C_CKER_MASK;
  

  Gpio_SetPinFunction(gGpioPin12_c, gGpioAlternate1Mode_c);
  Gpio_SetPinFunction(gGpioPin13_c, gGpioAlternate1Mode_c);
  
  /* Register our own interrupt handler for the I2C peripheral */  
  IntAssignHandler(gI2cInt_c, (IntHandlerFunc_t)&IIC_IsrEx);
  ITC_SetPriority(gI2cInt_c, gItcFastPriority_c);
  ITC_EnableInterrupt(gI2cInt_c);
  IntEnableFIQ();
  /* Enable I2C module */  
  IIC_EnableEx();
  
  /* Configure I2C hardware peripheral */ 
  IIC_SetSlaveAddress(gI2CDefaultSlaveAddress_c);
  
  /* Prepare the Rx module of the I2C to receive a maximum length packet */    
  IIC_InitQueue(&mI2cModuleEx.recvQueue);  
  IIC_ReceiveDataEx(0x00, &internalRxBuffer[0], gIIC_QueueSz_c - 1, gI2cSlvTransfer_c);   
#endif
}
Example #5
0
void CRM_Init (void)
{
      //XtalAdjust
//    CRM_XTAL_CNTL.CTune = 0x18;
//    CRM_XTAL_CNTL.FTune = 0x0F;

    // hibernate init    
    CRM_WU_CNTL_EXT_WU_POL &= ~4 ;

    CRM_WU_CNTL_EXT_WU_EN = 1;   //wake up from Key_4 ; //wake up on level high is default at reset
    CRM_WU_CNTL_EXT_WU_IEN = 0;  //without generating an interrupt
    
    CRM_WU_CNTL_TIMER_WU_EN = 1; //wake up from counter
    CRM_SLEEP_CNTL_RAM_RET = 3;  //3=96k
    CRM_SLEEP_CNTL_MCU_RET = 1;  // e un must pt ticus
    CRM_SLEEP_CNTL_DIG_PAD_EN = 1;
    
    //start the 32KHz osc
    _RINGOSC_CNTL.Bits.ROSC_EN=0;
    _XTAL32_CNTL.Bits.XTAL32_EN=1; //start the osc
    
    DelayLoop( 1000 );
    
    //source RTC_counter from 32KHz
    CRM_SYS_XTAL32_EXISTS = 1;  
    //reduce pwr consumption
    XTAL32_CNTL = 1;
    
    
    // set RTC interrupt
    IntAssignHandler(gCrmInt_c, (IntHandlerFunc_t)RtcClock_Interrupt);
    ITC_SetPriority(gCrmInt_c, gItcFastPriority_c); //fiq
    ITC_EnableInterrupt(gCrmInt_c);
    g_ul250msStartTmr = RTC_COUNT; 
    RTC_TIMEOUT = CLK_250MS_32KHZ;
    CRM_WU_CNTL_RTC_WU_EN = 1;
    CRM_WU_CNTL_RTC_WU_IEN = 1;   
}