Esempio n. 1
0
int main ()
{

  // init phoenix
  phoenix_init();
  
  nrk_setup_ports ();
  nrk_setup_uart (UART_BAUDRATE_115K2);

  nrk_init ();

  nrk_led_clr (0);
  nrk_led_clr (1);
  nrk_led_clr (2);
  nrk_led_clr (3);

  nrk_time_set (0, 0);

  bmac_task_config ();

  nrk_create_taskset ();
  nrk_start ();

  return 0;
}
Esempio n. 2
0
File: main.c Progetto: vishnudh/RTOS
int main ()
{
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);
  nrk_init_hardware();
  nrk_init();

  nrk_led_clr(BLUE_LED);
  nrk_led_clr(GREEN_LED);
  nrk_led_clr(RED_LED);

  nrk_time_set(0,0);
  nrk_create_taskset ();

  for (uint16_t task_ID = 1; task_ID <= 3; task_ID++) {
	  nrk_kprintf("InitT");
	  nrk_printnum((uint32_t)task_ID);
	  nrk_kprintf(":NP:");
	  nrk_printnum((uint32_t)nrk_task_TCB[task_ID].next_period);
	  nrk_kprintf("\r\n");
  }

  nrk_start();

  return 0;
}
Esempio n. 3
0
int main ()
{
  nrk_setup_ports ();
  nrk_setup_uart (UART_BAUDRATE_115K2);

  nrk_init ();

  nrk_led_clr (0);
  nrk_led_clr (1);
  nrk_led_clr (2);
  nrk_led_clr (3);

  nrk_time_set (0, 0);

  tdma_mode_set(TDMA_MASTER);

  // use tdma's tree scheduler
  tdma_schedule_method_set(TDMA_SCHED_TREE);

  tdma_task_config ();

  nrk_create_taskset ();

  nrk_start ();

  return 0;
}
Esempio n. 4
0
int
main ()
{
  uint16_t div;
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);

  printf( "Starting up...\r\n" );

	
  nrk_init();

  nrk_led_clr(0);
  nrk_led_clr(1);
  nrk_led_clr(2);
  nrk_led_clr(3);
  
  nrk_time_set(0,0);

  
  rtl_task_config();
  
  nrk_create_taskset ();

  nrk_start();
  
  return 0;
}
Esempio n. 5
0
int
main ()
{
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);

  TWI_Master_Initialise();
  sei();
  nrk_led_set(RED_LED);
  /* initialize the adxl345 */
  init_adxl345();
  init_itg3200();
  init_hmc5843();
  nrk_init();

  nrk_led_clr(ORANGE_LED);
  nrk_led_clr(BLUE_LED);
  nrk_led_clr(GREEN_LED);
  nrk_led_clr(RED_LED);
 
  nrk_time_set(0,0);
  nrk_create_taskset ();
  nrk_start();
  
  return 0;
}
Esempio n. 6
0
int
main ()
{
  uint8_t t;
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);

  printf( "Starting up...\r\n" );

  nrk_init();

  nrk_led_clr(ORANGE_LED);
  nrk_led_clr(BLUE_LED);
  nrk_led_set(GREEN_LED);
  nrk_led_clr(RED_LED);
 
  nrk_time_set(0,0);
  nrk_create_taskset ();

  my_semaphore = nrk_sem_create(1,4);
  if(my_semaphore==NULL) nrk_kprintf( PSTR("Error creating sem\r\n" ));
  nrk_start();
  
  return 0;
}
Esempio n. 7
0
int main()
{
	// initialise the UART	
	nrk_setup_ports();  
	nrk_setup_uart(UART_BAUDRATE_115K2);
	
	// initialise the OS
	nrk_init();

	// clear all LEDs	
	nrk_led_clr(ORANGE_LED);		
   nrk_led_clr(BLUE_LED);			// will toggle whenever a packet is sent
   nrk_led_clr(GREEN_LED);			// will toggle whenever a packet is received
   nrk_led_clr(RED_LED);			// will light up on error
	  
	// start the clock	
	nrk_time_set(0,0);

	// initialise the network stack  	
	nrk_init_nw_stack();
	if(DEBUG_APP == 1)
		nrk_kprintf(PSTR("Network stack initialised\r\n"));
	
	nrk_create_taskset();		// create the set of tasks
	nrk_start();					// start this node
	
	return 0;
}
Esempio n. 8
0
int
main ()
{
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);
  
  nrk_init();
  
  nrk_led_clr(ORANGE_LED);
  nrk_led_clr(BLUE_LED);
  nrk_led_clr(GREEN_LED);
  nrk_led_clr(RED_LED);
  
  nrk_time_set(0,0);
  nrk_create_taskset();
  
