• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

adafruit/Adafruit-MCP23017-Arduino-Library

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

adafruit/Adafruit-MCP23017-Arduino-Library

开源软件地址(OpenSource Url):

https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library

开源编程语言(OpenSource Language):

C++ 100.0%

开源软件介绍(OpenSource Introduction):

Adafruit MCP23017 Arduino Library Build StatusDocumentation

This is a library for the MCP23008/17 I2C and MCP23S08/17 SPI Port Expanders.

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Carter Nelson for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution

To install, use the Arduino IDE Library Manager.

Pin Addressing

When using single pin operations such as pinMode(pinId, dir) or digitalRead(pinId) or digitalWrite(pinId, val) then the pins are addressed using the ID's below. For example, for set the mode of GPB0 then use pinMode(8, ...). NOTE The MCP23008 and MCP23S08 only have GPAx pins.

MCP23x08 Pin # MCP23x17 Pin # Pin Name Pin ID
10 21 GPA0 0
11 22 GPA1 1
12 23 GPA2 2
13 24 GPA3 3
14 25 GPA4 4
15 26 GPA5 5
16 27 GPA6 6
17 28 GPA7 7
-- 1 GPB0 8
-- 2 GPB1 9
-- 3 GPB2 10
-- 4 GPB3 11
-- 5 GPB4 12
-- 6 GPB5 13
-- 7 GPB6 14
-- 8 GPB7 15

Use of HW address pins for SPI device

Library supports MCP23Sxx HW pin addressing (A2, A1, A0 for S17 and A1, A0 for S08) To use it provide HW address to begin_SPI(CS, SPI, HW_ADDR) function, and as a result each SPI message will contain correct chip address.

Example: mcp.begin_SPI(10, &SPI, 0b101);

MCP23S08 uses addr pins by default. For MCP23S17 address recognition must be enabled by enableAddrPins() function. NOTE Calling enableAddrPins() will enable IOCON.HAEN bit for all active (CS low) devices on SPI bus. NOTE There is hardware bug in the MCP23S17 chip, see "MCP23S17 Rev. A Silicon Errata". As a result, if using device with A2 = high, and not using addressing, hw address must be set to 0b1XX In such case, even if not using addressing, initalize your MCP23S17 chip with 0b1XX address, eg: mcp.begin_SPI(10, &SPI, 0b100);.

Warning

Some people have reported an undocumented bug that can potentially corrupt the I2C bus. It occurs if an MCP230XX input pin state changes during I2C readout. This should be very rare. For more information, see this forum post and this knowledge base article.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
nanomsg/nanomsg: nanomsg library发布时间:2022-08-15
下一篇:
ant-design/ant-design: An enterprise-class UI design language and React UI libra ...发布时间:2022-08-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap