Skip to content

Commit cb2ccaf

Browse files
committed
shitty fix
1 parent ccf1118 commit cb2ccaf

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
6262
"./Drivers/Embedded-Base/middleware/src/c_utils.c"
6363

6464
# Misc Embedded-Base Stuff (drivers, middleware, utils, etc.)
65+
"../Drivers/Embedded-Base/general/src/hdc2021debr.c"
6566
"../Drivers/Embedded-Base/general/src/sht30.c"
6667
"../Drivers/Embedded-Base/general/include/lsm6dsv_reg.h"
6768
"../Drivers/Embedded-Base/general/src/lsm6dsv_reg.c"

Core/Inc/u_sensors.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ void send_sht30_data();
7676
*/
7777
uint16_t init_hdc2021();
7878

79+
/**
80+
* @brief tells the hdc2021 to read and prepare data in its registers
81+
* @return whether there were errors
82+
*/
83+
uint16_t prepare_data_hdc2021();
84+
7985
/**
8086
* @brief reads temp and humidity data from the hdc2021
8187
* @return whether there were errors in reading the data

Core/Src/u_sensors.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,17 @@ uint16_t init_hdc2021() {
567567
return hdc2021_init(&hdc2021, (Write_ptr_hdc) _hdc2021_i2c_write, (Read_ptr_hdc) _hdc2021_i2c_read, HDC2021_I2C_ADDR);
568568
}
569569

570+
uint16_t prepare_data_hdc2021() {
571+
int status = hdc2021_trigger_oneshot(&hdc2021);
572+
573+
if (status) {
574+
PRINTLN_ERROR("ERROR: Failed to perform one-shot hdc2021 (Status: %d/%s).", status, hal_status_toString(status));
575+
return U_ERROR;
576+
}
577+
578+
return U_SUCCESS;
579+
}
580+
570581
uint16_t read_hdc2021() {
571582
int status = hdc2021_get_temp_humid(&hdc2021);
572583

Core/Src/u_threads.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ void sensors_thread(ULONG thread_input) {
5454
start_timer(&data_send_timer, DATA_SEND_INTERVAL);
5555
}
5656

57-
tx_thread_sleep(_sensors_thread.sleep);
57+
tx_thread_sleep(_sensors_thread.sleep / 2);
58+
59+
CATCH_ERROR(prepare_data_hdc2021(), U_SUCCESS);
60+
61+
tx_thread_sleep(_sensors_thread.sleep / 2);
5862
}
5963
}
6064

0 commit comments

Comments
 (0)