Skip to content

Commit ccdacdd

Browse files
committed
mcp960x: fix incorrect I2C addressing
1 parent a43fa64 commit ccdacdd

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

components/mcp960x/mcp960x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ esp_err_t mcp960x_init_desc(mcp960x_t *dev, uint8_t addr, i2c_port_t port, gpio_
172172
{
173173
CHECK_ARG(dev);
174174

175-
if (addr != (MCP9600_ADDR) && addr != (MCP9601_ADDR))
175+
if (addr < (MCP960X_ADDR_BASE) || addr > (MCP960X_ADDR_DEFAULT))
176176
{
177177
ESP_LOGE(TAG, "Invalid I2C address");
178178
return ESP_ERR_INVALID_ARG;

components/mcp960x/mcp960x.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
extern "C" {
4848
#endif
4949

50-
#define MCP9600_ADDR 0x40
51-
#define MCP9601_ADDR 0x41
50+
/**
51+
* Basic I2C address. Device support 8 addresses, ranging from 0x60 to 0x67.
52+
*/
53+
#define MCP960X_ADDR_BASE 0x60
54+
/**
55+
* Default I2C address (ADDR pin is floating).
56+
*/
57+
#define MCP960X_ADDR_DEFAULT 0x67
5258

5359
#define MCP960X_FILTER_OFF 0
5460
#define MCP960X_FILTER_MAX 7

examples/mcp960x/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <string.h>
66

77
#define I2C_PORT 0
8-
#define I2C_ADDR MCP9601_ADDR
8+
#define I2C_ADDR MCP960X_ADDR_DEFAULT
99
#define SENSORS_COUNT 4
1010

1111
/* 5 pins for 4 sensors */

0 commit comments

Comments
 (0)