Second ADC debugging in process

This commit is contained in:
2026-04-21 16:11:07 +02:00
parent dce6b0fd4f
commit 7e7d0a1c59
7 changed files with 199 additions and 156 deletions

View File

@@ -14,10 +14,11 @@
#include "Arduino.h"
#include "ADS1256.h"
#include "SPI.h"
#include <DebugLog.h>
#define convertSigned24BitToLong(value) ((value) & (1l << 23) ? (value) - 0x1000000 : value)
void drdyCallback(void *arg)
void IRAM_ATTR drdyCallback(void *arg)
{
auto cls = (ADS1256 *)arg;
if (!arg)
@@ -61,11 +62,16 @@ ADS1256::ADS1256(const int8_t DRDY_pin, const int8_t RESET_pin, const int8_t SYN
updateConversionParameter();
m_drdyHigh = xSemaphoreCreateBinary();
m_drdyLow = xSemaphoreCreateBinary();
xSemaphoreGive(m_drdyHigh);
xSemaphoreGive(m_drdyLow);
attachInterruptArg(DRDY_pin, drdyCallback, (void *)this, CHANGE);
// 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);
}
// Initialization
@@ -119,14 +125,16 @@ void ADS1256::InitializeADC()
void ADS1256::waitForLowDRDY()
{
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()
{
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