Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JAndrassy opened this issue Jan 13, 2024 · 6 comments
Open

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

JAndrassy opened this issue Jan 13, 2024 · 6 comments

Comments

@JAndrassy
Copy link

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
Copy link
Collaborator

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
Copy link
Author

JAndrassy commented Jan 13, 2024

spi_slave_api_.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
Copy link
Collaborator

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

@JAndrassy
Copy link
Author

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
Copy link
Collaborator

@JAndrassy ,

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

@JAndrassy
Copy link
Author

JAndrassy commented Mar 6, 2024

I see now, there is already a PR #248 from last year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants