Beispiel #1
0
/**
  * @brief  Execute STMTouch Driver main State machine
  * @param  None
  * @retval status Return TSL_STATUS_OK if the acquisition is done
  */
TSL_Status_enum_T TSL_user_Action(void)
{
  TSL_Status_enum_T status;

  /* Configure bank */
  if (!config_done)
  {
    TSL_acq_BankConfig(idx_bank); /* Configure Bank */
    TSL_acq_BankStartAcq(); /* Start Bank acquisition */
    config_done = 1;
#if TSLPRM_USE_ACQ_INTERRUPT > 0
    Gv_EOA = 0; /* Will be set by the TS interrupt routine */
#endif    
  }

  /* Check end of acquisition */
#if TSLPRM_USE_ACQ_INTERRUPT > 0
  if (Gv_EOA) /* Set by the TS interrupt routine */
#else
  if (TSL_acq_BankWaitEOC() == TSL_STATUS_OK)
#endif
  {
    TSL_acq_BankGetResult(idx_bank, 0, 0); /* Get Bank Result */
    idx_bank++; /* Next bank */
    config_done = 0;
  }

  /* Process objects, DxS and ECS
     Check if all banks have been acquired
  */
  if (idx_bank > TSLPRM_TOTAL_BANKS-1)
  {
    /* Reset flags for next banks acquisition */
    idx_bank = 0;
    config_done = 0;
    
    /* Process Objects */
    TSL_obj_GroupProcess(&MyObjGroup);
    
    /* DxS processing (if TSLPRM_USE_DXS option is set) */
    /*TSL_dxs_FirstObj(&MyObjGroup);*/
    
    /* ECS every 100ms */
    if (TSL_tim_CheckDelay_ms(100, &Gv_ECS_last_tick) == TSL_STATUS_OK)
    {
      TSL_ecs_Process(&MyObjGroup);
    }
    
    status = TSL_STATUS_OK; /* All banks have been acquired and sensors processed */
    
  }
  else
  {
    status = TSL_STATUS_BUSY;
  }
  
  return status;
}
Beispiel #2
0
/**
  * @brief  Acquisition completed callback in non blocking mode 
  * @param  htsc: pointer to a TSC_HandleTypeDef structure that contains
  *         the configuration information for the specified TSC.
  * @retval None
  */
void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef* htsc)
{
  static __IO TSL_tTick_ms_T ECSLastTick; /* Hold the last time value for ECS */
  
  /* Discharge all capacitors */
#if TSLPRM_IODEF > 0
  __HAL_TSC_SET_IODEF_OUTPPLOW(&TscHandle);
#endif
                         
  TSL_acq_BankGetResult(idx_bank++, 0, 0); /* Read current bank result */
    
  /* Check if we have acquired all the banks */
  if (idx_bank > TSLPRM_TOTAL_BANKS - 1)
  {
    /* Process the objects state machine, DxS and ECS */
    TSL_obj_GroupProcess(&MyObjGroup);
    TSL_dxs_FirstObj(&MyObjGroup);
    if (TSL_tim_CheckDelay_ms(100, &ECSLastTick) == TSL_STATUS_OK)
    {
      if(TSL_ecs_Process(&MyObjGroup) == TSL_STATUS_OK)
      {
        BSP_LED_Toggle(LED6);
      }
      else
      {
        BSP_LED_Off(LED6);
      }
    }
    /* Start again with the first bank */
    idx_bank = 0;    
  }

  /* Configure bank */
  TSL_acq_BankConfig(idx_bank);
  
  /* Start bank acquisition in Interrupt mode */
  TSL_acq_BankStartAcq_IT();
}
Beispiel #3
0
/**
  * @brief  Execute STMTouch Driver main State machine
  * @param  None
  * @retval status Return TSL_STATUS_OK if the acquisition is done
  */
tsl_user_status_t tsl_user_Exec(void)
{
  static uint32_t idx_bank = 0;
  static uint32_t config_done = 0;
  tsl_user_status_t status = TSL_USER_STATUS_BUSY;

  /* Configure and start bank acquisition */
  if (!config_done)
  {
    TSL_acq_BankConfig(idx_bank);
    TSL_acq_BankStartAcq();
    config_done = 1;
  }

  /* Check end of acquisition (polling mode) and read result */
  if (TSL_acq_BankWaitEOC() == TSL_STATUS_OK)
  {
    STMSTUDIO_LOCK;
    TSL_acq_BankGetResult(idx_bank, 0, 0);
    STMSTUDIO_UNLOCK;
    idx_bank++; /* Next bank */
    config_done = 0;
  }

  /* Process objects, DxS and ECS
     Check if all banks have been acquired
  */
  if (idx_bank > TSLPRM_TOTAL_BANKS-1)
  {
    /* Reset flags for next banks acquisition */
    idx_bank = 0;
    config_done = 0;
    
    /* Process Objects */
    TSL_obj_GroupProcess(&MyObjGroup);
    
    /* DxS processing (if TSLPRM_USE_DXS option is set) */
    TSL_dxs_FirstObj(&MyObjGroup);
    
    /* ECS every 100ms */
    if (TSL_tim_CheckDelay_ms(100, &ECSLastTick) == TSL_STATUS_OK)
    {
      if (TSL_ecs_Process(&MyObjGroup) == TSL_STATUS_OK)
      {
        status = TSL_USER_STATUS_OK_ECS_ON;
      }
      else
      {
        status = TSL_USER_STATUS_OK_ECS_OFF;
      }
    }
    else
    {
      status = TSL_USER_STATUS_OK_NO_ECS;
    }
  }
  else
  {
    status = TSL_USER_STATUS_BUSY;
  }
  
  return status;
}
Beispiel #4
0
/**
  * @brief  Execute STMTouch Driver main State machine
  * @param  None
  * @retval status Return TSL_STATUS_OK if the acquisition is done
  */
TSL_Status_enum_T TSL_user_Action(void)
{
  static uint8_t idx_bank=0;
  static uint8_t ConfigDone=0;
  TSL_Status_enum_T status;
  
  if(!ConfigDone)
  {
    // Configure Bank
    TSL_acq_BankConfig(idx_bank);
 
    // Start Bank acquisition
    TSL_acq_BankStartAcq();
    
    // Set flag
    ConfigDone=1;
  }
  
  // Check Bank End of Acquisition
  if (TSL_acq_BankWaitEOC() == TSL_STATUS_OK)
  {
    // Get Bank Result
    TSL_acq_BankGetResult(idx_bank, 0, 0);
    ConfigDone=0;
    idx_bank++;
  }
  

  if(idx_bank == TSLPRM_TOTAL_BANKS)
  {
    idx_bank=0;
    
    // Process Objects
    TSL_obj_GroupProcess(&MyObjGroup);
  
    // DxS processing
    // Warning: TSLPRM_USE_DXS must be set !!!
    TSL_dxs_FirstObj(&MyObjGroup);

    // ECS every 100ms
    if (TSL_tim_CheckDelay_ms(100, &ECS_last_tick) == TSL_STATUS_OK)
    {
      LED_BLUE_TOGGLE;
      if (TSL_ecs_Process(&MyObjGroup) == TSL_STATUS_OK)
      {
        LED_GREEN_ON;
        process_sensor = 0;
      }
      else
      {
        LED_GREEN_OFF;
        process_sensor = 1;
      }
    }

    
    status = TSL_STATUS_OK; // All banks have been acquired and sensors processed
    
  }
  else
  {
    status = TSL_STATUS_BUSY;
  }
  
  return status;
}