From 1fd7e6f2870e2b06e08af74c7cecc93c2879e8d6 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Tue, 28 Apr 2020 20:13:56 +0200
Subject: [PATCH] refact(bme680): Use new style HW locks

---
 epicardium/modules/bme680.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/epicardium/modules/bme680.c b/epicardium/modules/bme680.c
index caadf68b9..8cda3a6e2 100644
--- a/epicardium/modules/bme680.c
+++ b/epicardium/modules/bme680.c
@@ -43,9 +43,7 @@ int epic_bme680_init()
 		return 0;
 	}
 
-	if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
-		return -EBUSY;
-	}
+	hwlock_acquire(HWLOCK_I2C);
 
 	bme.dev_id   = BME680_I2C_ADDR_PRIMARY;
 	bme.intf     = BME680_I2C_INTF;
@@ -110,9 +108,7 @@ int epic_bme680_deinit()
 		return 0;
 	}
 
-	if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
-		return -EBUSY;
-	}
+	hwlock_acquire(HWLOCK_I2C);
 
 	int8_t result = bme680_soft_reset(&bme);
 	if (result != BME680_OK) {
@@ -133,9 +129,7 @@ int epic_bme680_read_sensors(struct bme680_sensor_data *data)
 		return -EINVAL;
 	}
 
-	if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
-		return -EBUSY;
-	}
+	hwlock_acquire(HWLOCK_I2C);
 
 	uint16_t profile_dur = 0;
 	bme680_get_profile_dur(&profile_dur, &bme);
@@ -152,9 +146,7 @@ int epic_bme680_read_sensors(struct bme680_sensor_data *data)
 	 */
 	hwlock_release(HWLOCK_I2C);
 	vTaskDelay(pdMS_TO_TICKS(profile_dur));
-	if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
-		return -EBUSY;
-	}
+	hwlock_acquire(HWLOCK_I2C);
 
 	struct bme680_field_data raw_data;
 	result = bme680_get_sensor_data(&raw_data, &bme);
-- 
GitLab