System: ESP32 with HSPI module
- My goal is: Use MISO (IO12) as a GPIO for another purpose
- My actions are: In config_schema the initialization parameters are
- ["spi.enable", true]
- ["spi.unit_no", 2]
- ["spi.mosi_gpio", 13]
- ["spi.miso_gpio", -1] #IO12 assigned as DC(GPIO) for LCD data/command
- ["spi.sclk_gpio", 14]
- ["spi.cs0_gpio", -1] #CS controlled by GPIO
- ["mydev", "o", {title: "mydev interface parameters"}]
- ["mydev.cs_index", "i", 0, {title: "spi.cs*_gpio index, 0, 1 or 2"}]
- ["mydev.spi_freq", "i", 40000000, {title: "SPI frequency"}]
- ["mydev.dc_pin", "i", 12, {title: "DC pin"}]
- ["mydev.cs_pin", "i", 15, {title: "CS pin"}]
- ["mydev.io26_pin", "i", 26, {title: "IO26 pin"}] #IO26 as a control experiment
IO12 configured as gpio in initialization section.
- The result I see is: IO12 is out of control. When I write a byte (e.g. 0x10) with MOSI, I try to output IO12 high but the result is like a clock output.
Snippet below shows the
//private fuction
static void lpm013_spi_write8_data(uint8_t byte) {
mgos_gpio_write(mgos_sys_config_get_mydev_dc_pin(), 1);
mgos_gpio_write(mgos_sys_config_get_mydev_io26_pin(), 1);
lpm013_spi_write(&byte, 1);
}
//...code to write a single byte 0x01 from mosi
lpm013_spi_cs_lo(); lpm013_spi_write8_data(0x10);lpm013_spi_cs_hi();
See Screen capture from a logic analyzer below
4. My expectation & question is:
I expected IO12, when it is not used as MISO it can be used for another purpose like DC by GPIO. It turns out that it is out of control.
Any idea why?