// Semaphore initialization
  semaphore1 = nrk_sem_create(1,3);  
  semaphore2 = nrk_sem_create(1,5);
  semaphore3 = nrk_sem_create(1,1);

  nrk_start();
  
  return 0;
}
Esempio n. 9
0
int main ()
{
    nrk_setup_ports ();
    nrk_setup_uart (UART_BAUDRATE_115K2);

    nrk_init ();
    nrk_led_clr(ORANGE_LED);
    nrk_led_clr(GREEN_LED);
    nrk_led_clr(RED_LED);
    nrk_led_clr(BLUE_LED);

    nrk_time_set(0,0);

    bmac_task_config();
    nrk_create_taskset();

    lock = nrk_sem_create(1,2);
    if( lock==NULL ) {
        nrk_kprintf( PSTR("Error creating sem\r\n" ));
    }

    nrk_start();

    return 0;
}
Esempio n. 10
0
int main ()
{
  nrk_setup_ports ();
  nrk_setup_uart (UART_BAUDRATE_115K2);
  //  nrk_setup_uart (UART_BAUDRATE_230K4);
  nrk_setup_uart_gps(UART_BAUDRATE_115K2);

  TWI_Master_Initialise();
  grideye_addr = 0x68;

  printf ("Starting up...\r\n");

  nrk_init ();

  nrk_led_clr (ORANGE_LED);
  nrk_led_clr (BLUE_LED);
  nrk_led_clr (GREEN_LED);
  nrk_led_clr (RED_LED);

  nrk_time_set (0, 0);
  nrk_create_taskset ();
  nrk_start ();

  return 0;
}
Esempio n. 11
0
int main ()
{
    uint8_t ds;
    nrk_setup_ports ();
    nrk_setup_uart (UART_BAUDRATE_115K2);


    ds=nrk_eeprom_read_byte(EEPROM_SLEEP_STATE_ADDR);
    if(ds==1) deep_sleep_button();

    nrk_init ();

    nrk_led_clr (0);
    nrk_led_clr (1);
    nrk_led_clr (2);
    nrk_led_clr (3);

    nrk_time_set (0, 0);

    tdma_set_error_callback(&tdma_error);
    tdma_task_config();

    nrk_register_drivers();
    nrk_create_taskset ();
    nrk_start ();

    return 0;
}
Esempio n. 12
0
int
main ()
{
  uint8_t t;
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);
  oled_setup();
  nrk_init();

  nrk_gpio_direction(NRK_DEBUG_0, NRK_PIN_INPUT);
  nrk_gpio_direction(NRK_DEBUG_1, NRK_PIN_OUTPUT);
  oled_off();
  nrk_gpio_direction(NRK_DEBUG_2, NRK_PIN_INPUT);
  nrk_gpio_direction(NRK_DEBUG_3, NRK_PIN_INPUT);
  nrk_led_clr(ORANGE_LED);
  nrk_led_clr(BLUE_LED);
  nrk_led_clr(GREEN_LED);
  nrk_led_clr(RED_LED);
 
  nrk_time_set(0,0);
  bmac_task_config ();
  nrk_create_taskset ();
  nrk_start();
  
  return 0;
}
Esempio n. 13
0
int main ()
{
    nrk_setup_ports();
    nrk_setup_uart(UART_BAUDRATE_115K2);

    nrk_init();

    nrk_time_set(0,0);

    nrk_time_get(seed);
    srand(seed->nano_secs);

    //Initialize tasks 
    //Higher value higher priority`
    // INITIALIZE_TASK(1, BASIC_TASK);
    // INITIALIZE_TASK(2, CBS_TASK);
    // INITIALIZE_TASK(3, BASIC_TASK);

	INITIALIZE_TASK(1, CBS_TASK);
    	INITIALIZE_TASK(2, BASIC_TASK);
    	INITIALIZE_TASK(3, CBS_TASK);

    nrk_start();

    return 0;
}
Esempio n. 14
0
int main ()
{
  uint16_t div;
  nrk_setup_ports ();
  nrk_setup_uart (UART_BAUDRATE_115K2);
  begin();//start I2C

  nrk_init ();

  nrk_led_clr (0);
  nrk_led_clr (1);
  nrk_led_clr (2);
  nrk_led_clr (3);

  nrk_time_set (0, 0);

  tdma_set_error_callback(&tdma_error);
  tdma_task_config();

  //nrk_register_drivers();
  nrk_create_taskset ();
  nrk_start ();

  return 0;
}
Esempio n. 15
0
int
main ()
{
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);


