esp32c3 > gpio > mapping spi2 pins

BugSimpson
Posts: 22
Joined: Fri Oct 11, 2024 2:14 pm

esp32c3 > gpio > mapping spi2 pins

Postby BugSimpson » Tue Dec 17, 2024 9:34 am

Hello community, I'm trying in vain to get the pins from the SPI2 interface to the pins specified in the source code.

What have I forgotten?

Code: Untitled.c Select all


  gpio_pin_map_to_peripheral(6, 64);
gpio_pin_map_to_peripheral(12, 63);
gpio_pin_map_to_peripheral(13, 65);
gpio_pin_map_to_peripheral(16, 68);

gpio_set_io_mux(6, 2, 0); // gpio2 / miso (fspiq)
gpio_set_io_mux(12, 2, 0); // gpio6 / clock (fspiclk)
gpio_set_io_mux(13, 2, 0); // gpio7 / mosi (fspid)
gpio_set_io_mux(16, 2, 0); // gpio10 / chip select (fspics0)

void gpio_pin_map_to_peripheral( uint8_t _pin, uint8_t _periphSignal )
{
REG_WRITE( GPIO_FUNCx_OUT_SEL_CNFG_REG( _pin ), _periphSignal );
}

void gpio_set_io_mux(uint8_t _pin, uint8_t _func, uint8_t _inv )
{
REG_SET_BIT( IO_MUX_GPIOn_REG(_pin), (_func<12) | (_inv<<8));
}

MicroController
Posts: 2672
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp32c3 > gpio > mapping spi2 pins

Postby MicroController » Tue Dec 17, 2024 12:29 pm

Code: Select all

(_func<12)
Missing one "<"?

And MISO needs to be input.

BugSimpson
Posts: 22
Joined: Fri Oct 11, 2024 2:14 pm

Re: esp32c3 > gpio > mapping spi2 pins

Postby BugSimpson » Wed Dec 18, 2024 4:28 pm

ohh sh** yes! thank you. its work!

Who is online

Users browsing this forum: No registered users and 5 guests