Skip to content
Snippets Groups Projects

Basic PTT implementation

Merged schneider requested to merge schneider/ptt into master
Files
7
@@ -139,8 +139,6 @@ static int max86150_handle_sample(struct max86150_sensor_data *data)
@@ -139,8 +139,6 @@ static int max86150_handle_sample(struct max86150_sensor_data *data)
max86150_stream.was_full = false;
max86150_stream.was_full = false;
}
}
interrupt_trigger(EPIC_INT_MAX86150);
return 0;
return 0;
}
}
@@ -156,15 +154,23 @@ static int max86150_fetch_fifo(void)
@@ -156,15 +154,23 @@ static int max86150_fetch_fifo(void)
// There is a recommendation from Maxim not to read the entire FIFO, but rather a fixed number of samples.
// There is a recommendation from Maxim not to read the entire FIFO, but rather a fixed number of samples.
// See https://os.mbed.com/users/laserdad/code/MAX86150_ECG_PPG//file/3c728f3d1f10/main.cpp/
// See https://os.mbed.com/users/laserdad/code/MAX86150_ECG_PPG//file/3c728f3d1f10/main.cpp/
// So we should not use max86150_check() but max86150_get_sample().
// So we should not use max86150_check() but max86150_get_sample().
 
int n = 0;
while (max86150_get_sample(&sample.red, &sample.ir, &sample.ecg) > 0) {
while (max86150_get_sample(&sample.red, &sample.ir, &sample.ecg) > 0) {
 
n++;
result = max86150_handle_sample(&sample);
result = max86150_handle_sample(&sample);
// stop in case of errors
// stop in case of errors
if (result < 0) {
if (result < 0) {
 
n = 0;
break;
break;
}
}
}
}
hwlock_release(HWLOCK_I2C);
hwlock_release(HWLOCK_I2C);
mutex_unlock(&max86150_mutex);
mutex_unlock(&max86150_mutex);
 
 
if (n > 0) {
 
interrupt_trigger(EPIC_INT_MAX86150);
 
}
 
//LOG_INFO("max86150", "%d", n);
return result;
return result;
}
}
@@ -221,6 +227,20 @@ void vMAX86150Task(void *pvParameters)
@@ -221,6 +227,20 @@ void vMAX86150Task(void *pvParameters)
while (1) {
while (1) {
if (max86150_sensor_active) {
if (max86150_sensor_active) {
//LOG_INFO("max86150", "Interrupt!");
//LOG_INFO("max86150", "Interrupt!");
 
mutex_lock(&max86150_mutex);
 
hwlock_acquire(HWLOCK_I2C);
 
 
int i1 = max86150_get_int1();
 
 
hwlock_release(HWLOCK_I2C);
 
mutex_unlock(&max86150_mutex);
 
 
//LOG_INFO("max86150", "%d", i1);
 
 
if (i1 & 16) {
 
interrupt_trigger(EPIC_INT_MAX86150_PROX);
 
}
 
int ret = max86150_fetch_fifo();
int ret = max86150_fetch_fifo();
if (ret < 0) {
if (ret < 0) {
LOG_ERR("max86150", "Unknown error: %d", -ret);
LOG_ERR("max86150", "Unknown error: %d", -ret);
Loading