|
@@ -189,7 +189,7 @@ int main(void)
|
|
|
SensorDev.read = user_i2c_read;
|
|
|
SensorDev.write = user_i2c_write;
|
|
|
SensorDev.delay_ms = tdelay_ms;
|
|
|
- //rsltSensor = bme280_init(&SensorDev);
|
|
|
+ rsltSensor = bme280_init(&SensorDev);
|
|
|
if (rsltSensor == BME280_OK) {
|
|
|
Flag.BME280 = 1;
|
|
|
}
|
|
@@ -206,8 +206,8 @@ int main(void)
|
|
|
SensorDev.settings.osr_t = BME280_OVERSAMPLING_2X;
|
|
|
SensorDev.settings.filter = BME280_FILTER_COEFF_16;
|
|
|
|
|
|
- //rsltSensor = bme280_set_sensor_settings((BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL), &SensorDev);
|
|
|
- //rsltSensor = bme280_set_sensor_mode(BME280_NORMAL_MODE, &SensorDev);
|
|
|
+ rsltSensor = bme280_set_sensor_settings((BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL), &SensorDev);
|
|
|
+ rsltSensor = bme280_set_sensor_mode(BME280_FORCED_MODE, &SensorDev);
|
|
|
//SensorDev.delay_ms(50);
|
|
|
//rsltSensor = bme280_get_sensor_data(BME280_ALL, &SensorData, &SensorDev);
|
|
|
/* bme280_get_sensor_data(...) returns:
|
|
@@ -224,16 +224,15 @@ int main(void)
|
|
|
{
|
|
|
IN15_OFF;
|
|
|
COLOR_RGB(0, 0, 0);
|
|
|
- tdelay_ms(500);
|
|
|
-
|
|
|
RTC_ReadAll(&Clock);
|
|
|
- //rsltSensor = bme280_get_sensor_data(BME280_ALL, &SensorData, &SensorDev);
|
|
|
+ tdelay_ms(500);
|
|
|
|
|
|
if (Flag.RTC_IRQ != 0) {
|
|
|
Flag.RTC_IRQ = 0;
|
|
|
IN15_Minus;
|
|
|
}
|
|
|
COLOR_RGB(0xFF, 0x12, 0x0); // FF7E00 or FFBF00
|
|
|
+ rsltSensor = bme280_get_sensor_data(BME280_ALL, &SensorData, &SensorDev);
|
|
|
tdelay_ms(500);
|
|
|
/* USER CODE END WHILE */
|
|
|
|
|
@@ -258,10 +257,10 @@ int main(void)
|
|
|
pres_h = (uint8_t)(tmp / 100);
|
|
|
pres_l = (uint8_t)(tmp % 100);
|
|
|
|
|
|
- showDigit(Tube_A, temp_h >> 4);
|
|
|
- showDigit(Tube_B, temp_h & 0xf);
|
|
|
- showDigit(Tube_D, temp_l >> 4);
|
|
|
- showDigit(Tube_E, temp_l & 0xf);
|
|
|
+ showDigit(Tube_A, hum_h / 10);
|
|
|
+ showDigit(Tube_B, hum_h % 10);
|
|
|
+ showDigit(Tube_D, hum_l / 10);
|
|
|
+ showDigit(Tube_E, hum_l % 10);
|
|
|
} else {
|
|
|
showDigit(Tube_A, Clock.Min >> 4);
|
|
|
showDigit(Tube_B, Clock.Min & 0xf);
|
|
@@ -271,7 +270,7 @@ int main(void)
|
|
|
SPI_StartTX();
|
|
|
|
|
|
RTOS_DispatchTask();
|
|
|
- //__WFI();
|
|
|
+ __WFI();
|
|
|
}
|
|
|
/* USER CODE END 3 */
|
|
|
}
|
|
@@ -291,6 +290,7 @@ int8_t user_i2c_read(const uint8_t id, const uint8_t reg_addr, uint8_t *data, co
|
|
|
/* prepare i2c for sending reg addr */
|
|
|
I2C1->CR2 &= ~( I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RD_WRN);
|
|
|
I2C1->CR2 |= ( id | 1 << I2C_CR2_NBYTES_Pos );
|
|
|
+ I2C1->CR1 |= I2C_CR1_NOSTRETCH;
|
|
|
/* gen START */
|
|
|
I2C1->CR2 |= ( I2C_CR2_START );
|
|
|
|
|
@@ -311,7 +311,8 @@ int8_t user_i2c_read(const uint8_t id, const uint8_t reg_addr, uint8_t *data, co
|
|
|
I2C1->TXDR = reg_addr;
|
|
|
|
|
|
/* wait for i2c */
|
|
|
- while ( I2C1->ISR & I2C_ISR_BUSY ) {};
|
|
|
+ while ( I2C1->ISR & I2C_ISR_BUSY ) {
|
|
|
+ }
|
|
|
|
|
|
/* prepare dma channel for receiving data */
|
|
|
DMA1_Channel2->CMAR = (uint32_t)data;
|
|
@@ -345,13 +346,13 @@ int8_t user_i2c_write(const uint8_t id, const uint8_t reg_addr, uint8_t *data, c
|
|
|
I2C1->CR2 |= ( I2C_CR2_START );
|
|
|
|
|
|
while ( !( I2C1->CR2 & I2C_CR2_START ) ) {};
|
|
|
+ I2C1->TXDR = reg_addr;
|
|
|
if ((I2C1->ISR & I2C_ISR_NACKF) != 0) {
|
|
|
I2C1->CR1 &= ~I2C_CR1_PE;
|
|
|
while ((I2C1->CR1 & I2C_CR1_PE) != 0) {};
|
|
|
I2C1->CR1 |= I2C_CR1_PE;
|
|
|
return I2C_RET_NACK;
|
|
|
}
|
|
|
- I2C1->TXDR = reg_addr;
|
|
|
|
|
|
DMA1_Channel3->CCR |= DMA_CCR_EN;
|
|
|
I2C1->CR1 |= ( I2C_CR1_TXDMAEN );
|