Ejemplo n.º 1
0
static void hardware_init()
{
    // Openlab platform init
    platform_init();
    event_init();
    soft_timer_init();

    // Switch off the LEDs
    leds_off(LED_0 | LED_1 | LED_2);

    // Uart initialisation
    uart_set_rx_handler(uart_print, char_rx, NULL);

#ifdef IOTLAB_M3
    // ISL29020 light sensor initialisation
    isl29020_prepare(ISL29020_LIGHT__AMBIENT, ISL29020_RESOLUTION__16bit,
                     ISL29020_RANGE__16000lux);
    isl29020_sample_continuous();

    // LPS331AP pressure sensor initialisation
    lps331ap_powerdown();
    lps331ap_set_datarate(LPS331AP_P_12_5HZ_T_12_5HZ);
#endif

    // Init csma Radio mac layer
    mac_csma_init(CHANNEL, RADIO_POWER);

    // Init control_node i2c
    iotlab_i2c_init();

    // Initialize a openlab timer
    soft_timer_set_handler(&tx_timer, alarm, NULL);
    soft_timer_start(&tx_timer, BLINK_PERIOD, 1);
}
Ejemplo n.º 2
0
int main(void)
{
    platform_init();
    soft_timer_init();
    event_init();

    uart_set_rx_handler(uart_print, char_handler_irq, NULL);

    radio_queue = xQueueCreate(1, sizeof(int));  // radio sync queue

    //init sensor
#ifdef IOTLAB_M3
    isl29020_prepare(ISL29020_LIGHT__AMBIENT, ISL29020_RESOLUTION__16bit,
            ISL29020_RANGE__1000lux);
    isl29020_sample_continuous();

    lps331ap_powerdown();
    lps331ap_set_datarate(LPS331AP_P_12_5HZ_T_12_5HZ);
#endif

    l3g4200d_powerdown();
    l3g4200d_gyr_config(L3G4200D_200HZ, L3G4200D_250DPS, true);

    lsm303dlhc_powerdown();
    lsm303dlhc_mag_config(
            LSM303DLHC_MAG_RATE_220HZ, LSM303DLHC_MAG_SCALE_2_5GAUSS,
            LSM303DLHC_MAG_MODE_CONTINUOUS, LSM303DLHC_TEMP_MODE_ON);
    lsm303dlhc_acc_config(
            LSM303DLHC_ACC_RATE_400HZ, LSM303DLHC_ACC_SCALE_2G,
            LSM303DLHC_ACC_UPDATE_ON_READ);

    platform_run();
    return 1;
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: awe00/openlab
int main()
{
    // Initialize the platform
    platform_init();
    //fiteco_lib_gwt_opennode_power_select(FITECO_GWT_OPENNODE_POWER__OFF);

    /* compatibility with HiKoB */
    if (uart_external == NULL)
        uart_external = uart_print;
    else
        uart_enable(uart_external, 500000);


    // Start the soft timer
    soft_timer_init();


    //set the open node power to off and charge the battery
    //fiteco_lib_gwt_opennode_power_select(FITECO_GWT_OPENNODE_POWER__MAIN);
    fiteco_lib_gwt_opennode_power_select(FITECO_GWT_OPENNODE_POWER__OFF);
    fiteco_lib_gwt_battery_charge_enable();
    fiteco_lib_gwt_opennode_power_select(FITECO_GWT_OPENNODE_POWER__MAIN);
    cn_i2c_start();

    //initialize the led, red off, green on
    leds_off(LEDS_MASK);
    leds_on(GREEN_LED);

    uart_set_rx_handler(uart_print, char_rx, NULL);

    // Run
    platform_run();
    return 0;
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: adjih/openlab
static void hardware_init()
{
    // Openlab platform init
    platform_init();
    event_init();
    soft_timer_init();

    iotlab_i2c_init();

    // Switch off the LEDs
    leds_off(LED_0 | LED_1 | LED_2);

    // Uart initialisation
    uart_set_rx_handler(uart_print, char_rx, NULL);

}
Ejemplo n.º 5
0
int main()
{
    // Initialize the platform
    platform_init();

    // Set handler for RX of char
    uart_set_rx_handler(uart_print, char_rx, NULL );

    log_printf(
            "\r\n\r\nOpenNode Power Selection:\r\n\t0: off\r\n\t1: main\r\n\t2: battery\r\n");
    log_printf("OpenNode Battery Charge:\r\n\t3: off\r\n\t4: on\r\n");
    log_printf(
            "Current measurement:\r\n\t5: off\r\n\t6: 3V\r\n\t7: 5V\r\n\t8: battery\r\n");

    // Launch everything
    platform_run();

    return 0;
}
Ejemplo n.º 6
0
/*---------------------------------------------------------------------------*/
int main()
{
    static uint32_t idle_count = 0;

    /* 
     * OpenLab Platform init
     * 
     */

    platform_init();

    /*
     * Contiki core 
     *
     */

    clock_init();
    process_init();
    rtimer_init();
    process_start(&etimer_process, NULL);
    ctimer_init();

    /* 
     * Sensors 
     *
     * registered sensors: button
     *
     * TODO: add lsm303dlhc + l3g4200 + lps331
     */

    process_start(&sensors_process, NULL);

    /* 
     * Network 
     *
     */

    netstack_init();
    set_rime_addr();

#if UIP_CONF_IPV6
    memcpy(&uip_lladdr.addr, &rimeaddr_node_addr, sizeof(uip_lladdr.addr));
    process_start(&tcpip_process, NULL);

    #if VIZTOOL_CONF_ON
    process_start(&viztool_process, NULL);
    #endif

    #if (!UIP_CONF_IPV6_RPL)
    {
	uip_ipaddr_t ipaddr;

	uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0);
	uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
	uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
    }
    #endif /* UIP_CONF_IPV6_RPL */
#endif /* UIP_CONF_IPV6 */

    /*
     * init serial line
     */
    serial_line_init();
    uart_set_rx_handler(uart_print, char_rx, NULL);

    /*
     * eventually init slip device
     * wich may override serial line
     */
#if SLIP_ARCH_CONF_ENABLE
#ifndef UIP_CONF_LLH_LEN
#error "LLH_LEN is not defined"
#elif UIP_CONF_LLH_LEN != 0
#error "LLH_LEN must be 0 to use slip interface"
#endif
    slip_arch_init(SLIP_ARCH_CONF_BAUDRATE);
#endif

    /*
     * Start
     */
    print_processes(autostart_processes);
    autostart_start(autostart_processes);
    watchdog_start();

    while(1) 
    {
	int r;
	do 
	{
	    watchdog_periodic();
	    r = process_run();
	} while(r > 0);
	idle_count++;
    }

    return 0;
}