Ejemplo n.º 1
0
void ICACHE_FLASH_ATTR
MQTT_Disconnect(MQTT_Client *mqttClient)
{
	mqttClient->connState = TCP_DISCONNECTING;
	xSemaphoreGive(mqttClient->mqttTaskSem);
	xTimerStop(mqttClient->mqttTimer, portMAX_DELAY);
}
Ejemplo n.º 2
0
void vModeAstroPause(void)
{
    if (state == MODE_ASTRO_STATE_STOP) return;
    if (bModeAstroIsPaused()) return;
    
    xTimerStop(xModeAstroControlTimer, 0);
}
Ejemplo n.º 3
0
static void gprs_sent_timeout_cb(TimerHandle_t timer)
{
	xTimerStop(timer, 0);
	osel_memset(recv.buf, 0 , SIZE);
	recv.offset = 0;
	xSemaphoreGive(gprs_mutex);
}
Ejemplo n.º 4
0
static void poll_ip6_addr(TimerHandle_t pxTimer){
    struct netif *netif_arg = (struct netif *) pvTimerGetTimerID( pxTimer ); 
    bool slaac_done = false;

    //0th  address is link local, assume 1th address is SLAAC
    for(int i = 0; i < 4; i++){
        if(netif_arg->ip6_addr[1].addr[i] != 0){
            slaac_done = true;
            break;
        }
    }
    if(slaac_done){
        for(int i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++){
            uart_printf("IPv6 Address %d of interface %c%c set "
                    "to %04hx:%04hx:%04hx:%04hx:%04hx:%04hx:%04hx:%04hx\n",
                    i,
                    netif_arg->name[0], netif_arg->name[1],
                    IP6_ADDR_BLOCK1(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK2(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK3(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK4(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK5(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK6(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK7(&netif_arg->ip6_addr[i]),
                    IP6_ADDR_BLOCK8(&netif_arg->ip6_addr[i]));
        }
        xTimerStop( pxTimer, 0 );
    }
}
Ejemplo n.º 5
0
void vModeSmsPause(void)
{
    if (state == MODE_SMS_STATE_STOP) return;
    if (bModeSmsIsPaused()) return;
    
    xTimerStop(xModeSmsControlTimer, 0);
}
Ejemplo n.º 6
0
int os_timer_change(os_timer_t timer, os_timer_change_t change, bool fromISR, unsigned period, unsigned block, void* reserved)
{
    portBASE_TYPE woken;
    switch (change)
    {
    case OS_TIMER_CHANGE_START:
        if (fromISR)
            return xTimerStartFromISR(timer, &woken)!=pdPASS;
        else
            return xTimerStart(timer, block)!=pdPASS;

    case OS_TIMER_CHANGE_RESET:
        if (fromISR)
            return xTimerResetFromISR(timer, &woken)!=pdPASS;
        else
            return xTimerReset(timer, block)!=pdPASS;

    case OS_TIMER_CHANGE_STOP:
        if (fromISR)
            return xTimerStopFromISR(timer, &woken)!=pdPASS;
        else
            return xTimerStop(timer, block)!=pdPASS;

    case OS_TIMER_CHANGE_PERIOD:
        if (fromISR)
            return xTimerChangePeriodFromISR(timer, period, &woken)!=pdPASS;
        else
            return xTimerChangePeriod(timer, period, block)!=pdPASS;
    }
    return -1;
}
Ejemplo n.º 7
0
void vModeVideoPause(void)
{
    if (state == MODE_VIDEO_STATE_STOP) return;
    if (bModeVideoIsPaused()) return;
    
    xTimerStop(xModeVideoControlTimer, 0);
}
Ejemplo n.º 8
0
static void prvTimerCallback( TimerHandle_t xExpiredTimer )
{
UBaseType_t *puxVariableToIncrement;
BaseType_t xReturned;

	/* The timer callback just demonstrates it is executing by incrementing a
	variable - the address of which is passed into the timer as its ID.  Obtain
	the address of the variable to increment. */
	puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );

	/* Increment the variable to show the timer callback has executed. */
	( *puxVariableToIncrement )++;

	/* If this callback has executed the required number of times, stop the
	timer. */
	if( *puxVariableToIncrement == staticMAX_TIMER_CALLBACK_EXECUTIONS )
	{
		/* This is called from a timer callback so must not block.  See
		http://www.FreeRTOS.org/FreeRTOS-timers-xTimerStop.html */
		xReturned = xTimerStop( xExpiredTimer, staticDONT_BLOCK );

		if( xReturned != pdPASS )
		{
			xErrorOccurred = pdTRUE;
		}
	}
}
Ejemplo n.º 9
0
static void cipsend_ok_cb(void)         //3分钟没有喂狗说明GPRS流程出现了问题
{
	xTimerStop(gprs_daemon_timer, 0);
	xSemaphoreGive(gprs_mutex);
	
	wdt_clear(SOFT_WDT);
}
Ejemplo n.º 10
0
/**@brief Stop a FreeRTOS timer.
 *
 * @param[in]  p_timer_id        Id of timer.
 *
 * @return     NRF_SUCCESS on success, otherwise error code.
 */
uint32_t app_timer_stop(TimerHandle_t timer_id)
{
    if( xTimerStop(timer_id, NULL) != pdPASS )
        return NRF_ERROR_NOT_FOUND;
    else
        return NRF_SUCCESS;
}
Ejemplo n.º 11
0
static int logDeleteBlock(int id)
{
  int i;
  struct log_ops * ops;
  struct log_ops * opsNext;
  
  for (i=0; i<LOG_MAX_BLOCKS; i++)
    if (logBlocks[i].id == id) break;
  
  if (i >= LOG_MAX_BLOCKS) {
    ERROR("trying to delete block id %d that doesn't exist.", id);
    return ENOENT;
  }
  
  ops = logBlocks[i].ops;
  while (ops)
  {
    opsNext = ops->next;
    opsFree(ops);
    ops = opsNext;
  }
  
  if (logBlocks[i].timer != 0) {
    xTimerStop(logBlocks[i].timer, portMAX_DELAY);
    xTimerDelete(logBlocks[i].timer, portMAX_DELAY);
    logBlocks[i].timer = 0;
  }
  
  logBlocks[i].id = BLOCK_ID_FREE;
  return 0;
}
Ejemplo n.º 12
0
uint32_t app_timer_stop(app_timer_id_t timer_id)
{
    app_timer_info_t * pinfo = (app_timer_info_t*)(timer_id);
    TimerHandle_t hTimer = pinfo->osHandle;
    if (hTimer == NULL)
    {
        return NRF_ERROR_INVALID_STATE;
    }

    if (__get_IPSR() != 0)
    {
        BaseType_t yieldReq = pdFALSE;
        if (xTimerStopFromISR(timer_id, &yieldReq) != pdPASS)
        {
            return NRF_ERROR_NO_MEM;
        }
        portYIELD_FROM_ISR(yieldReq);
    }
    else
    {
        if (xTimerStop(timer_id, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS)
        {
            return NRF_ERROR_NO_MEM;
        }
    }

    pinfo->active = false;
    return NRF_SUCCESS;
}
Ejemplo n.º 13
0
/*-------------------------------------------
| Name:rttmr_stop
| Description:
| Parameters:
| Return Type:
| Comments:
| See:
---------------------------------------------*/
int rttmr_stop(tmr_t* tmr){
   if(!tmr)
      return -1;
#ifdef __KERNEL_UCORE_FREERTOS
   while(xTimerStop(tmr, 10 )!=pdPASS);
#endif
   return 0;
}
Ejemplo n.º 14
0
 void beepTimerCallback( xTimerHandle pxTimer )
 {
     /* Optionally do something if the pxTimer parameter is NULL. */
     configASSERT( pxTimer );
 	 OC1CON2bits.OCTRIS = 1;// disable output
     xTimerStop( pxTimer, 0 );
 
 }
Ejemplo n.º 15
0
static QState Tag_CarReady(Tag * const me) {
  QState status;
  //uint8 tem;
  switch (Q_SIG(me))
  {
  case Q_ENTRY_SIG:
    {
      LED_READY_ON();
      xTimerStart( xTimers[0], 0 );
      printf("car ready\r\n");
      status = Q_HANDLED();
      break;
    }
  case Q_START_SIG:
    {
      status = Q_TRAN(&Tag_Charging);
      break;
    }

  case Q_CHECK_SERVER_SIG:
    {
       if(g_charging_en)
       {
         status = Q_TRAN(&Tag_Charging);
       }
       else
       {
         status = Q_HANDLED();
       }
      break;
    }

  case Q_CAR_DETECTED_SIG:
    {
      status = Q_TRAN(&Tag_CarDetected);
      break;
    }
  case Q_STANDBY_SIG:
    {
      status = Q_TRAN(&Tag_Standby);
      break;
    }
  case Q_EXIT_SIG:
    {
      xTimerStop( xTimers[0], 0 );
      LED_READY_OFF();
      status = Q_HANDLED();
      break;
    }

  default:
    {
      status = Q_SUPER(&Tag_Active);
      break;
    }
  }
  return status;
}
Ejemplo n.º 16
0
wiced_result_t wiced_rtos_stop_timer( wiced_timer_t* timer )
{
    if ( xTimerStop( timer->handle, WICED_WAIT_FOREVER ) != pdPASS )
    {
        return WICED_ERROR;
    }

    return WICED_SUCCESS;
}
void DeInitTimer(Timer* timer)
{

// 	printf("DeInitTimer\r\n");
//	printf("DeInitTimer: %d\r\n", pvTimerGetTimerID(((st_TimerHandle_t *)*timer)->xTimer ));
	AllocatedTimerIndex--;
	xTimerStop( ((pst_TimerHandle_t)*timer)->xTimer, 0 );
	((pst_TimerHandle_t)*timer)->TimeToExpire = 0;
	((pst_TimerHandle_t)*timer)->Allocated = 0;
}
Ejemplo n.º 18
0
static void lora_recv_timeout_cb(TimerHandle_t timer)
{
    xTimerStop(lora_daemon_timer, 0);
    //*< rxok event
    lora_recv_rxok_flag = TRUE;

    if (lora_mode != SETTING_MODE)
    {
        if (lora_int_reg[1] != NULL)
        {
            (*(lora_int_reg[1]))(0x0000);    //*< rxok
        }
    }
}
Ejemplo n.º 19
0
static int logStopBlock(int id)
{
  int i;
  
  for (i=0; i<LOG_MAX_BLOCKS; i++)
    if (logBlocks[i].id == id) break;
  
  if (i >= LOG_MAX_BLOCKS) {
    ERROR("Trying to stop block id %d that doesn't exist.\n", id);
    return ENOENT;
  }
  
  xTimerStop(logBlocks[i].timer, portMAX_DELAY);
  
  return 0;
}
Ejemplo n.º 20
0
void vModeVideoStop(void)
{
    taskENTER_CRITICAL();
    {
        xTimerStop(xModeVideoControlTimer, 0);
        
        for (uint8_t motor = 0; motor < SM_MOTORS_USED; motor++)
        {
            vSmStop(motor);
            if (eep_params.sm[motor].power_save == 0) vSmEnable(motor, 0);
        }
        state = MODE_VIDEO_STATE_STOP;
        finished = true;
    }
    taskEXIT_CRITICAL();
}
Ejemplo n.º 21
0
/// Stop the timer.
/// \param[in]     timer_id      timer ID obtained by \ref osTimerCreate.
/// \return status code that indicates the execution status of the function.
/// \note MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS.
osStatus osTimerStop (osTimerId timer_id)
{
    portBASE_TYPE taskWoken = pdFALSE;
    osStatus result = osOK;

    if (inHandlerMode()) {
        xTimerStopFromISR(timer_id, &taskWoken);
        portEND_SWITCHING_ISR(taskWoken);
    }
    else {
        if (xTimerStop(timer_id, 0) != pdPASS) {    //TODO: add timeout support
            result = osErrorOS;
        }
    }

    return result;
}
Ejemplo n.º 22
0
void recue_tim_func(TimerHandle_t timer)
{
	configASSERT(timer);

	if(jar_status != FULL)
	{
		TIM_Cmd(TIM17, DISABLE);
		TIM_CtrlPWMOutputs(TIM17, DISABLE);

		GPIO_ResetBits(GPIOA, (GPIO_Pin_9));
		GPIO_SetBits(GPIOA, GPIO_Pin_10);

		xTimerStop(recue_tim_handler, 0);
		vTaskSuspend(blink_handler);
		jar_status = FULL;
	}
}
Ejemplo n.º 23
0
void vModeSmsStop(void)
{
    taskENTER_CRITICAL();
    {
        xTimerStop(xModeSmsControlTimer, 0);
        
        for (uint8_t motor = 0; motor < SM_MOTORS_USED; motor++)
        {
            vSmStop(motor);
            if (eep_params.sm[motor].power_save == 0) vSmEnable(motor, 0);
        }
        vCamClear();
        test_mode = mode_smsTEST_NONE;
        state = MODE_SMS_STATE_STOP;
        finished = true;
    }
    taskEXIT_CRITICAL();
}
/**
* @brief  Stop a timer.
* @param  timer_id      timer ID obtained by \ref osTimerCreate
* @retval  status code that indicates the execution status of the function.
* @note   MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS.
*/
osStatus osTimerStop (osTimerId timer_id)
{
  osStatus result = osOK;
#if (configUSE_TIMERS == 1)  
  portBASE_TYPE taskWoken = pdFALSE;

  if (inHandlerMode()) {
    xTimerStopFromISR(timer_id, &taskWoken);
    portEND_SWITCHING_ISR(taskWoken);
  }
  else {
    if (xTimerStop(timer_id, 0) != pdPASS) {
      result = osErrorOS;
    }
  }
#else 
  result = osErrorOS;
#endif 
  return result;
}
Ejemplo n.º 25
0
void stop_filling(void * pvParameters )
{
	for(;;)
	{
		if (xSemaphoreTake(full_sem, portMAX_DELAY) == pdPASS)
		{
			if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1) == SET)
			{
				jar_status = FULL;
				TIM_Cmd(TIM17, DISABLE);
				TIM_CtrlPWMOutputs(TIM17, DISABLE);
				TIM17->CCR1 = MOTOR_PWM_PERIOD;
				vTaskSuspend(blink_handler);
				GPIO_ResetBits(GPIOA, (GPIO_Pin_9 | GPIO_Pin_10));
				xTimerStop(recue_tim_handler, 0);
			}
		}
	}
	vTaskDelete(NULL);
}
Ejemplo n.º 26
0
/* Overridden weak function, from hw_rf.c*/
bool hw_rf_preoff_cb(void)
{
        /* Default sleep duration value is UINT_MAX. This value
         * marks that the MACs either never sleep, or don't
         * want to be waken up by a timer.
         */
        uint32_t sleep_duration_in_lp = UINT32_MAX;

        /* Stop recalib timer */
        if (dg_configRF_RECALIBRATION_TIMER_TIMEOUT > 0) {
                if (recalib_timer != NULL) {
                        if (is_called_from_isr()) {
                                BaseType_t xHigherPriorityTaskWoken;
                                xTimerStopFromISR(recalib_timer, &xHigherPriorityTaskWoken);
                                portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
                        } else {
                                xTimerStop(recalib_timer, portMAX_DELAY);
                        }
                }
        }

        if (dg_configRF_ENABLE_RECALIBRATION == 0) {
                return false;
        }

#if   defined(CONFIG_USE_BLE)
        uint32_t ble_wakeup = pm_get_mac_wakeup_time(PM_BLE_ID);

        sleep_duration_in_lp = get_distance(ble_wakeup);

#endif

        if (ad_rf_check_calibration(sleep_duration_in_lp) == true) {

                ad_rf_start_and_check_calibration();
                return true;
        }

        return false;
}
Ejemplo n.º 27
0
//*****************************************************************************
//
//! \brief Dalay some time in ms.
//!
//! \param ulDelay is the delay number of ms.
//!
//! \return None.
//
//*****************************************************************************
void
DelayMS(unsigned long ulDelay)
{
    //
    // Set the timer clock
    //
    xSysCtlPeripheralClockSourceSet(LPR5150AL_TIMER_CLK, 1);

    xSysCtlPeripheralEnable2(LPR5150AL_TIMER_BASE);

	//
	// Clear the status first
	//
	xTimerStatueClear(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0, xTIMER_INT_MATCH);

    //
    // Config as periodic mode
    //
    xTimerInitConfig(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0, xTIMER_MODE_PERIODIC, 1000);
    xTimerIntEnable(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0, xTIMER_INT_MATCH);
    xTimerStart(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0);

    //
    // Delay ulDelay cycles, one cycle delay is 1ms.
    //
    while(ulDelay)
	{
	    while(!xTimerStatusGet(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0, xTIMER_INT_MATCH));
		xTimerStatueClear(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0, xTIMER_INT_MATCH);
		ulDelay--;
	}

    //
    // Stop the timer
    //
	xTimerStop(LPR5150AL_TIMER_BASE, xTIMER_CHANNEL0);
	xSysCtlPeripheralDisable2(LPR5150AL_TIMER_BASE);

}
Ejemplo n.º 28
0
//*****************************************************************************
//
//! \brief xtimer 002 test execute main body.
//!
//! \return None.
//
//*****************************************************************************
static void xTimer002Execute(void)
{
    unsigned long ulTemp;
    unsigned long ulBase;
    int i;

    //
    // Periodic mode
    //
    for(i = 0; i < 2; i++)
    {
        ulBase = ulTimerBase[i];
        ulTemp = 0;
        
        //
        // Clear the flag first
        //
        TimerIntClear(ulBase, TIMER_INT_UEV1);
        
        //
        // Config as periodic mode
        //
        xTimerInitConfig(ulBase, xTIMER_CHANNEL0, xTIMER_MODE_PERIODIC | xTIMER_COUNT_UP, 1000); 
		xTimerMatchSet(ulBase, xTIMER_CHANNEL0, 1000);
		xTimerPrescaleSet(ulBase, xTIMER_CHANNEL0, 8);
		   
        xTimerIntCallbackInit(ulBase, TimerCallbackFunc[i]);
        xTimerIntEnable(ulBase, xTIMER_CHANNEL0, xTIMER_INT_MATCH);
        xIntEnable(ulTimerIntID[i]);

        xTimerStart(ulBase, xTIMER_CHANNEL0);
        

        TestAssertQBreak("b","Intterrupt test not happen", 0xfffffffe);
        xTimerStop(ulBase, xTIMER_CHANNEL0);       
    }
    
}
Ejemplo n.º 29
0
void PX4FMU::work_stop()
{
	xTimerStop(_work, portMAX_DELAY);

	for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) {
		if (_control_subs[i] > 0) {
			::close(_control_subs[i]);
			_control_subs[i] = -1;
		}
	}

	::close(_armed_sub);
	//::close(_param_sub);

	/* make sure servos are off */
	up_pwm_servo_deinit();

	DEVICE_LOG("stopping\n");

	/* note - someone else is responsible for restoring the GPIO config */

	/* tell the dtor that we are exiting */
	_initialized = false;
}
Ejemplo n.º 30
0
static void prvTimerCallback( TimerHandle_t xExpiredTimer )
{
UBaseType_t *puxVariableToIncrement;
BaseType_t xReturned;

	/* Obtain the address of the variable to increment from the timer ID. */
	puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );

	/* Increment the variable to show the timer callback has executed. */
	( *puxVariableToIncrement )++;

	/* If this callback has executed the required number of times, stop the
	timer. */
	if( *puxVariableToIncrement == staticMAX_TIMER_CALLBACK_EXECUTIONS )
	{
		/* This is called from a timer callback so must not block. */
		xReturned = xTimerStop( xExpiredTimer, staticDONT_BLOCK );

		if( xReturned != pdPASS )
		{
			xErrorOccurred = pdTRUE;
		}
	}
}