DDRF=0xff;

while(1)
{
PORTF=0xff;
nrk_spin_wait_us(500);
PORTF=0x00;
nrk_spin_wait_us(500);

}

  nrk_init();

  nrk_led_clr(ORANGE_LED);
  nrk_led_clr(BLUE_LED);
  nrk_led_clr(GREEN_LED);
  nrk_led_clr(RED_LED);
 
  nrk_time_set(0,0);
  nrk_create_taskset ();
  nrk_start();
  
  return 0;
}
Esempio n. 16
0
int main() {
	nrk_setup_ports();
	nrk_setup_uart(UART_BAUDRATE_115K2);

	nrk_init();

	nrk_led_clr(ORANGE_LED);
	nrk_led_clr(BLUE_LED);
	nrk_led_clr(GREEN_LED);
	nrk_led_clr(RED_LED);

	nrk_time_set(0, 0);
	nrk_create_taskset();

//	sem1 = nrk_sem_create(1, 10);
	nrk_sem_list[0].value = 1;
	nrk_sem_list[0].count = 1;
	nrk_sem_list[0].resource_ceiling = 5;
	sem1 = nrk_sem_list;

	if (sem1 == NULL)
		printf("Creating sem error\n");
	nrk_start();

	return 0;
}
Esempio n. 17
0
int main ()
{
  nrk_setup_ports ();
  nrk_setup_uart (UART_BAUDRATE_115K2);

  nrk_init ();

  nrk_led_clr (0);
  nrk_led_clr (1);
  nrk_led_clr (2);
  nrk_led_clr (3);

  nrk_time_set (0, 0);

  tdma_mode_set(TDMA_SLAVE);

  // do the scheduling by yourself
  tdma_schedule_method_set(TDMA_SCHED_MANUAL);

  // rcv sync packet from master
  tdma_schedule_add(0, TDMA_RX, -1);

  // SCHEDULE A
  // add a TX slot for every tenth slot
  
  for (tdma_slot_t i = 10; i < TDMA_SLOTS_PER_CYCLE; i+=10)
  {
    tdma_schedule_add(i, TDMA_TX_PARENT, 0);
  }
  
  
  // SCHEDULE B
  // just do one slot
  //tdma_schedule_add(10, TDMA_TX_PARENT, 0);


  // SCHEDULE C
  // for node 2
  //  tdma_schedule_add(0, TDMA_RX, 0);
  //  tdma_schedule_add(10, TDMA_TX_PARENT, 0);
  //  tdma_schedule_add(100, TDMA_TX_CHILD, 0);

  // for node 3
    //tdma_schedule_add(20, TDMA_TX_PARENT, 0);
    //tdma_schedule_add(100, TDMA_RX, 0);




  tdma_task_config ();

  nrk_create_taskset ();

  nrk_start ();

  return 0;
}
Esempio n. 18
0
//------------------------------------------------------------------------------
//      void main (void)
//
//      DESCRIPTION:
//              Startup routine and main loop
//------------------------------------------------------------------------------
int main (void)
{
    uint8_t i,length;
    uint32_t cnt;

    nrk_setup_ports(); 
    nrk_setup_uart (UART_BAUDRATE_115K2);
 
    printf( "Basic TX...\r\n" ); 
    nrk_led_set(0); 
    nrk_led_set(1); 
    nrk_led_clr(2); 
    nrk_led_clr(3); 
/*
	    while(1) {
		   
				for(i=0; i<40; i++ )
					halWait(10000);
		    nrk_led_toggle(1);

	    }

*/

    rfRxInfo.pPayload = rx_buf;
    rfRxInfo.max_length = RF_MAX_PAYLOAD_SIZE;
		nrk_int_enable();
    rf_init (&rfRxInfo, 26, 0x2420, 0x1214);
    cnt=0;
    while(1){
	  		DPDS1 |= 0x3;
			DDRG |= 0x1;
			PORTG |= 0x1;
			DDRE|=0xE0;
			PORTE|=0xE0;
    		rfTxInfo.pPayload=tx_buf;
    		sprintf( tx_buf, "%lu", cnt); 
    		rfTxInfo.length= strlen(tx_buf) + 1;
				rfTxInfo.destAddr = 0x1215;
				rfTxInfo.cca = 0;
				rfTxInfo.ackRequest = 0;
				
				printf( "Sending\r\n" );
	//			nrk_gpio_set(NRK_DEBUG_0);
				if(rf_tx_packet(&rfTxInfo) != 1)
					printf("--- RF_TX ERROR ---\r\n");
	//			nrk_gpio_clr(NRK_DEBUG_0);
				cnt++;
		
				for(i=0; i<10; i++ )
					halWait(10000);
				nrk_led_toggle(RED_LED);
		}

}
Esempio n. 19
0
int main ()
{
    uint16_t div;

    nrk_int_disable();
    // Configure relay port directions
    DDRE |= 0x10;
    socket_0_enable();
    // Configure led port directions
    DDRE |= 0x0c;
    DDRD |= 0x00;
    PORTD |= 0xff;
    DDRF = 0;

    socket_0_active=nrk_eeprom_read_byte(EEPROM_STATE_ADDR);
    // turn outlet on if active or throttled for testing
    if(socket_0_active==1 || socket_0_active==2)
    {
        socket_0_enable();
        plug_led_green_set();
    } else
    {
        socket_0_disable();
        plug_led_green_clr();
    }
    // If PUD value set, then we expect it wasn't a clean reboot (unexpected restart).
    // Try to force a proper watchdog reboot
    if((MCUCR&0x10)!=0 )
    {
        //nrk_watchdog_enable();
        nrk_int_disable();
        MCUSR &= ~(1<<WDRF);
        WDTCSR |= (1<<WDCE) | (1<<WDE);
        WDTCSR = (1<<WDE) | (1<<WDP2) | (1<<WDP0);

        // Disable interrupts to stop pending timers etc
        while(1);
    }

    nrk_setup_uart (UART_BAUDRATE_115K2);

    MCUCR |= BM(PUD);

    nrk_init ();
    nrk_time_set (0, 0);

    tdma_set_error_callback(&tdma_error);
    tdma_task_config();

    nrk_create_taskset ();
    nrk_start ();

    return 0;
}
Esempio n. 20
0
//------------------------------------------------------------------------------
//      void main (void)
//
//      DESCRIPTION:
//              Startup routine and main loop
//------------------------------------------------------------------------------
int main (void)
{
    uint8_t cnt,i,length;

    nrk_setup_ports(); 
    nrk_setup_uart (UART_BAUDRATE_115K2);
 
    printf( "Basic TX...\r\n" ); 
    nrk_led_set(0); 
    nrk_led_set(1); 
    nrk_led_clr(2); 
    nrk_led_clr(3); 
/*
	    while(1) {
		   
				for(i=0; i<40; i++ )
					halWait(10000);
		    nrk_led_toggle(1);

	    }

*/

    rfRxInfo.pPayload = rx_buf;
    rfRxInfo.max_length = RF_MAX_PAYLOAD_SIZE;
		nrk_int_enable();
    rf_init (&rfRxInfo, 13, 0x2420, 0x1214);
    cnt=0;
    while(1){
				nrk_led_set(GREEN_LED);
    		rfTxInfo.pPayload=tx_buf;
    		sprintf( tx_buf, "This is my string counter %d", cnt); 
    		rfTxInfo.length= strlen(tx_buf) + 1;
				rfTxInfo.destAddr = 0x1215;
				rfTxInfo.cca = 0;
				rfTxInfo.ackRequest = 0;
				
				printf( "Sending\r\n" );
				nrk_gpio_set(NRK_DEBUG_0);
				if(rf_tx_packet(&rfTxInfo) != 1)
					printf("--- RF_TX ERROR ---\r\n");
				nrk_gpio_clr(NRK_DEBUG_0);
				cnt++;
		
				for(i=0; i<80; i++ )
					halWait(10000);
				nrk_led_clr(GREEN_LED);
				for(i=0; i<20; i++ )
					halWait(10000);
		}

}
Esempio n. 21
0
File: main.c Progetto: jnwu/nanork
int
main ()
{
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);

  nrk_init();

  nrk_time_set(0,0);
  nrk_create_taskset ();
  nrk_start();
  
  return 0;
}
Esempio n. 22
0
int main ()
{
  nrk_setup_ports ();
  nrk_setup_uart (UART_BAUDRATE_115K2);

  nrk_init ();

  nrk_led_clr (0);
  nrk_led_clr (1);
  nrk_led_clr (2);
  nrk_led_clr (3);

  nrk_time_set (0, 0);

  tdma_mode_set(TDMA_MASTER);

  // do the scheduling by yourself
  tdma_schedule_method_set(TDMA_SCHED_MANUAL);

  // send sync to child
  tdma_schedule_add(0, TDMA_TX_CHILD, 0);

  // SCHEDULE A
  // add a RX from child every tenth slot
  for (tdma_slot_t i = 10; i < TDMA_SLOTS_PER_CYCLE; i+=10)
  {
    tdma_schedule_add(i, TDMA_RX, 0);
  }
  
  
  // SCHEDULE B
  // rcv data from child. priority is ignored
  //tdma_schedule_add(10, TDMA_RX, -1);

  // SCHEDULE C: Sync Test
  // Add 2 RX slots from children from level 1 and 2
  //tdma_schedule_add(0, TDMA_TX_CHILD, 0);
  //tdma_schedule_add(10, TDMA_RX, 0);
  //tdma_schedule_add(20, TDMA_RX, 0);


  tdma_task_config ();

  nrk_create_taskset ();

  nrk_start ();

  return 0;
}
Esempio n. 23
0
	int
