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
MCP23S17 ESP-IDF library
Re: MCP23S17 ESP-IDF library
Give this a shot
- Attachments
-
- main_18_02_2019_122955.zip
- (4.27 KiB) Downloaded 942 times
-
- Posts: 27
- Joined: Tue Feb 05, 2019 5:26 pm
Re: MCP23S17 ESP-IDF library
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.
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.
-
- Posts: 27
- Joined: Tue Feb 05, 2019 5:26 pm
Re: MCP23S17 ESP-IDF library
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.
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.
Re: MCP23S17 ESP-IDF library
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.I noted that your SPI setup is only running at 10Khz, is there a reason why it's so low?
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.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.
It is needed because if you later use mcp23S17_GpioPinMode, because it uses _modeCacheIn 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.
-
- Posts: 42
- Joined: Fri Apr 12, 2019 4:25 pm
- Location: Canada
Who is online
Users browsing this forum: No registered users and 111 guests