Esempio n. 1
0
uint8_t eth_u8_init( void ){
	
	if( low_level_init() != 0 ){
		
		return 1;
	}

	enabled = TRUE;
	
	// create the IRQ handler thread
	thread_t_create( eth_irq_thread,
                     PSTR("ethernet_irq"),
                     0,
                     0 );
	
	// create the transmit timeout monitor
	thread_t_create( eth_tx_monitor_thread,
                     PSTR("ethernet_tx_monitor"),
                     0,
                     0 );
	
	thread_t_create( eth_irq_check_thread,
                     PSTR("ethernet_irq_monitor"),
                     0,
                     0 );
	
    return 0;
}
Esempio n. 2
0
void wcom_neighbors_v_init( void ){
    
    mode = MODE_CHANNEL_SCAN;

    // init lists
    list_v_init( &prov_list );
    list_v_init( &neighbor_list );
    
    beacon_thread = -1;

    // create threads
    thread_t_create( beacon_init_thread,
                     PSTR("wcom_neighbor_beacon_init"),
                     0,
                     0 );

    thread_t_create( join_timeout_thread,
                     PSTR("wcom_neighbor_join_timeout_monitor"),
                     0,
                     0 );

    thread_t_create( neighbor_monitor_thread,
                     PSTR("wcom_neighbor_monitor"),
                     0,
                     0 );

    // create vfile
    fs_f_create_virtual( PSTR("neighbors"), vfile );
}
Esempio n. 3
0
void app_v_init( void ) {

    thread_t_create( app_thread,
                     PSTR("app"),
                     0,
                     0 );
}
Esempio n. 4
0
void cmd2_v_init( void ){

    // create socket
    sock = sock_s_create( SOCK_UDPX_SERVER );

    ASSERT( sock >= 0 );

    // bind to server port
    sock_v_bind( sock, CMD2_SERVER_PORT );
    
    // create server thread
    thread_t_create( command2_server_thread,
                     PSTR("command_server"),
                     0,
                     0 );
    
    // create serial thread
    thread_t_create( command2_serial_thread,
                     PSTR("command_serial_monitor"),
                     0,
                     0 );

    file = -1;
}
Esempio n. 5
0
void io_v_init( void ){
    
    // set all LEDs to outputs
    io_v_set_mode( IO_PIN_LED0, IO_MODE_OUTPUT );
    io_v_set_mode( IO_PIN_LED1, IO_MODE_OUTPUT );
    io_v_set_mode( IO_PIN_LED2, IO_MODE_OUTPUT );
    
    // check if safe mode
    if( sys_u8_get_mode() != SYS_MODE_SAFE ){
        
        // disable jtag
        //io_v_disable_jtag();
    }

    // create button monitor thread
	thread_t_create( push_button_monitor_thread,
                     PSTR("io_button_monitor"),
                     0,
                     0 );
}
Esempio n. 6
0
uint8_t rf_u8_init( void ){

	TRXPR = 1; // force a reset

	_delay_ms( 5 );
    
    // check hardware revision
    if( io_u8_get_board_rev() == 0 ){
    
        // disable internal voltage regulators (1.8v rev 4 boards only).  This will not be necessary on rev 4.1.
        VREG_CTRL = ( 1 << AVREG_EXT ) | ( 1 << DVREG_EXT );
        // note the datasheet poorly documents this register.
    }

	rf_v_set_internal_state( CMD_PLL_ON ); // set mode to PLL_ON

	// set cca mode
	//rf_v_set_cca_mode( MODE_3_THRESH_CS );
	//rf_v_set_cca_mode( MODE_2_CS );
	//rf_v_set_cca_mode( MODE_1_THRESH );
	uint16_t cca_mode;
    cfg_i8_get( CFG_PARAM_WCOM_CCA_MODE, &cca_mode );
    
    // bounds check mode
    if( ( cca_mode < 1 ) || ( cca_mode > 3 ) ){
        
        cca_mode = MODE_2_CS;
        cfg_v_set( CFG_PARAM_WCOM_CCA_MODE, &cca_mode );
    }
    
    // set cca mode
    rf_v_set_cca_mode( cca_mode );

    // get cca threshold
    uint16_t cca_thresh;
    cfg_i8_get( CFG_PARAM_WCOM_CCA_THRESHOLD, &cca_thresh );
    
    // bounds check mode
    if( cca_thresh >= 16 ){
        
        cca_thresh = 8;
        cfg_v_set( CFG_PARAM_WCOM_CCA_THRESHOLD, &cca_thresh );
    }
    
	rf_v_set_cca_ed_threshold( cca_thresh );
	
    // set back off exponents
    uint16_t min_be;
    uint16_t max_be;
    cfg_i8_get( CFG_PARAM_WCOM_MIN_BE, &min_be );
    cfg_i8_get( CFG_PARAM_WCOM_MAX_BE, &max_be );
    
    // bounds check
    if( max_be < 3 ){
        
        max_be = 3;
        cfg_v_set( CFG_PARAM_WCOM_MAX_BE, &max_be );
    }
    else if( max_be > 8 ){
        
        max_be = 8;
        cfg_v_set( CFG_PARAM_WCOM_MAX_BE, &max_be );
    }

    if( min_be > max_be ){
        
        min_be = max_be;
        cfg_v_set( CFG_PARAM_WCOM_MIN_BE, &min_be );
    }

    rf_v_set_be( min_be, max_be );

    // set receiver sensitivity
    uint16_t rx_sens;
    cfg_i8_get( CFG_PARAM_WCOM_RX_SENSITIVITY, &rx_sens );
    
    // bounds check
    if( rx_sens > 15 ){
        
        rx_sens = 15;
        cfg_v_set( CFG_PARAM_WCOM_RX_SENSITIVITY, &rx_sens );
    }
    
    rf_v_set_rx_sensitivity( rx_sens );

    // set power
    uint16_t tx_power;
    cfg_i8_get( CFG_PARAM_WCOM_MAX_TX_POWER, &tx_power );
    
    if( tx_power > 15 ){
        
        // note 15 is the lowest setting, 0 is the highest

        tx_power = 15;
        cfg_v_set( CFG_PARAM_WCOM_MAX_TX_POWER, &tx_power );
    }

    rf_v_set_power( tx_power ); 
	
    uint16_t csma_tries;
    uint16_t tx_tries;
    cfg_i8_get( CFG_PARAM_WCOM_CSMA_TRIES, &csma_tries );
    cfg_i8_get( CFG_PARAM_WCOM_TX_HW_TRIES, &tx_tries );
    
    if( csma_tries > 5 ){
        
        csma_tries = 5;
        cfg_v_set( CFG_PARAM_WCOM_CSMA_TRIES, &csma_tries );
    }
    
    if( tx_tries > 15 ){
        
        tx_tries = 15;
        cfg_v_set( CFG_PARAM_WCOM_TX_HW_TRIES, &tx_tries );
    }

	// set up CSMA and frame retries
    rf_v_set_csma_tries( csma_tries );
    rf_v_set_frame_retries( tx_tries );
   
	// park on channel 11
	rf_v_set_channel( 11 );
	
    // enable interrupts
    IRQ_MASK |= _BV( TX_END_EN ) |
                _BV( RX_END_EN );
        
    
    // set mode to normal
    // this will configure address and pan id
    rf_v_set_mode( RF_MODE_NORMAL );

    // create threads
	thread_t_create( receive_thread,
                     PSTR("rf_receive"),
                     0,
                     0 );

    thread_t_create( rf_pll_schedule_thread,
                     PSTR("rf_pll_calibration"),
                     0,
                     0 );

    // set up CSMA seed
    CSMA_SEED_0 = rf_u8_get_random();
    CSMA_SEED_1 |= rf_u8_get_random() & 0x07;

	return 0;
}