MCP23S17 ESP-IDF library

commando_j
Posts: 21
Joined: Tue Feb 05, 2019 5:26 pm

MCP23S17 ESP-IDF library

Postby commando_j » Mon Feb 18, 2019 4:24 pm

Hello,

I'm wondering if anyone has made any progress in a library for the MCP23S17 (SPI version) that is native to the ESP-IDF? I have seen the Arduino version, but I'm having trouble understanding how to get it to work with ESP-IDF and Eclipse. I saw a few people working on a solution, but no one posted any final resolution. I'm hoping someone completed their work and would share their solutions.

Thanks

mikemoy
Posts: 264
Joined: Fri Jan 12, 2018 9:10 pm

Re: MCP23S17 ESP-IDF library

Postby mikemoy » Mon Feb 18, 2019 6:31 pm

Give this a shot
Attachments
main_18_02_2019_122955.zip
(4.27 KiB) Downloaded 54 times

commando_j
Posts: 21
Joined: Tue Feb 05, 2019 5:26 pm

Re: MCP23S17 ESP-IDF library

Postby commando_j » Mon Feb 18, 2019 6:42 pm

Thank you! Can't wait to get home and try it.

May take a day or two. I'm about to test to make sure I can send something on the bus with simple transmit command to make sure the connections and initilization of SPI is good.

Love the forum.

commando_j
Posts: 21
Joined: Tue Feb 05, 2019 5:26 pm

Re: MCP23S17 ESP-IDF library

Postby commando_j » Mon Feb 25, 2019 2:28 am

It works!

After getting home the other night, I blew up my one prototype by putting 12V to the ESP32 reset line! So I just got everything hooked back up with my ESP32 dev board and just the MCP23S17 on my PCB, connected with jumper wires.

I noted that your SPI setup is only running at 10Khz, is there a reason why it's so low?
Other notes:
- You write to GPIOA only, but you write 2 bytes, so essentially you write to GPIOA and B at the same time. You do this elsewhere with other registers that are next to each other. Not an issue, just took me a bit of time to see that.
- In the GpioMode function, you set _modeCache = mode, but _modeCache is not used to write a Word to the MCP23S17. I figure for this one routine, setting _modeCache was not needed.

Thanks again.

mikemoy
Posts: 264
Joined: Fri Jan 12, 2018 9:10 pm

Re: MCP23S17 ESP-IDF library

Postby mikemoy » Mon Feb 25, 2019 3:37 am

I noted that your SPI setup is only running at 10Khz, is there a reason why it's so low?
I dont need the speed for my application and my PCB is 12" x 13" in size. The ESP32 is on one end and the MCP23S17 is on the other end, so I did not want to run a high freq across the PCB.
You write to GPIOA only, but you write 2 bytes, so essentially you write to GPIOA and B at the same time. You do this elsewhere with other registers that are next to each other. Not an issue, just took me a bit of time to see that.
Correct, The part is set up in auto increment mode. So when you write to GPIOA, it will auto increment the register so you can then write to that register without issuing another register location and write again. Its just a way to write a word faster to it.
In the GpioMode function, you set _modeCache = mode, but _modeCache is not used to write a Word to the MCP23S17. I figure for this one routine, setting _modeCache was not needed.
It is needed because if you later use mcp23S17_GpioPinMode, because it uses _modeCache

bonmotwang
Posts: 22
Joined: Fri Apr 12, 2019 4:25 pm
Location: Canada

Re: MCP23S17 ESP-IDF library

Postby bonmotwang » Fri Jun 14, 2019 8:13 pm

mikemoy wrote:
Mon Feb 18, 2019 6:31 pm
Give this a shot
You are the best!

Thanks

Paul

Who is online

Users browsing this forum: Baidu [Spider] and 21 guests