Decreased limit of frame size to 10 words to cater for static DRAM_ATTR frames

This commit is contained in:
Chris Stuurman 2026-05-02 16:47:41 +02:00
parent 678312a27d
commit 477f05a524
2 changed files with 6 additions and 7 deletions

View File

@ -17,7 +17,6 @@ namespace ads131m08 {
static const char *const TAG = "ads131m08";
static const char *const white_space = " \t\n\r\f\v"; // Defines whitespace
//TODO: RREG might be longer than allocated frame size. work out max length and update following accordingly
DRAM_ATTR static spiframe tx_frame(ADS131M08Hub::numFrameWords * 4, 0);
DRAM_ATTR static spiframe rx_frame(ADS131M08Hub::numFrameWords * 4, 0);
@ -327,7 +326,7 @@ bool ADS131M08Hub::set_frame_word(spiframe &frame, int w_index, uint16_t data)
size_t frame_words = frame.size() / word_nbytes;
int b_index = w_index * word_nbytes;
if (w_index >= frame_words) {
if (w_index > MAX_FRAME_SIZE) {
if (w_index >= MAX_FRAME_SIZE) {
ESP_LOGE(TAG, "Word index of %d out of bounds", w_index);
// esp_crosscore_int_send_print_backtrace(xPortGetCoreID());
return false; // invalid - something has gone wrong
@ -357,7 +356,7 @@ bool ADS131M08Hub::set_frame_word(spiframe &frame, int w_index, uint32_t data)
size_t frame_words = frame.size() / word_nbytes;
int b_index = w_index * word_nbytes;
if (w_index >= frame_words) {
if (w_index > MAX_FRAME_SIZE) {
if (w_index >= MAX_FRAME_SIZE) {
ESP_LOGE(TAG, "Word index of %d out of bounds", w_index);
// esp_crosscore_int_send_print_backtrace(xPortGetCoreID());
return false; // invalid - something has gone wrong
@ -1028,9 +1027,9 @@ uint16_str ADS131M08Hub::adc_register_read(uint8_t address, uint8_t nregs) {
if (nregs == 0) {
return result; // invalid
}
if (nregs > 31) {
// We are limited to 31 registers, otherwise we will ran into DMA / SPI buffer problems
ESP_LOGE(TAG, "Trying to read %d registers. This exceeds maximum register read count of 31!", nregs);
if (nregs > MAX_FRAME_SIZE - 2) {
// We are limited to 8 registers, otherwise we will exceed our static DMA / SPI buffer size
ESP_LOGE(TAG, "Trying to read %d registers. This exceeds maximum register read count of %d!", nregs, MAX_FRAME_SIZE - 2);
return result; // invalid
}
int word_nbytes = adc_word_length_ >> 3;

View File

@ -6,7 +6,7 @@ namespace esphome {
namespace ads131m08 {
static constexpr size_t MAX_FRAME_SIZE =
50; // in frame_words. This is an arbitrary limit, if frame is above this size something must have gone wrong
10; // in frame_words. If frame is above this size something must have gone wrong
enum ADC_DRDY_STATE : uint8_t {
DS_LOGIC_HIGH = 0, // DEFAULT