⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abb_inth.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:

#if (!OP_L1_STANDALONE)
/********************************************************************************/
/*                                                                              */
/*  Function Name: spi_abb_read_int_reg_callback                                */
/*                                                                              */
/*  Purpose:      Callback function                                             */
/*                Called when an external interrupt has occured and the         */
/*                ABB interrupt register has been read.                         */
/*                                                                              */
/********************************************************************************/
void spi_abb_read_int_reg_callback(SYS_UWORD16 *read_value)
{
   SYS_UWORD16 loop_count;
   SYS_UWORD16 status_value;
   xSignalHeaderRec *adc_msg;
   volatile SYS_UWORD8 i;
// TISH031204 shirely modify for add in new charging algorithm
#ifdef RVM_LCC_SWE
   struct pwr_adc_ind_s *addr;
   extern T_PWR_CTRL_BLOCK *pwr_ctrl;
#endif


   // check all the possible causes of the ABB IT
   if (*read_value & PUSHOFF_IT_STS)
   {
      /* Push Button from ON to OFF */
      if (SPI_GBL_INFO_PTR->is_gsm_on == TRUE)
      {
         NU_Sleep(SHORT_OFF_KEY_PRESSED);

         /* Since this callback function is called from the SPI task
         it can't be interrupted by another task
         so we can directly access the SPI through the low-level driver */

         #if ((ANALOG == 1) || (ANALOG == 2))
         status_value = (ABB_Read_Status() & ONREFLT);
         #elif (ANALOG == 3)
         status_value = (ABB_Read_Register_on_page(PAGE1, VRPCCFG) & PWOND);
         #endif

         if (status_value == PWR_OFF_KEY_PRESSED)
         {
            /* Inform keypad that key ON/OFF has been pressed */
            kpd_power_key_pressed();

            loop_count = 0;
            /* Wait loop for Power-OFF */
            while ((loop_count < OFF_LOOP_COUNT) &&
                   (status_value == PWR_OFF_KEY_PRESSED))
            {
               NU_Sleep(SHORT_OFF_KEY_PRESSED);
               #if ((ANALOG == 1) || (ANALOG == 2))
               status_value = (ABB_Read_Status() & ONREFLT);
               #elif (ANALOG == 3)
               status_value = (ABB_Read_Register_on_page(PAGE1, VRPCCFG) & PWOND);
               #endif
               loop_count++;
            }

            if (status_value == PWR_OFF_KEY_PRESSED) /* Power-OFF request detected */
            {
               rvf_send_trace("IQ EXT: Power Off request",25, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

               Power_OFF_Button();
            }
         }
      }
      else  /* GSM OFF */
      { 
         rvf_send_trace("IQ EXT: Power On request",24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

         Power_ON_Button();
      }
   }

   else if (*read_value & REMOT_IT_STS)
   {
      rvf_send_trace("IQ EXT: Power Off remote request",32, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

      /* 'Remote Power' from ON to OFF */
      Power_OFF_Remote();
   }
        
   else if (*read_value & ADCEND_IT_STS)
   {
      rvf_send_trace("IQ EXT: ADC End",15, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

      /* ADC end of conversion */
      ABB_Read_ADC(&SPI_GBL_INFO_PTR->adc_result[0]);
      adc_msg = os_alloc_sig(sizeof(T_CST_ADC_RESULT));
     if(adc_msg != NULL)
     {
        adc_msg->SignalCode = CST_ADC_RESULT;

        for(i=0;i<MADC_NUMBER_OF_MEAS;i++)
        {
          ((T_CST_ADC_RESULT *)(adc_msg->SigP))->adc_result[i] = SPI_GBL_INFO_PTR->adc_result[i];
        }
        os_send_sig(adc_msg, RRM1_QUEUE);
// TISH031204 shirely change for add in new charging algorithm
#ifdef RVM_LCC_SWE
	// Send ADC measurement to PWR (LCC) task
        // NOTE that memory is allocated externally in the PWR task
        if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_adc_ind_s), (void *)&addr) == RVF_RED) {
           rvf_send_trace("rvf_get_buf failed",18, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
        /* Unmask External interrupt */
           IQ_Unmask(IQ_EXT);
        //            rvf_dump_mem();
           return;
        }
        addr->header.msg_id        = PWR_ADC_IND;
        addr->header.src_addr_id   = SPI_GBL_INFO_PTR->addr_id;
        addr->header.dest_addr_id  = pwr_ctrl->addr_id;
        addr->header.callback_func = NULL;
        // FIXME: memcpy from SPI_GBL_INFO_PTR->adc_result - make sure it has not been de-allocated
        memcpy(addr->data, SPI_GBL_INFO_PTR->adc_result, 8*2);
        addr->data[9] = ABB_Read_Status();; // Read & assign ITSTATREG status so we save the polling in PWR task!!
        if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) {
            rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
        }
#endif
      }
   }
// TISH031204 shirely change for add in new charging algorithm
#if (defined(RVM_PWR_SWE) || defined(RVM_LCC_SWE))
   else if (*read_value & CHARGER_IT_STS)
   {
      /* Charger plug IN or OUT */
#if ((ANALOG == 1) || (ANALOG == 2))
      status_value = ABB_Read_Status();
#elif (ANALOG == 3)
      status_value = ABB_Read_Register_on_page(PAGE1, VRPCCFG);
#endif
      if (status_value & CHGPRES)
      {
         rvf_send_trace("IQ EXT: Charger Plug",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

// TISH031204 shirely change for add in new charging algorithm
#ifdef RVM_PWR_SWE
         PWR_Charger_Plug();  /* charger plugged IN */
#endif
#ifdef RVM_LCC_SWE
      // Forward charger plug indication to PWR (LCC) task
      // NOTE that memory is allocated externally in the PWR task
      if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_req_s), (void *)&addr) == RVF_RED) {
      	  rvf_send_trace("rvf_get_buf failed#1",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      	  rvf_dump_mem();
      }
      addr->header.msg_id        = PWR_CHARGER_PLUGGED_IND;
      addr->header.src_addr_id   = SPI_GBL_INFO_PTR->addr_id;
      addr->header.dest_addr_id  = pwr_ctrl->addr_id;
      addr->header.callback_func = NULL;
      if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) {
      	  rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      }
#endif
      }
      else
      {
         rvf_send_trace("IQ EXT: Charger Unplug",22, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);

// TISH031204 shirely change for add in new charging algorithm
#ifdef RVM_PWR_SWE
         PWR_Charger_Unplug();   /* charger plugged OUT */
#endif
#ifdef RVM_LCC_SWE
      // Forward charger unplug indication to PWR (LCC) task
      
      // NOTE that memory is allocated externally in the PWR task
      if (rvf_get_buf(pwr_ctrl->prim_id, sizeof(struct pwr_req_s), (void *)&addr) == RVF_RED) {
      	  rvf_send_trace("rvf_get_buf failed#2",20, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      	  rvf_dump_mem();
      }
      addr->header.msg_id        = PWR_CHARGER_UNPLUGGED_IND;
      addr->header.src_addr_id   = SPI_GBL_INFO_PTR->addr_id;
      addr->header.dest_addr_id  = pwr_ctrl->addr_id;
      addr->header.callback_func = NULL;
      if (rvf_send_msg(pwr_ctrl->addr_id, addr) != RV_OK) {
      	  rvf_send_trace("SPI FATAL: Send failed!",23, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      }
#endif
      }
   }
 
#endif /* RVM_PWR_SWE || RVM_LCC_SWE */

   /* Unmask External interrupt */
   IQ_Unmask(IQ_EXT);
}
#endif	// (!OP_L1_STANDALONE)

⌨️ 快捷键说明

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