From a1518afd3cd0e3b7500c83f551115633e9c850c5 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 14 Oct 2022 15:45:00 +1100 Subject: [PATCH] Tune I2C buffer size --- main/gay-ipod-fw.cpp | 1 - main/i2c.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main/gay-ipod-fw.cpp b/main/gay-ipod-fw.cpp index 69c0f87f..ffbdea62 100644 --- a/main/gay-ipod-fw.cpp +++ b/main/gay-ipod-fw.cpp @@ -17,7 +17,6 @@ #include "driver/sdspi_host.h" #include "driver/spi_common.h" #include "driver/spi_master.h" -#include "esp_heap_trace.h" #include "esp_intr_alloc.h" #include "esp_log.h" #include "hal/gpio_types.h" diff --git a/main/i2c.cpp b/main/i2c.cpp index 9b218f3f..65ed9012 100644 --- a/main/i2c.cpp +++ b/main/i2c.cpp @@ -6,12 +6,12 @@ namespace gay_ipod { +static constexpr int kCmdLinkSize = I2C_LINK_RECOMMENDED_SIZE(12); + I2CTransaction::I2CTransaction() { // Use a fixed size buffer to avoid many many tiny allocations. - // TODO: make this static and tune the size. possibly make it optional too? - // threading. - buffer_ = (uint8_t*) calloc(sizeof(uint8_t), I2C_LINK_RECOMMENDED_SIZE(10)); - handle_ = i2c_cmd_link_create_static(buffer_, I2C_LINK_RECOMMENDED_SIZE(10)); + buffer_ = (uint8_t*) calloc(sizeof(uint8_t), kCmdLinkSize); + handle_ = i2c_cmd_link_create_static(buffer_, kCmdLinkSize); assert(handle_ != NULL && "failed to create command link"); }