コード例 #1
0
ファイル: leds.c プロジェクト: marcaz/Fleet
__task void LED_TOGGLE (void) {
	//----------------------------------------------------------------
	uint8_t led_timer = 0;
   //----------------------------------------------------------------
	put_log("[LED]: LED Task Started...\r\n");
	//----------------------------------------------------------------
	for (;;) {
		//----------------------------------------------------------------
		os_dly_wait(20);
		//----------------------------------------------------------------
		led_timer++;
		//----------------------------------------------------------------
		if(led_timer==3 || led_timer==4){
			//----------------------------------------------------------------
			tmr1 = os_tmr_create (5, MAIN_LED_OFF_TMO);
			if (tmr1 != NULL) {
				GPIOD->BSRRL = GPIO_Pin_12;
			}
			//----------------------------------------------------------------
			if(led_timer==4){
				led_timer = 0;
			}
			//----------------------------------------------------------------
		}
		//----------------------------------------------------------------
	}
	//----------------------------------------------------------------
}
コード例 #2
0
ファイル: LLMJVM_RTX.c プロジェクト: jfazli/PE208
int32_t LLMJVM_IMPL_scheduleRequest(int64_t absoluteTime){
	int64_t relativeTime;
	int64_t relativeTick;//number of ticks before absoluteTime

	//First check if absolute time is lower than current schedule time
	if(absoluteTime < LLMJVM_RTX_nextWakeupTime){
		if(LLMJVM_RTX_currentTimerID != NULL)
			os_tmr_kill(LLMJVM_RTX_currentTimerID);//kill potential previously scheduled timer
		LLMJVM_RTX_nextWakeupTime = absoluteTime;

		relativeTime = absoluteTime - LLMJVM_IMPL_getCurrentTime(MICROEJ_TRUE);
		relativeTick = LLMJVM_RTX_timeToTick(relativeTime);  //number of ticks before absoluteTime

		//Checks if absoluteTick has already been reached
		if(relativeTick > 0){
			if(relativeTick > UINT16_MAX)
				relativeTick = UINT16_MAX;//saturate relativeTick value to 16 bits
 
			LLMJVM_RTX_currentTimerID = os_tmr_create((U16)relativeTick, LLMJVM_RTX_TIMER_INFO);

			if(LLMJVM_RTX_currentTimerID == NULL)
				return LLMJVM_ERROR;
			else
				return LLMJVM_OK;
		}
		else {
			//absoluteTick has been reached, notify the vm now
			return LLMJVM_schedule();
		}
	}

	return LLMJVM_OK;
}
コード例 #3
0
/****************************************************************************************************
 * @fn      ASFTimerStart
 *          Creates a new timer in the system with the given attributes.
 *
 * @param   pTimer  Pointer to timer control block containing the attributes of the timer to be
 *                  created.
 *
 * @return  none
 *
 * @see     ASFDeleteTimer()
 ***************************************************************************************************/
static void _TimerStart ( AsfTimer *pTimer, char *_file, int _line )
{
    uint16_t info = (uint16_t)((uint32_t)pTimer); //We only need to store the LSB16 of the pointer as the system RAM is < 64K
    ASF_assert( pTimer != NULLP );
    ASF_assert( pTimer->sysUse != TIMER_SYS_ID ); //In case we are trying to restart a running timer
    pTimer->sysUse = TIMER_SYS_ID;
    pTimer->timerId = os_tmr_create( pTimer->ticks, info );
    ASF_assert( pTimer->timerId != NULL );
}
コード例 #4
0
__task void timer_1s_task(void){
  for(;;){
		//PTB->PTOR = PIN_18_MASK;		
		if( os_tmr_create(1000, st_diag_id) == NULL )	//	0x03e8 = 1000 = 1 секунда
      os_tsk_delete_self();
		else
			os_evt_wait_or(st_diag_id, 0xffff);
  }
}