main ()
{
  uint8_t t;
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_230K4);

  nrk_init();
  nrk_time_set(0,0);

  nrk_create_taskset ();
  nrk_start();
  
  return 0;
}
Esempio n. 24
0
int
main ()
{
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);

	log_g = 1;
  if(log_g)printf("log:Starting up...\r\n" );

  nrk_init();
uint8_t i;
request_flag_g=0;
retransmit_count_g=0;
//added this 1
for(i=0;i<5;i++)
{
	version_g[i] = 0;
}
//added
	version_g[MAC_ADDR] = -1;
	data_index_g = -1;

  nrk_led_clr(ORANGE_LED);
  nrk_led_clr(BLUE_LED);
  nrk_led_set(GREEN_LED);
  nrk_led_clr(RED_LED);
 	
	tx_sem = nrk_sem_create(1,4);
  if(tx_sem==NULL) nrk_kprintf( PSTR("log:Error creating sem\r\n" ));
	
	conn_sem = nrk_sem_create(1,4);
  if(conn_sem==NULL) nrk_kprintf( PSTR("log:Error creating sem\n" ));

	uart_sem = nrk_sem_create(1,4);
  if(conn_sem==NULL) nrk_kprintf( PSTR("log:Error creating sem\n" ));
	
	ack_sem = nrk_sem_create(1,4);
  if(conn_sem==NULL) nrk_kprintf( PSTR("log:Error creating sem\n" ));
  
	nrk_time_set(0,0);
  nrk_register_drivers();
  bmac_task_config ();
  nrk_create_taskset ();
  nrk_start();
 

  return 0;
}
Esempio n. 25
0
int main ()
{
    nrk_setup_ports();
    nrk_setup_uart(UART_BAUDRATE_115K2);

    nrk_init();

    nrk_time_set(0,0);

    //Initialize tasks 
    INITIALIZE_TASK(1);
    INITIALIZE_TASK(2);

    nrk_start();

    return 0;
}
Esempio n. 26
0
int
main ()
{
  uint8_t t;
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);

  printf( "Starting up...\r\n" );

  nrk_init();
  nrk_time_set(0,0);

  nrk_register_drivers();
  nrk_create_taskset ();
  nrk_start();
  
  return 0;
}
Esempio n. 27
0
File: main.c Progetto: nycdarren/mrk
int main ()
{
    nrk_setup_ports ();
    nrk_setup_uart (UART_BAUDRATE_115K2);

    nrk_init ();

    nrk_led_clr (ORANGE_LED);
    nrk_led_clr (BLUE_LED);
    nrk_led_clr (GREEN_LED);
    nrk_led_clr (RED_LED);

    nrk_time_set (0, 0);
    nrk_create_taskset ();
    nrk_start ();

    return 0;
}
Esempio n. 28
0
int
main ()
{
  uint8_t t;
  
  nrk_setup_ports();
  nrk_setup_uart(UART_BAUDRATE_115K2);
  
  nrk_kprintf( PSTR("Starting up...\r\n") );

  nrk_init();

 
  nrk_time_set(0,0);
  nrk_create_taskset ();
  nrk_start();
  return 0;
}
Esempio n. 29
0
int main() {
	nrk_setup_ports();
	nrk_setup_uart(UART_BAUDRATE_115K2);
	nrk_kprintf(PSTR("\r\n Nano-RK Version \r\n "));
	printf("%d\r\n", NRK_VERSION );
	nrk_init();

	nrk_led_clr(ORANGE_LED);
	nrk_led_clr(BLUE_LED);
	nrk_led_clr(GREEN_LED);
	nrk_led_clr(RED_LED);

	nrk_time_set(0, 0);
	nrk_create_taskset();
	printf("NRK_START ::\r\n");
	nrk_start();

	return 0;
}
Esempio n. 30
0
//------------------------------------------------------------------------------
//      void main (void)
//
//      DESCRIPTION:
//              Startup routine
//------------------------------------------------------------------------------
int main (void)
{
	nrk_setup_ports(); 
	nrk_setup_uart (UART_BAUDRATE_115K2);

	nrk_init();

	printf( "WiDom Test Starting up... (MSG_PRIO=%d)\r\n", MSG_PRIO );

	nrk_led_set(ORANGE_LED);
	nrk_led_clr(BLUE_LED);
	nrk_led_clr(GREEN_LED);
	nrk_led_clr(RED_LED);
	
	nrk_time_set(0,0);
	nrk_create_taskset ();
	nrk_start();

	return 0;
}