void auto_init_mpl3115a2(void) { assert(MPL3115A2_NUM == MPL3115A2_INFO_NUM); for (unsigned i = 0; i < MPL3115A2_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing mpl3115a2 #%u\n", i); if ((mpl3115a2_init(&mpl3115a2_devs[i], &mpl3115a2_params[i]) | mpl3115a2_set_active(&mpl3115a2_devs[i])) != MPL3115A2_OK) { LOG_ERROR("[auto_init_saul] error initializing mpl3115a2 #%u\n", i); continue; } /* temperature */ saul_entries[(i * 2)].dev = &(mpl3115a2_devs[i]); saul_entries[(i * 2)].name = mpl3115a2_saul_info[i].name; saul_entries[(i * 2)].driver = &mpl3115a2_temperature_saul_driver; /* atmospheric pressure */ saul_entries[(i * 2) + 1].dev = &(mpl3115a2_devs[i]); saul_entries[(i * 2) + 1].name = mpl3115a2_saul_info[i].name; saul_entries[(i * 2) + 1].driver = &mpl3115a2_pressure_saul_driver; /* register to saul */ saul_reg_add(&(saul_entries[(i * 2)])); saul_reg_add(&(saul_entries[(i * 2) + 1])); } }
void auto_init_si70xx(void) { for (unsigned i = 0; i < SI70XX_NUMOF; i++) { LOG_DEBUG("[auto_init_saul] initializing SI70xx #%u\n", i); int res = si70xx_init(&si70xx_devs[i], si70xx_params[i].i2c_dev, si70xx_params[i].address); if (res < 0) { LOG_ERROR("[auto_init_saul] error initializing SI70xx #%i\n", i); return; } /* temperature */ saul_entries[i * 2].dev = &si70xx_devs[i]; saul_entries[i * 2].name = si70xx_saul_reg_info[i][0].name; saul_entries[i * 2].driver = &si70xx_temperature_saul_driver; /* relative humidity */ saul_entries[(i * 2) + 1].dev = &si70xx_devs[i]; saul_entries[(i * 2) + 1].name = si70xx_saul_reg_info[i][1].name; saul_entries[(i * 2) + 1].driver = \ &si70xx_relative_humidity_saul_driver; saul_reg_add(&saul_entries[i * 2]); saul_reg_add(&saul_entries[(i * 2) + 1]); } }
void auto_init_mpu9150(void) { assert(MPU9150_NUM == MPU9150_INFO_NUM); for (unsigned int i = 0; i < MPU9150_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing mpu9150 #%u\n", i); if (mpu9150_init(&mpu9150_devs[i], &mpu9150_params[i]) < 0) { LOG_ERROR("[auto_init_saul] error initializing mpu9150 #%u\n", i); continue; } saul_entries[(i * 3)].dev = &(mpu9150_devs[i]); saul_entries[(i * 3)].name = mpu9150_saul_info[i].name; saul_entries[(i * 3)].driver = &mpu9150_saul_acc_driver; saul_entries[(i * 3) + 1].dev = &(mpu9150_devs[i]); saul_entries[(i * 3) + 1].name = mpu9150_saul_info[i].name; saul_entries[(i * 3) + 1].driver = &mpu9150_saul_gyro_driver; saul_entries[(i * 3) + 2].dev = &(mpu9150_devs[i]); saul_entries[(i * 3) + 2].name = mpu9150_saul_info[i].name; saul_entries[(i * 3) + 2].driver = &mpu9150_saul_mag_driver; saul_reg_add(&(saul_entries[(i * 3)])); saul_reg_add(&(saul_entries[(i * 3) + 1])); saul_reg_add(&(saul_entries[(i * 3) + 2])); } }
void auto_init_gpio(void) { for (unsigned int i = 0; i < SAUL_GPIO_NUMOF; i++) { const saul_gpio_params_t *p = &saul_gpio_params[i]; LOG_DEBUG("[auto_init_saul] initializing GPIO #%u\n", i); saul_reg_entries[i].dev = (void *)p; saul_reg_entries[i].name = p->name; if ((p->mode == GPIO_IN) || (p->mode == GPIO_IN_PD) || (p->mode == GPIO_IN_PU)) { saul_reg_entries[i].driver = &gpio_in_saul_driver; } else { saul_reg_entries[i].driver = &gpio_out_saul_driver; } /* initialize the GPIO pin */ gpio_init(p->pin, p->mode); /* set initial pin state if configured */ if (p->flags & (SAUL_GPIO_INIT_CLEAR | SAUL_GPIO_INIT_SET)) { phydat_t s; s.val[0] = (p->flags & SAUL_GPIO_INIT_SET); saul_reg_entries[i].driver->write(p, &s); } /* add to registry */ saul_reg_add(&(saul_reg_entries[i])); } }
void auto_init_tmp006(void) { for (unsigned i = 0; i < TMP006_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing tmp006 #%u\n", i); if (tmp006_init(&tmp006_devs[i], &tmp006_params[i]) != TMP006_OK) { LOG_ERROR("[auto_init_saul] error initializing tmp006 #%u\n", i); continue; } if (tmp006_set_active(&tmp006_devs[i]) != TMP006_OK) { LOG_ERROR("[auto_init_saul] error set active tmp006 #%u\n", i); continue; } #if TMP006_USE_LOW_POWER if (tmp006_set_standby(&tmp006_devs[i]) != TMP006_OK) { LOG_ERROR("[auto_init_saul] error set standby tmp006 #%u\n", i); continue; } #endif saul_entries[i].dev = &(tmp006_devs[i]); saul_entries[i].name = tmp006_saul_info[i].name; saul_entries[i].driver = &tmp006_saul_driver; saul_reg_add(&(saul_entries[i])); } }
void auto_init_nrf_temperature(void) { saul_reg_entry.dev = NULL; saul_reg_entry.name = nrf_temperature_saul_info.name; saul_reg_entry.driver = &nrf_temperature_saul_driver; /* add to registry */ saul_reg_add(&(saul_reg_entry)); }
void auto_init_dht(void) { for (unsigned int i = 0; i < DHT_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing dht #%u\n", i); if (dht_init(&dht_devs[i], &dht_params[i]) != DHT_OK) { LOG_ERROR("[auto_init_saul] error initializing dht #%u\n", i); } else { saul_entries[(i * 2)].dev = &(dht_devs[i]); saul_entries[(i * 2)].name = dht_saul_info[i][0].name; saul_entries[(i * 2)].driver = &dht_temp_saul_driver; saul_entries[(i * 2) + 1].dev = &(dht_devs[i]); saul_entries[(i * 2) + 1].name = dht_saul_info[i][1].name; saul_entries[(i * 2) + 1].driver = &dht_hum_saul_driver; saul_reg_add(&(saul_entries[(i * 2)])); saul_reg_add(&(saul_entries[(i * 2) + 1])); } } }
void auto_init_fxos8700(void) { for (unsigned i = 0; i < FXOS8700_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing fxos8700 #%u\n", i); int res = fxos8700_init(&fxos8700_devs[i], &fxos8700_params[i]); if (res != 0) { LOG_ERROR("[auto_init_saul] error initializing fxos8700 #%u\n", i); } else { saul_entries[(i * 2)].dev = &(fxos8700_devs[i]); saul_entries[(i * 2)].name = fxos8700_saul_info[i].name; saul_entries[(i * 2)].driver = &fxos8700_saul_acc_driver; saul_entries[(i * 2) + 1].dev = &(fxos8700_devs[i]); saul_entries[(i * 2) + 1].name = fxos8700_saul_info[i].name; saul_entries[(i * 2) + 1].driver = &fxos8700_saul_mag_driver; saul_reg_add(&(saul_entries[(i * 2)])); saul_reg_add(&(saul_entries[(i * 2) + 1])); } } }
void auto_init_hdc1000(void) { for (unsigned i = 0; i < HDC1000_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing hdc1000 #%u\n", i); int res = hdc1000_init(&hdc1000_devs[i], &hdc1000_params[i]); if (res < 0) { LOG_ERROR("[auto_init_saul] error initializing hdc1000 #%u\n", i); continue; } saul_entries[(i * 2)].dev = &(hdc1000_devs[i]); saul_entries[(i * 2)].name = hdc1000_saul_info[i].name; saul_entries[(i * 2)].driver = &hdc1000_saul_temp_driver; saul_entries[(i * 2) + 1].dev = &(hdc1000_devs[i]); saul_entries[(i * 2) + 1].name = hdc1000_saul_info[i].name; saul_entries[(i * 2) + 1].driver = &hdc1000_saul_hum_driver; saul_reg_add(&(saul_entries[(i * 2)])); saul_reg_add(&(saul_entries[(i * 2) + 1])); } }
void auto_init_lps331ap(void) { assert(LPS331AP_NUM == LPS331AP_INFO_NUM); for (unsigned int i = 0; i < LPS331AP_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing lps331ap #%u\n", i); if (lps331ap_init(&lps331ap_devs[i], &lps331ap_params[i]) < 0) { LOG_ERROR("[auto_init_saul] error initializing lps331ap #%u\n", i); continue; } saul_entries[i].dev = &(lps331ap_devs[i]); saul_entries[i].name = lps331ap_saul_info[i].name; saul_entries[i].driver = &lps331ap_saul_pres_driver; saul_reg_add(&(saul_entries[i])); saul_entries[(i * 2) + 1].dev = &(lps331ap_devs[i]); saul_entries[(i * 2) + 1].name = lps331ap_saul_info[i].name; saul_entries[(i * 2) + 1].driver = &lps331ap_saul_temp_driver; saul_reg_add(&(saul_entries[(i * 2) + 1])); } }
void auto_init_gpio(void) { for (unsigned int i = 0; i < SAUL_GPIO_NUMOF; i++) { const saul_gpio_params_t *p = &saul_gpio_params[i]; LOG_DEBUG("[auto_init_saul] initializing GPIO #%u\n", i); saul_gpios[i] = p->pin; saul_reg_entries[i].dev = &(saul_gpios[i]); saul_reg_entries[i].name = p->name; saul_reg_entries[i].driver = &gpio_saul_driver; /* initialize the GPIO pin */ gpio_init(p->pin, p->mode); /* add to registry */ saul_reg_add(&(saul_reg_entries[i])); } }
void auto_init_adc(void) { for (unsigned i = 0; i < SAUL_ADC_NUMOF; i++) { const saul_adc_params_t *p = &saul_adc_params[i]; saul_adcs[i] = p; LOG_DEBUG("[auto_init_saul] initializing direct ADC #%u\n", i); saul_reg_entries[i].dev = &saul_adcs[i]; saul_reg_entries[i].name = p->name; saul_reg_entries[i].driver = &adc_saul_driver; /* initialize the ADC line */ adc_init(p->line); /* add to registry */ saul_reg_add(&(saul_reg_entries[i])); } }
void auto_init_lis3mdl(void) { assert(LIS3MDL_NUM == LIS3MDL_INFO_NUM); for (unsigned int i = 0; i < LIS3MDL_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing lis3mdl #%u\n", i); if (lis3mdl_init(&lis3mdl_devs[i], &lis3mdl_params[i]) < 0) { LOG_ERROR("[auto_init_saul] error initializing lis3mdl #%u\n", i); continue; } saul_entries[i].dev = &(lis3mdl_devs[i]); saul_entries[i].name = lis3mdl_saul_info[i].name; saul_entries[i].driver = &lis3mdl_saul_mag_driver; saul_reg_add(&(saul_entries[i])); } }
void auto_init_pulse_counter(void) { assert(PULSE_COUNTER_NUM == PULSE_COUNTER_INFO_NUM); for (unsigned i = 0; i < PULSE_COUNTER_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing pulse_counter #%u\n", i); int res = pulse_counter_init(&pulse_counter_devs[i], &pulse_counter_params[i]); if (res != 0) { LOG_ERROR("[auto_init_saul] error initializing pulse_counter #%u\n", i); } else { saul_entries[i].dev = &(pulse_counter_devs[i]); saul_entries[i].name = pulse_counter_saul_info[i].name; saul_entries[i].driver = &pulse_counter_saul_driver; saul_reg_add(&(saul_entries[i])); } } }
void auto_init_l3g4200d(void) { assert(L3G4200D_NUM == L3G4200D_INFO_NUM); for (unsigned int i = 0; i < L3G4200D_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing l3g4200d #%u\n", i); if (l3g4200d_init(&l3g4200d_devs[i], &l3g4200d_params[i]) < 0) { LOG_ERROR("[auto_init_saul] error initializing l3g4200d #%u\n", i); continue; } saul_entries[i].dev = &(l3g4200d_devs[i]); saul_entries[i].name = l3g4200d_saul_info[i].name; saul_entries[i].driver = &l3g4200d_saul_driver; saul_reg_add(&(saul_entries[i])); } }
void auto_init_lps331ap(void) { for (unsigned int i = 0; i < LPS331AP_NUM; i++) { const lps331ap_params_t *p = &lps331ap_params[i]; LOG_DEBUG("[auto_init_saul] initializing lps331ap #%u\n", i); int res = lps331ap_init(&lps331ap_devs[i], p->i2c, p->addr, p->rate); if (res < 0) { LOG_ERROR("[auto_init_saul] error initializing lps331ap #%u\n", i); continue; } saul_entries[i].dev = &(lps331ap_devs[i]); saul_entries[i].name = lps331ap_saul_info[i].name; saul_entries[i].driver = &lps331ap_saul_driver; saul_reg_add(&(saul_entries[i])); } }
void auto_init_veml6070(void) { assert(VEML6070_NUM == VEML6070_INFO_NUM); for (unsigned i = 0; i < VEML6070_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing veml6070 #%u\n", i); if (veml6070_init(&veml6070_devs[i], &veml6070_params[i]) != VEML6070_OK) { LOG_ERROR("[auto_init_saul] error initializing veml6070 #%u\n", i); continue; } saul_entries[(i)].dev = &(veml6070_devs[i]); saul_entries[(i)].name = veml6070_saul_info[i].name; saul_entries[(i)].driver = &veml6070_uv_saul_driver; /* register to saul */ saul_reg_add(&(saul_entries[(i)])); } }
void auto_init_ds18(void) { for (unsigned i = 0; i < DS18_NUMOF; i++) { const ds18_params_t *p = &ds18_params[i]; LOG_DEBUG("[auto_init_saul] initializing ds18 #%u\n", i); if (ds18_init(&ds18_devs[i], p) < 0) { LOG_ERROR("[auto_init_saul] error initializing ds18 #%u\n", i); return; } /* temperature */ saul_entries[i].dev = &(ds18_devs[i]); saul_entries[i].name = ds18_saul_reg_info[i].name; saul_entries[i].driver = &ds18_temperature_saul_driver; /* register to saul */ saul_reg_add(&(saul_entries[i])); } }
void auto_init_tsl2561(void) { for (unsigned i = 0; i < TSL2561_NUMOF; i++) { LOG_DEBUG("[auto_init_saul] initializing tsl2561 #%u\n", i); if (tsl2561_init(&tsl2561_devs[i], tsl2561_params[i].i2c_dev, tsl2561_params[i].addr, tsl2561_params[i].gain, tsl2561_params[i].integration) != TSL2561_OK) { LOG_ERROR("[auto_init_saul] error initializing tsl2561 #%u\n", i); continue; } /* illuminance */ saul_entries[i].dev = &(tsl2561_devs[i]); saul_entries[i].name = tsl2561_saul_reg_info[i].name; saul_entries[i].driver = &tsl2561_illuminance_saul_driver; /* register to saul */ saul_reg_add(&(saul_entries[i])); } }
void auto_init_mma8652(void) { for (int i = 0; i < MMA8652_NUM; i++) { const mma8652_params_t *p = &mma8652_params[i]; DEBUG("[auto_init_saul] initializing mma8652 acc sensor\n"); if (mma8652_init(&mma8652_devs[i], p->i2c, p->addr, p->rate, p->scale, p->type) < 0) { DEBUG("[auto_init_saul] error during initialization\n"); return; } if (mma8652_set_active(&mma8652_devs[i]) < 0) { DEBUG("[auto_init_saul] error activating mma8652\n"); return; } saul_entries[i].dev = &(mma8652_devs[i]); saul_entries[i].name = mma8652_saul_info[i].name; saul_entries[i].driver = &mma8652_saul_driver; saul_reg_add(&(saul_entries[i])); } }
void auto_init_lis3dh(void) { assert(LIS3DH_NUM == LIS3DH_INFO_NUM); for (unsigned int i = 0; i < LIS3DH_NUM; i++) { LOG_DEBUG("[auto_init_saul] initializing lis3dh #%u\n", i); if (lis3dh_init(&lis3dh_devs[i], &lis3dh_params[i]) < 0) { LOG_ERROR("[auto_init_saul] error initializing lis3dh #%u\n", i); continue; } if (lis3dh_set_odr(&lis3dh_devs[i], lis3dh_params[i].odr) < 0) { LOG_ERROR("[auto_init_saul] error setting ODR for lis3dh #%u\n", i); continue; } saul_entries[i].dev = &(lis3dh_devs[i]); saul_entries[i].name = lis3dh_saul_info[i].name; saul_entries[i].driver = &lis3dh_saul_driver; saul_reg_add(&(saul_entries[i])); } }