void HardwareInit() { // Set this only if nRF is power at 2V or more //nrf_power_dcdcen_set(true); NRF_POWER->DCDCEN = 1; IOPinCfg(s_GpioPins, s_NbGpioPins); IOPinClear(0, BLUEIO_TAG_BME680_LED2_BLUE_PIN); IOPinClear(0, BLUEIO_TAG_BME680_LED2_GREEN_PIN); IOPinClear(0, BLUEIO_TAG_BME680_LED2_RED_PIN); g_Timer.Init(s_TimerCfg); // Initialize I2C #ifdef NEBLINA_MODULE g_Spi.Init(s_SpiCfg); #else g_I2c.Init(s_I2cCfg); #endif bsec_library_return_t bsec_status; // NOTE : For BME680 air quality calculation, this library is require to be initialized // before initializing the sensor driver. bsec_status = bsec_init(); if (bsec_status != BSEC_OK) { printf("BSEC init failed\r\n"); return; } // Inititalize sensor g_TphSensor.Init(s_TphSensorCfg, g_pIntrf, &g_Timer); // g_TphSensor.Disable(); // g_I2c.Disable(); // while(1) __WFE(); if (g_TphSensor.DeviceID() == BME680_ID) { g_GasSensor.Init(s_GasSensorCfg, g_pIntrf, NULL); } g_TphSensor.StartSampling(); usDelay(300000); // Update sensor data TPHSENSOR_DATA tphdata; g_TphSensor.Read(tphdata); if (g_TphSensor.DeviceID() == BME680_ID) { GASSENSOR_DATA gdata; g_GasSensor.Read(gdata); } g_TphSensor.StartSampling(); g_AdvData.Type = BLEADV_MANDATA_TYPE_TPH; // Do memcpy to adv data. Due to byte alignment, cannot read directly into // adv data memcpy(g_AdvData.Data, ((uint8_t*)&tphdata) + sizeof(tphdata.Timestamp), sizeof(BLEADV_MANDATA_TPHSENSOR)); g_I2c.Disable(); #ifdef NRF52_SERIES g_Adc.Init(s_AdcCfg); g_Adc.OpenChannel(s_ChanCfg, s_NbChan); g_Adc.StartConversion(); #endif #ifdef USE_TIMER_UPDATE // Only with SDK14 uint64_t period = g_Timer.EnableTimerTrigger(0, 500UL, TIMER_TRIG_TYPE_CONTINUOUS); #endif }