From 4bb04a8cf0aa1114a47c49598250288f81315f06 Mon Sep 17 00:00:00 2001 From: Jake-Hensley Date: Sun, 2 Feb 2025 18:40:42 -0500 Subject: [PATCH 01/13] sht30 builds on msb --- Core/Inc/msb.h | 4 +++- Core/Src/msb.c | 27 +++++++++++++++++---------- Drivers/Embedded-Base | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Core/Inc/msb.h b/Core/Inc/msb.h index 9435f15..4a673bf 100644 --- a/Core/Inc/msb.h +++ b/Core/Inc/msb.h @@ -1,4 +1,3 @@ - #ifndef MSB_CENTRAL_H #define MSB_CENTRAL_H @@ -18,6 +17,9 @@ typedef enum { } device_loc_t; int8_t msb_init(); +Write_ptr sht30_i2c_write(sht3x_command_t command); +Read_ptr sht30_i2c_read(); + #ifdef SENSOR_TEMP int8_t central_temp_measure(uint16_t *temp, uint16_t *humidity); diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 3470f5e..81561d4 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -2,6 +2,7 @@ #include "lsm6dso.h" #include "lsm6dso_reg.h" #include "main.h" +#include "sht30.h" #include #include #include @@ -46,23 +47,29 @@ VL6180xDev_t tof; uint32_t adc1_buf[3]; #endif +inline Write_ptr sht30_i2c_write(sht3x_command_t command) { + return sht30_write_reg(&temp_sensor, command); +} + +inline Read_ptr sht30_i2c_read() { + return sht30_read_reg(&temp_sensor); +} + int8_t msb_init() { #ifdef SENSOR_TEMP /* Initialize the Onboard Temperature Sensor */ - temp_sensor = (sht30_t){ - .i2c_handle = &hi2c3, - }; - assert(!sht30_init(&temp_sensor)); /* This is always connected */ + sht30_t temp_sensor; + assert(!sht30_init(&temp_sensor, sht30_i2c_read(), sht30_i2c_write(SHT3X_COMMAND_MEASURE_HIGHREP_10HZ))); /* This is always connected */ #endif #ifdef SENSOR_IMU - /* Initialize the IMU */ + /* Initialize the IMU */ assert(!LSM6DSO_Init(&imu)); /* This is always connected */ /* Setup IMU Accelerometer */ LSM6DSO_ACC_Enable(&imu); - + /* Setup IMU Gyroscope */ LSM6DSO_GYRO_Enable(&imu); @@ -70,7 +77,7 @@ int8_t msb_init() LSM6DSO_ACC_Disable_Inactivity_Detection(&imu); #endif -#ifdef SENSOR_TOF +#ifdef SENSOR_TOFsht30_t /* Initialize the ToF sensor */ struct MyDev_t tof_get = { .i2c_bus_num = 0x29 << 1, @@ -106,9 +113,9 @@ int8_t central_temp_measure(uint16_t *temp, uint16_t *humidity) if (mut_stat) return mut_stat; - HAL_StatusTypeDef hal_stat = sht30_get_temp_humid(&temp_sensor); - if (hal_stat) - return hal_stat; + int status = sht30_get_temp_humid(&temp_sensor); + if (status) + return status; *temp = temp_sensor.temp; *humidity = temp_sensor.humidity; diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 6427e59..b2e2a67 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 6427e594510a830b62185d601df8a5c3815745d7 +Subproject commit b2e2a678def15ce102da4cf745f2c71c01b26e14 From 1ee7c34f00f174895fa4ae47f97c3676ed37b3e5 Mon Sep 17 00:00:00 2001 From: Jake-Hensley Date: Thu, 6 Feb 2025 20:29:55 -0500 Subject: [PATCH 02/13] msb is building with the new sht30 --- Drivers/Embedded-Base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index b2e2a67..cb0dc8a 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit b2e2a678def15ce102da4cf745f2c71c01b26e14 +Subproject commit cb0dc8a1e68ed309ab5adbd82da93cca23969086 From f26aeb5e24d09f371446290f9aacbed5f2f32433 Mon Sep 17 00:00:00 2001 From: Jake-Hensley Date: Thu, 13 Feb 2025 22:36:33 -0500 Subject: [PATCH 03/13] builds --- Core/Inc/msb.h | 2 -- Core/Src/msb.c | 10 +++++----- Drivers/Embedded-Base | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Core/Inc/msb.h b/Core/Inc/msb.h index 4a673bf..81157ee 100644 --- a/Core/Inc/msb.h +++ b/Core/Inc/msb.h @@ -17,8 +17,6 @@ typedef enum { } device_loc_t; int8_t msb_init(); -Write_ptr sht30_i2c_write(sht3x_command_t command); -Read_ptr sht30_i2c_read(); #ifdef SENSOR_TEMP diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 81561d4..f124e80 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -47,12 +47,12 @@ VL6180xDev_t tof; uint32_t adc1_buf[3]; #endif -inline Write_ptr sht30_i2c_write(sht3x_command_t command) { - return sht30_write_reg(&temp_sensor, command); +static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, uint8_t reg, uint8_t length) { + return HAL_I2C_Mem_Write(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY); } -inline Read_ptr sht30_i2c_read() { - return sht30_read_reg(&temp_sensor); +static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, uint8_t reg, uint8_t length) { + return HAL_I2C_Mem_Read(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY); } int8_t msb_init() @@ -60,7 +60,7 @@ int8_t msb_init() #ifdef SENSOR_TEMP /* Initialize the Onboard Temperature Sensor */ sht30_t temp_sensor; - assert(!sht30_init(&temp_sensor, sht30_i2c_read(), sht30_i2c_write(SHT3X_COMMAND_MEASURE_HIGHREP_10HZ))); /* This is always connected */ + assert(!sht30_init(&temp_sensor, (Read_ptr) sht30_i2c_read, (Write_ptr) sht30_i2c_write, (SHT30_I2C_ADDR))); /* This is always connected */ #endif #ifdef SENSOR_IMU diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index cb0dc8a..be3d260 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit cb0dc8a1e68ed309ab5adbd82da93cca23969086 +Subproject commit be3d260aae8b4543725d7a9aa8ae9fa5cb5399b9 From bc99930b1a3c9f1150ec34aa087616f1831c29d9 Mon Sep 17 00:00:00 2001 From: Jake-Hensley Date: Thu, 13 Feb 2025 22:39:31 -0500 Subject: [PATCH 04/13] formated --- Core/Inc/msb.h | 1 - Core/Src/msb.c | 22 +++++++++++++++------- Drivers/Embedded-Base | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Core/Inc/msb.h b/Core/Inc/msb.h index 81157ee..a619bee 100644 --- a/Core/Inc/msb.h +++ b/Core/Inc/msb.h @@ -18,7 +18,6 @@ typedef enum { int8_t msb_init(); - #ifdef SENSOR_TEMP int8_t central_temp_measure(uint16_t *temp, uint16_t *humidity); #endif diff --git a/Core/Src/msb.c b/Core/Src/msb.c index f124e80..b6d7600 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -47,12 +47,18 @@ VL6180xDev_t tof; uint32_t adc1_buf[3]; #endif -static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, uint8_t reg, uint8_t length) { - return HAL_I2C_Mem_Write(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY); +static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, + uint8_t reg, uint8_t length) +{ + return HAL_I2C_Mem_Write(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, + data, length, HAL_MAX_DELAY); } -static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, uint8_t reg, uint8_t length) { - return HAL_I2C_Mem_Read(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY); +static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, + uint8_t reg, uint8_t length) +{ + return HAL_I2C_Mem_Read(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, + data, length, HAL_MAX_DELAY); } int8_t msb_init() @@ -60,16 +66,18 @@ int8_t msb_init() #ifdef SENSOR_TEMP /* Initialize the Onboard Temperature Sensor */ sht30_t temp_sensor; - assert(!sht30_init(&temp_sensor, (Read_ptr) sht30_i2c_read, (Write_ptr) sht30_i2c_write, (SHT30_I2C_ADDR))); /* This is always connected */ + assert(!sht30_init(&temp_sensor, (Read_ptr)sht30_i2c_read, + (Write_ptr)sht30_i2c_write, + (SHT30_I2C_ADDR))); /* This is always connected */ #endif #ifdef SENSOR_IMU - /* Initialize the IMU */ + /* Initialize the IMU */ assert(!LSM6DSO_Init(&imu)); /* This is always connected */ /* Setup IMU Accelerometer */ LSM6DSO_ACC_Enable(&imu); - + /* Setup IMU Gyroscope */ LSM6DSO_GYRO_Enable(&imu); diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index be3d260..8aa7c9a 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit be3d260aae8b4543725d7a9aa8ae9fa5cb5399b9 +Subproject commit 8aa7c9a42725d0ec05e7e2ccdf5b5857f1feabfb From 754de77e2f038837ad5923cdad6843b673099ed9 Mon Sep 17 00:00:00 2001 From: Jake-Hensley Date: Wed, 5 Mar 2025 19:49:31 -0500 Subject: [PATCH 05/13] trying to test --- Core/Inc/msb.h | 2 +- Core/Inc/msb_conf.h | 2 +- Core/Src/monitor.c | 13 +++++++------ Core/Src/msb.c | 17 ++++++++--------- Drivers/Embedded-Base | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Core/Inc/msb.h b/Core/Inc/msb.h index a619bee..5698450 100644 --- a/Core/Inc/msb.h +++ b/Core/Inc/msb.h @@ -19,7 +19,7 @@ typedef enum { int8_t msb_init(); #ifdef SENSOR_TEMP -int8_t central_temp_measure(uint16_t *temp, uint16_t *humidity); +int8_t central_temp_measure(float *temp, float *humidity); #endif #ifdef SENSOR_TOF diff --git a/Core/Inc/msb_conf.h b/Core/Inc/msb_conf.h index d94eb72..a9f5c3d 100644 --- a/Core/Inc/msb_conf.h +++ b/Core/Inc/msb_conf.h @@ -35,7 +35,7 @@ #define SENSOR_STRAIN //#define SENSOR_TOF -#define SENSOR_IMU +//jake #define SENSOR_IMU // on knuckle or /wheel //#define SENSOR_WHEEL_TEMP diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index 57a3cef..e2b44d2 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -4,6 +4,7 @@ #include "cmsis_os.h" #include "msb.h" #include "msb_conf.h" +#include "sht30.h" #include "stm32f405xx.h" #include @@ -46,12 +47,12 @@ void vTempMonitor(void *pv_params) .data = { 0 } }; struct __attribute__((__packed__)) { - uint16_t temp; - uint16_t humidity; + float temp; + float humidity; } temp_sensor_data; - uint16_t temp_dat = 0; - uint16_t humidity_dat = 0; + float temp_dat = 0; + float humidity_dat = 0; for (;;) { if (central_temp_measure(&temp_dat, &humidity_dat)) { @@ -62,8 +63,8 @@ void vTempMonitor(void *pv_params) temp_sensor_data.humidity = humidity_dat; #ifdef LOG_VERBOSE - printf("Board Temperature:\t%d\r\n", temp_sensor_data.temp); - printf("Board Humidity:\t%d\r\n", temp_sensor_data.humidity); + printf("Board Temperature:\t%f\r\n", temp_sensor_data.temp); + printf("Board Humidity:\t%f\r\n", temp_sensor_data.humidity); #endif endian_swap(&temp_sensor_data.temp, diff --git a/Core/Src/msb.c b/Core/Src/msb.c index b6d7600..71df179 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -48,14 +48,14 @@ uint32_t adc1_buf[3]; #endif static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, - uint8_t reg, uint8_t length) + uint8_t length) { - return HAL_I2C_Mem_Write(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, - data, length, HAL_MAX_DELAY); + return HAL_I2C_Master_Transmit(&hi2c3, dev_address, + data, length, HAL_MAX_DELAY); } static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, - uint8_t reg, uint8_t length) + uint16_t reg, uint8_t length) { return HAL_I2C_Mem_Read(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, data, length, HAL_MAX_DELAY); @@ -66,8 +66,7 @@ int8_t msb_init() #ifdef SENSOR_TEMP /* Initialize the Onboard Temperature Sensor */ sht30_t temp_sensor; - assert(!sht30_init(&temp_sensor, (Read_ptr)sht30_i2c_read, - (Write_ptr)sht30_i2c_write, + assert(!sht30_init(&temp_sensor, (Write_ptr) sht30_i2c_write, (Read_ptr) sht30_i2c_read, (SHT30_I2C_ADDR))); /* This is always connected */ #endif @@ -85,7 +84,7 @@ int8_t msb_init() LSM6DSO_ACC_Disable_Inactivity_Detection(&imu); #endif -#ifdef SENSOR_TOFsht30_t +#ifdef SENSOR_TOF /* Initialize the ToF sensor */ struct MyDev_t tof_get = { .i2c_bus_num = 0x29 << 1, @@ -115,13 +114,13 @@ int8_t msb_init() /// @brief Measure the temperature and humidity of central MSB SHT30 /// @param out /// @return error code -int8_t central_temp_measure(uint16_t *temp, uint16_t *humidity) +int8_t central_temp_measure(float *temp, float *humidity) { osStatus_t mut_stat = osMutexAcquire(i2c_mutex, osWaitForever); if (mut_stat) return mut_stat; - int status = sht30_get_temp_humid(&temp_sensor); + uint8_t status = sht30_get_temp_humid(&temp_sensor); if (status) return status; diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 8aa7c9a..c47affa 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 8aa7c9a42725d0ec05e7e2ccdf5b5857f1feabfb +Subproject commit c47affafba2cb6e881fce7600ecd50b7048a7fd5 From 59a24393bea02720932edf3d51546a125a835790 Mon Sep 17 00:00:00 2001 From: Jack Rubacha Date: Wed, 5 Mar 2025 20:11:48 -0500 Subject: [PATCH 06/13] fix vars --- Core/Src/msb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 71df179..3a4718c 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -65,7 +65,6 @@ int8_t msb_init() { #ifdef SENSOR_TEMP /* Initialize the Onboard Temperature Sensor */ - sht30_t temp_sensor; assert(!sht30_init(&temp_sensor, (Write_ptr) sht30_i2c_write, (Read_ptr) sht30_i2c_read, (SHT30_I2C_ADDR))); /* This is always connected */ #endif From d24f2d1651d8cacee98608c3807bad5023f95bb6 Mon Sep 17 00:00:00 2001 From: Caio Date: Wed, 2 Apr 2025 16:28:09 -0400 Subject: [PATCH 07/13] fix embedded base --- Drivers/Embedded-Base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 26ba9d6..95a87ca 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 26ba9d66fc18d0739586811f0641305c1ce55b7c +Subproject commit 95a87cad7b640c44c8ac0201f8fd1a5c3979b693 From de39881313498837745739d3cb906521a4ef0755 Mon Sep 17 00:00:00 2001 From: Caio Date: Fri, 4 Apr 2025 22:37:16 -0400 Subject: [PATCH 08/13] getting data --- Core/Src/monitor.c | 4 ++-- Core/Src/msb.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index 94bfc8b..be7dcee 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -63,8 +63,8 @@ void vTempMonitor(void *pv_params) temp_sensor_data.humidity = humidity_dat; #ifdef LOG_VERBOSE - printf("Board Temperature:\t%f\r\n", temp_sensor_data.temp); - printf("Board Humidity:\t%f\r\n", temp_sensor_data.humidity); + printf("Board Temperature:\t%d\r\n", (uint8_t)(temp_sensor_data.temp * 100)); + printf("Board Humidity:\t%d\r\n", (uint8_t)(temp_sensor_data.humidity * 100)); #endif endian_swap(&temp_sensor_data.temp, diff --git a/Core/Src/msb.c b/Core/Src/msb.c index c981163..8852c63 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -53,16 +53,23 @@ uint32_t adc1_buf[3]; static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, uint8_t length) -{ +{ + printf("address: %d\n", dev_address); + printf("length: %d\n", length); + return HAL_I2C_Master_Transmit(&hi2c3, dev_address, data, length, HAL_MAX_DELAY); } static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, - uint16_t reg, uint8_t length) + uint8_t length) { - return HAL_I2C_Mem_Read(&hi2c3, dev_address, reg, I2C_MEMADD_SIZE_8BIT, - data, length, HAL_MAX_DELAY); + printf("address: %d\n", dev_address); + printf("length: %d\n", length); + + HAL_Delay(1); // 1 ms delay to ensure sht30 returns to idle state + return HAL_I2C_Master_Receive(&hi2c3, dev_address, data, length, + HAL_MAX_DELAY); } int8_t msb_init() From f743c20259e015a3c538c94b1e0439d6c27cd48d Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 5 Apr 2025 14:35:59 -0400 Subject: [PATCH 09/13] working temps --- Core/Src/monitor.c | 6 +++--- Core/Src/msb.c | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index be7dcee..60d4913 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -63,10 +63,10 @@ void vTempMonitor(void *pv_params) temp_sensor_data.humidity = humidity_dat; #ifdef LOG_VERBOSE - printf("Board Temperature:\t%d\r\n", (uint8_t)(temp_sensor_data.temp * 100)); - printf("Board Humidity:\t%d\r\n", (uint8_t)(temp_sensor_data.humidity * 100)); + printf("Board Temperature:\t%d\r\n", (uint16_t)(temp_sensor_data.temp * 100) / 100); + printf("Board Humidity:\t%d\r\n", (uint16_t)(temp_sensor_data.humidity * 100) / 100); #endif - + endian_swap(&temp_sensor_data.temp, sizeof(temp_sensor_data.temp)); endian_swap(&temp_sensor_data.humidity, diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 8852c63..c7deb42 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -54,9 +54,6 @@ uint32_t adc1_buf[3]; static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, uint8_t length) { - printf("address: %d\n", dev_address); - printf("length: %d\n", length); - return HAL_I2C_Master_Transmit(&hi2c3, dev_address, data, length, HAL_MAX_DELAY); } @@ -64,9 +61,6 @@ static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, uint8_t length) { - printf("address: %d\n", dev_address); - printf("length: %d\n", length); - HAL_Delay(1); // 1 ms delay to ensure sht30 returns to idle state return HAL_I2C_Master_Receive(&hi2c3, dev_address, data, length, HAL_MAX_DELAY); From 376be3c7c4612d02f0c8afd8516b277f7c06cc56 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 5 Apr 2025 15:09:55 -0400 Subject: [PATCH 10/13] working --- Core/Src/msb.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Core/Src/msb.c b/Core/Src/msb.c index c7deb42..2202e46 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -53,14 +53,25 @@ uint32_t adc1_buf[3]; static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, uint8_t length) -{ +{ return HAL_I2C_Master_Transmit(&hi2c3, dev_address, data, length, HAL_MAX_DELAY); } -static inline uint8_t sht30_i2c_read(uint8_t *data, uint8_t dev_address, - uint8_t length) +static inline uint8_t sht30_i2c_read(uint8_t *data, uint16_t command, + uint8_t dev_address, uint8_t length) +{ + return HAL_I2C_Mem_Read(&hi2c3, SHT30_I2C_ADDR, command, + sizeof(command), data, length, HAL_MAX_DELAY); +} + +static inline uint8_t sht30_i2c_blocking_read(uint8_t *data, uint16_t command, + uint8_t dev_address, + uint8_t length) { + uint8_t command_buffer[2] = { (command & 0xff00u) >> 8u, + command & 0xffu }; + sht30_i2c_write(command_buffer, dev_address, sizeof(command_buffer)); HAL_Delay(1); // 1 ms delay to ensure sht30 returns to idle state return HAL_I2C_Master_Receive(&hi2c3, dev_address, data, length, HAL_MAX_DELAY); @@ -72,6 +83,7 @@ int8_t msb_init() /* Initialize the Onboard Temperature Sensor */ assert(!sht30_init(&temp_sensor, (Write_ptr)sht30_i2c_write, (Read_ptr)sht30_i2c_read, + (Read_ptr)sht30_i2c_blocking_read, (SHT30_I2C_ADDR))); /* This is always connected */ #endif From 28c8158859218064038bc3739c35d0ff07173a10 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 5 Apr 2025 15:40:10 -0400 Subject: [PATCH 11/13] working --- Core/Src/msb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 2202e46..3b65fe0 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -61,16 +61,18 @@ static inline uint8_t sht30_i2c_write(uint8_t *data, uint8_t dev_address, static inline uint8_t sht30_i2c_read(uint8_t *data, uint16_t command, uint8_t dev_address, uint8_t length) { - return HAL_I2C_Mem_Read(&hi2c3, SHT30_I2C_ADDR, command, - sizeof(command), data, length, HAL_MAX_DELAY); + return HAL_I2C_Mem_Read(&hi2c3, dev_address, command, sizeof(command), + data, length, HAL_MAX_DELAY); } +// blocking read uses master transmit (in blocking mode) static inline uint8_t sht30_i2c_blocking_read(uint8_t *data, uint16_t command, uint8_t dev_address, uint8_t length) -{ +{ uint8_t command_buffer[2] = { (command & 0xff00u) >> 8u, command & 0xffu }; + // write command to sht30 before reading sht30_i2c_write(command_buffer, dev_address, sizeof(command_buffer)); HAL_Delay(1); // 1 ms delay to ensure sht30 returns to idle state return HAL_I2C_Master_Receive(&hi2c3, dev_address, data, length, From 7bafe6ee678e89331f648912678307134af9f519 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 5 Apr 2025 15:42:02 -0400 Subject: [PATCH 12/13] format --- Core/Src/monitor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index 60d4913..ebc05ec 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -63,10 +63,12 @@ void vTempMonitor(void *pv_params) temp_sensor_data.humidity = humidity_dat; #ifdef LOG_VERBOSE - printf("Board Temperature:\t%d\r\n", (uint16_t)(temp_sensor_data.temp * 100) / 100); - printf("Board Humidity:\t%d\r\n", (uint16_t)(temp_sensor_data.humidity * 100) / 100); + printf("Board Temperature:\t%d\r\n", + (uint16_t)(temp_sensor_data.temp * 100) / 100); + printf("Board Humidity:\t%d\r\n", + (uint16_t)(temp_sensor_data.humidity * 100) / 100); #endif - + endian_swap(&temp_sensor_data.temp, sizeof(temp_sensor_data.temp)); endian_swap(&temp_sensor_data.humidity, From 9013944a51c1bab32ca3982b0df016e0a7f8d13c Mon Sep 17 00:00:00 2001 From: Jack Rubacha Date: Sat, 1 Nov 2025 18:40:41 -0400 Subject: [PATCH 13/13] fixups --- Core/Inc/msb.h | 3 +++ Core/Src/monitor.c | 9 +++++---- Core/Src/msb.c | 5 +---- Drivers/Embedded-Base | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Core/Inc/msb.h b/Core/Inc/msb.h index 35499c0..5b920ea 100644 --- a/Core/Inc/msb.h +++ b/Core/Inc/msb.h @@ -20,6 +20,9 @@ typedef enum { int8_t msb_init(); #ifdef SENSOR_TEMP +/// @brief Measure the temperature and humidity of central MSB SHT30 +/// @param out +/// @return error code int8_t central_temp_measure(float *temp, float *humidity); #endif diff --git a/Core/Src/monitor.c b/Core/Src/monitor.c index 4ce6030..a84f333 100644 --- a/Core/Src/monitor.c +++ b/Core/Src/monitor.c @@ -63,12 +63,13 @@ void vTempMonitor(void *pv_params) temp_sensor_data.humidity = humidity_dat; #ifdef LOG_VERBOSE - printf("Board Temperature:\t%d\r\n", - (uint16_t)(temp_sensor_data.temp * 100) / 100); - printf("Board Humidity:\t%d\r\n", - (uint16_t)(temp_sensor_data.humidity * 100) / 100); + printf("Board Temperature: %f\n", temp_sensor_data.temp); + printf("Board Humidity:%f\n", temp_sensor_data.humidity); #endif + printf("Board Temperature: %f\n", temp_sensor_data.temp); + printf("Board Humidity:%f\n", temp_sensor_data.humidity); + endian_swap(&temp_sensor_data.temp, sizeof(temp_sensor_data.temp)); endian_swap(&temp_sensor_data.humidity, diff --git a/Core/Src/msb.c b/Core/Src/msb.c index 3ed13be..beda0e5 100644 --- a/Core/Src/msb.c +++ b/Core/Src/msb.c @@ -68,7 +68,7 @@ static inline uint8_t sht30_i2c_read(uint8_t *data, uint16_t command, static inline uint8_t sht30_i2c_blocking_read(uint8_t *data, uint16_t command, uint8_t dev_address, uint8_t length) -{ +{ uint8_t command_buffer[2] = { (command & 0xff00u) >> 8u, command & 0xffu }; // write command to sht30 before reading @@ -138,9 +138,6 @@ int8_t msb_init() } #ifdef SENSOR_TEMP -/// @brief Measure the temperature and humidity of central MSB SHT30 -/// @param out -/// @return error code int8_t central_temp_measure(float *temp, float *humidity) { osStatus_t mut_stat = osMutexAcquire(i2c_mutex, osWaitForever); diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 95a87ca..6e8d052 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 95a87cad7b640c44c8ac0201f8fd1a5c3979b693 +Subproject commit 6e8d05283e858487eb9ba0fd35f9809d48dd9f4b