espressif / esp-hosted

Hosted Solution (Linux/MCU) with ESP32 (Wi-Fi + BT + BLE)
Other
711 stars 170 forks source link

esp-hosted-fg SPI can't use pin 33 as HS or DR #315

Open JAndrassy opened 10 months ago

JAndrassy commented 10 months ago

functions set_handshake_gpio, reset_handshake_gpio, set_dataready_gpio and reset_dataready_gpio use WRITE_PERI_REG which treats mask as a 32 bit value.

I want to make esp-hosted-fg work on Arduino Nano RP2040 Connect where the io available for DR and HS are io 0 and io 33.

mantriyogesh commented 10 months ago

WRITE_PERI_REG are all slave side part. Don't you use the slave and slave software as is?

You can always change the host, as per your need.

I am still trying to understand the problem, if you could detail a bit.

JAndrassy commented 10 months ago

spi_slaveapi.c

the io 33 mask for WRITE_PERI_REG is 1 << 33 which doesn't fit into 32 bits, but WRITE_PERI_REG casts it to 32 bit.

I think correct is

static inline void set_handshake_gpio(void)
{
  gpio_set_level(GPIO_HS, 1);
}

static inline void reset_handshake_gpio(void)
{
  gpio_set_level(GPIO_HS, 0);
}

static inline void set_dataready_gpio(void)
{
  gpio_set_level(GPIO_DR, 1);
}

static inline void reset_dataready_gpio(void)
{
  gpio_set_level(GPIO_DR, 0);
}

https://content.arduino.cc/assets/ABX00053-schematics.pdf

mantriyogesh commented 10 months ago

Yes. You are correct. Either use above changes, or use 1ULL << 33

JAndrassy commented 10 months ago

just 1ll is not enough

#define WRITE_PERI_REG(addr, val) do {                                                                                 \
            ASSERT_IF_DPORT_REG((addr), WRITE_PERI_REG);                                                               \
            (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val);                                       \
        } while(0)

there is (uint32_t)(val);

mantriyogesh commented 10 months ago

@JAndrassy ,

Yes, you are absolutely correct. We will correct the master with this change.

JAndrassy commented 8 months ago

I see now, there is already a PR https://github.com/espressif/esp-hosted/pull/248/ from last year