Closed JustinOng closed 1 year ago
Even though I am wondering, what the content of the external callback function is
I have 8 outputs on a shift register, and 8 on a I2C IO expander.
void set_dir(uint8_t index, uint8_t index_state) {
// Current state of the shift register output
static uint8_t state = 0;
state = (state & ~(1 << index)) | ((index_state & 1) << index);
spi_transaction_t t;
memset(&t, 0, sizeof(t));
t.length = 8;
t.flags = SPI_TRANS_USE_TXDATA;
t.tx_data[0] = state;
ESP_ERROR_CHECK(spi_device_polling_transmit(_spi_sr, &t));
}
void set_en(uint8_t index, uint8_t index_state) {
static uint8_t state = 0;
state = (state & ~(1 << index)) | ((index_state & 1) << index);
uint8_t data[] = {
2, state};
ESP_ERROR_CHECK(i2c_master_write_to_device(I2C_PORT, I2C_IO_EXP_ADDR, data, sizeof(data), portMAX_DELAY));
}
Hope those functions - despite stack usage - do not cause trouble with the 4ms task for updating the stepper queues
This increases the size of the stack allocated for StepperTask because it has been observed to overflow its stack when
setExternalCallForPin
is used.Tracing the free stack space indicates that the approximate stack space used:
setExternalCallForPin
: 748 bytessetExternalCallForPin
: 1092 bytesI've just arbitrarily doubled the stack size since the ESP32 has a significant amount of RAM available, though it might be good to consider if we can set this more intelligently.