Tune I2C buffer size

custom
jacqueline 3 years ago
parent f77773496c
commit a1518afd3c
  1. 1
      main/gay-ipod-fw.cpp
  2. 8
      main/i2c.cpp

@ -17,7 +17,6 @@
#include "driver/sdspi_host.h" #include "driver/sdspi_host.h"
#include "driver/spi_common.h" #include "driver/spi_common.h"
#include "driver/spi_master.h" #include "driver/spi_master.h"
#include "esp_heap_trace.h"
#include "esp_intr_alloc.h" #include "esp_intr_alloc.h"
#include "esp_log.h" #include "esp_log.h"
#include "hal/gpio_types.h" #include "hal/gpio_types.h"

@ -6,12 +6,12 @@
namespace gay_ipod { namespace gay_ipod {
static constexpr int kCmdLinkSize = I2C_LINK_RECOMMENDED_SIZE(12);
I2CTransaction::I2CTransaction() { I2CTransaction::I2CTransaction() {
// Use a fixed size buffer to avoid many many tiny allocations. // Use a fixed size buffer to avoid many many tiny allocations.
// TODO: make this static and tune the size. possibly make it optional too? buffer_ = (uint8_t*) calloc(sizeof(uint8_t), kCmdLinkSize);
// threading. handle_ = i2c_cmd_link_create_static(buffer_, kCmdLinkSize);
buffer_ = (uint8_t*) calloc(sizeof(uint8_t), I2C_LINK_RECOMMENDED_SIZE(10));
handle_ = i2c_cmd_link_create_static(buffer_, I2C_LINK_RECOMMENDED_SIZE(10));
assert(handle_ != NULL && "failed to create command link"); assert(handle_ != NULL && "failed to create command link");
} }

Loading…
Cancel
Save