You can chat about native SDK questions and issues here.

User avatar
By CARPP
#85080 from my own struct?

For code-cleanup reasons I decided to refactor the SPI-part of my code into a separate struct. This struct has an internal variable of type *spi_trans_t* and two buffers (one for *mosi* and *miso* respectively).
But the ESP8266 just keeps crashing if I keep calling *spi_trans()* from inside a function of that struct - why is that?

Code: Select alltypedef enum STATE {
   IDLE = 0,
   READY = 1,
   WROTE_WRITE_CMD = 2,
   WROTE_READ_CMD = 3,
   SENT_READ_CLK = 4
} STATE;

typedef struct SPI_HANDLER {
   
   STATE state;
   spi_trans_t spi_t;

   bool hasPendingTransmit;

   uint8_t trans_data[TRANS_ARRAY_LEN];
   uint8_t recv_data[RECV_ARRAY_LEN];
   
   void (*finishedWriteRequestCallback)(void);
   void (*finishedReadRequestCallback)(uint8_t data);
   
   void (*writeToRAM)(struct SPI_HANDLER*, uint32_t addr, uint8_t data);
   void (*readFromRAM)(struct SPI_HANDLER*, uint32_t addr);

   void (*notifyTransmitFinished)(struct SPI_HANDLER*);
   
} SPI_HANDLER;


It works if I create spi_trans_t and the two buffers inside main.c. Anyone else who did encounter that problem?

I am using the latest RTOS SDK btw.