示例#1
0
void channelhop()
{ 

 uint8_t channel;
 
 while (1)
 {
	 
 
 for (channel = 11;channel <25;channel++)
 {
  lib_sleep_thread(1000);
 lib_radio_set_channel(channel); 
  
 lib_radio_send_string("Hello, world!\n"); 
 lib_yellow_toggle();
  
 }
 
 } 
 channel = 21; 
 lib_radio_set_channel(channel); 
 return; 

}
void testcounter()
{



    uint8_t ledcounter;
    counter = 0;




    while (1)
    {

        lib_sleep_thread(500);

        buffersum[0] = getNodeID();

        lib_get_radio_lock();
        lib_radio_set_channel(19);
        buffersum[1] = counter;
        lib_radio_send_msg(0xffff, 0xffff, 8, (uint8_t *)buffersum);
        lib_release_radio_lock();
        counter++;


        if (counter&0x1)
            lib_red_on();
        else
            lib_red_off();

        if (counter&0x2)
            lib_green_on();
        else
            lib_green_off();

        if (counter&0x04)
            lib_yellow_on();
        else
            lib_yellow_off();

    }

    return;
}
示例#3
0
//This function is called from the particular implementation!
//This function also contains platform related defintions 
//0, 1, 2, AND 10, 11 are reserved. User is suggested to start with id 20. 
inline result_t GenericTimerFired(uint8_t id)
{


    unsigned char result;
    
    //0, 1, 2 for threads
    switch (id)
    {
    case 0:
        ServiceTimerFired(0);
        break;
    case 1:
        ServiceTimerFired(1);
         break;
    case 2:
        ServiceTimerFired(2);
        break;
    case 3:
        ServiceTimerFired(3);
        break;
    case 4:
        ServiceTimerFired(4);
        break;
    case 5:
        ServiceTimerFired(5);
        break;
    case 6:
        ServiceTimerFired(6);
        break;
    case 7:
        ServiceTimerFired(7);
        break;
    case 9:

#ifdef PLATFORM_CPU_MEASURE
        
		cpucounter_history[loop++] = cpucounter; 
		cpucounter = 0; 
		if (loop == 20)
		loop = 0; 
             
        
#endif


        break;
#if defined(PLATFORM_AVR) && defined(RADIO_CC2420)
    case 10:
        hplcc2420interruptm_FIFOTimer_fired();
        break;
    case 11:
        hplcc2420interruptm_CCATimer_fired();
        break;
#endif
   case 12:
        #ifdef ENERGY_SHARE_SCHEDULING
        
         {energy_manager_increase_round();   
		  postTask(thread_task, 9);  
           
         }  
        #endif 		
			
		
	   break;  	  
    
	case 13:
        #ifdef TRACE_MEMORY_CONTENTS
          memoryReportTimerFired();
        #endif 
		
	    break; 
		
	case 14:
	    #ifdef TRACE_ENABLE
		 reportTrace();
		#endif 
		
		#ifdef BASE_MODE		
		restoreRadioState();
		#endif
	    
		break; 
		
	case 15:
	
		
		break; 	
		
	case 16:
	    
		#ifdef TRACE_MEMORY_CONTENTS
		  AMStandard_releaseLock();
		  lib_radio_set_channel(21); 
		 #endif 
		break;
		
		
    default:
        timercallbackinvoke(id);
        result = SUCCESS;
    }
    return SUCCESS;
}