Example #1
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;
}
Example #2
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);
}
Example #3
0
uint8_t lps331ap_config(i2c_t i2c, exti_line_t data_ready_line)
{
    uint8_t buf[2];

    lps331ap.i2c = i2c;
    lps331ap.data_ready_line = data_ready_line;

    // Reboot memory content
    buf[0] = CTRL_REG2;
    buf[1] = 0x80;
    
    return i2c_tx(lps331ap.i2c, LPS331AP_ADDRESS, buf, 2) || lps331ap_powerdown();
}