2025-12-31 13:21:59 +03:00
222
2025-12-31 13:21:59 +03:00
2025-12-31 13:08:39 +03:00
2025-12-31 13:08:39 +03:00
2025-12-31 13:08:39 +03:00
2025-12-31 13:08:39 +03:00
2025-12-31 13:08:39 +03:00
2025-12-31 13:08:39 +03:00
2025-12-31 13:18:55 +03:00

#include "zh_mcp23s17.h"

#define SPI_HOST (SPI_HOST_MAX - 1)

spi_device_handle_t mcp23s17_handle = NULL;

// To speed up transfers, every SPI transfer sends a bunch of lines. This define specifies how many. More means more memory use, // but less overhead for setting up / finishing transfers. Make sure 240 is dividable by this. #define PARALLEL_LINES 16

void app_main(void) { esp_err_t ret; spi_device_handle_t spi; spi_bus_config_t buscfg = { .miso_io_num = 25, .mosi_io_num = 23, .sclk_io_num = 19, .quadwp_io_num = -1, .quadhd_io_num = -1, .max_transfer_sz = 16 * 320 * 2 + 8};

spi_device_interface_config_t devcfg = {
    .clock_speed_hz = 10 * 1000 * 1000, // Clock out at 10 MHz
    .mode = 0,                          // SPI mode 0
    .spics_io_num = 22,                 // CS pin
    .queue_size = 7,                    // We want to be able to queue 7 transactions at a time
    // .pre_cb = lcd_spi_pre_transfer_callback, // Specify pre-transfer callback to handle D/C line
};
// Initialize the SPI bus
ret = spi_bus_initialize(SPI_HOST, &buscfg, SPI_DMA_CH_AUTO);
ESP_ERROR_CHECK(ret);
// Attach the LCD to the SPI bus
ret = spi_bus_add_device(SPI_HOST, &devcfg, &mcp23s17_handle);
ESP_ERROR_CHECK(ret);

}

Description
ESP32 ESP-IDF component for MCP23S17 16-bit I/O expander.
Readme 842 KiB
Languages
CMake 100%