Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
daafde03a4
commit
d9cffeff06
39
src/main.c
39
src/main.c
|
@ -147,13 +147,30 @@ int main(void) {
|
||||||
ims_bme280_result_t dht_result;
|
ims_bme280_result_t dht_result;
|
||||||
VL53L1_RangingMeasurementData_t ranging_result;
|
VL53L1_RangingMeasurementData_t ranging_result;
|
||||||
|
|
||||||
uint8_t ranging_ready = 0U;
|
uint8_t ranging_ready;
|
||||||
int16_t imu_temp;
|
int16_t imu_temp;
|
||||||
volatile uint16_t vbat;
|
uint16_t vbat;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
HAL_Delay(1000);
|
||||||
|
|
||||||
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
HAL_ADC_Start(&hadc);
|
||||||
|
HAL_ADC_PollForConversion(&hadc, 1000);
|
||||||
|
|
||||||
|
if (HAL_ADC_GetState(&hadc) & HAL_ADC_STATE_EOC_REG) {
|
||||||
|
vbat = HAL_ADC_GetValue(&hadc);
|
||||||
|
}
|
||||||
|
|
||||||
|
VL53L1_GetMeasurementDataReady(&s_ranging, &ranging_ready);
|
||||||
|
if (ranging_ready) {
|
||||||
|
VL53L1_GetRangingMeasurementData(&s_ranging, &ranging_result);
|
||||||
|
if (VL53L1_ClearInterruptAndStartMeasurement(&s_ranging) != VL53L1_ERROR_NONE) {
|
||||||
|
goto dead_loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ims_bme280_measure(&s_dht, &dht_result) != IMS_SUCCESS) {
|
if (ims_bme280_measure(&s_dht, &dht_result) != IMS_SUCCESS) {
|
||||||
goto dead_loop;
|
goto dead_loop;
|
||||||
}
|
}
|
||||||
|
@ -166,21 +183,6 @@ int main(void) {
|
||||||
goto dead_loop;
|
goto dead_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
VL53L1_GetMeasurementDataReady(&s_ranging, &ranging_ready);
|
|
||||||
if (ranging_ready) {
|
|
||||||
VL53L1_GetRangingMeasurementData(&s_ranging, &ranging_result);
|
|
||||||
if (VL53L1_ClearInterruptAndStartMeasurement(&s_ranging) != VL53L1_ERROR_NONE) {
|
|
||||||
goto dead_loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_ADC_Start(&hadc);
|
|
||||||
HAL_ADC_PollForConversion(&hadc, 1000);
|
|
||||||
|
|
||||||
if (HAL_ADC_GetState(&hadc) & HAL_ADC_STATE_EOC_REG) {
|
|
||||||
vbat = HAL_ADC_GetValue(&hadc);
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
|
@ -189,7 +191,6 @@ int main(void) {
|
||||||
dht_result.temperature / 100.0, dht_result.humidity / 1024.0, dht_result.pressure / 25600.0,
|
dht_result.temperature / 100.0, dht_result.humidity / 1024.0, dht_result.pressure / 25600.0,
|
||||||
als_result.ch0_value / 48.0, als_result.ch1_value / 48.0, (imu_temp / 256.0) + 25.0,
|
als_result.ch0_value / 48.0, als_result.ch1_value / 48.0, (imu_temp / 256.0) + 25.0,
|
||||||
ranging_result.RangeMilliMeter, (vbat * VDD_VALUE / 4096.0));
|
ranging_result.RangeMilliMeter, (vbat * VDD_VALUE / 4096.0));
|
||||||
HAL_Delay(100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_loop:
|
dead_loop:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user