re enable interrupt logic for ADC drdy

This commit is contained in:
2026-04-21 22:32:01 +02:00
parent aa9935ef22
commit 9bb66a9459

View File

@@ -11,6 +11,8 @@
RadoMmm for suggesting an improvement on the ADC-to-Volts conversion
*/
#define DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG
#include "Arduino.h"
#include "ADS1256.h"
#include "SPI.h"
@@ -62,16 +64,16 @@ ADS1256::ADS1256(const int8_t DRDY_pin, const int8_t RESET_pin, const int8_t SYN
updateConversionParameter();
// m_drdyHigh = xSemaphoreCreateBinary();
// m_drdyLow = xSemaphoreCreateBinary();
// if (!m_drdyHigh || !m_drdyLow) {
// LOG_ERROR("ADC Unable to create interrupt semaphores");
// return;
// }
m_drdyHigh = xSemaphoreCreateBinary();
m_drdyLow = xSemaphoreCreateBinary();
if (!m_drdyHigh || !m_drdyLow) {
LOG_ERROR("ADC Unable to create interrupt semaphores");
return;
}
// xSemaphoreGive(m_drdyHigh);
// xSemaphoreGive(m_drdyLow);
//attachInterruptArg(DRDY_pin, drdyCallback, (void *)this, CHANGE);
xSemaphoreGive(m_drdyHigh);
xSemaphoreGive(m_drdyLow);
attachInterruptArg(DRDY_pin, drdyCallback, (void *)this, CHANGE);
}
// Initialization
@@ -125,16 +127,16 @@ void ADS1256::InitializeADC()
void ADS1256::waitForLowDRDY()
{
while(digitalRead(m_DRDY_pin) == HIGH) {vTaskDelay(1);};
// xSemaphoreTake(m_drdyLow, pdMS_TO_TICKS(10));
// xSemaphoreGive(m_drdyLow);
// while(digitalRead(m_DRDY_pin) == HIGH) {vTaskDelay(1);};
xSemaphoreTake(m_drdyLow, pdMS_TO_TICKS(10));
xSemaphoreGive(m_drdyLow);
}
void ADS1256::waitForHighDRDY()
{
while(digitalRead(m_DRDY_pin) == LOW) {vTaskDelay(1);};
// xSemaphoreTake(m_drdyHigh, pdMS_TO_TICKS(10));
// xSemaphoreGive(m_drdyHigh);
// while(digitalRead(m_DRDY_pin) == LOW) {vTaskDelay(1);};
xSemaphoreTake(m_drdyHigh, pdMS_TO_TICKS(10));
xSemaphoreGive(m_drdyHigh);
}
void ADS1256::stopConversion() // Sending SDATAC to stop the continuous conversion