This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

bq40z50 下读取Chemical ID写了个测试函,数,用的是block操作,但是操作时返回值都是-ENXIO

Other Parts Discussed in Thread: BQ40Z50

我照着bq40z50手册,下面内容,写了个测试函数,用的是block操作,但是操作时返回值都是-ENXIO,(No such device or address)

Example: Read Chemical ID() (0x0006) via ManufacturerBlockAccess()

1. Send Chemical ID() to ManufacturerBlockAccess().

(a) SMBus block write. Command = 0x44. Data sent = 06 00 (data must be sent in Little Endian)

2. Read the result from ManufacturerBlockAccess().

(a) SMBus block read. Command = 0x44. Data read = 06 00 00 01 (each data entity is returned in

Little Endian).

(b) The first 2 bytes, “06 00”, is the MAC command.

(c) The second 2 bytes, “00 01”, is the chem ID returning in Little Endian. That is 0x0100, chem ID

100

 

设备树配置:

&i2c1 {

        status = "ok"; 

        bq40z50: bq40z50@16{

                 compatible = "bq40z50";

                 reg = <0x16>;

        };

 

测试代码:

#define BQ40Z50_BLKWR_CMD             0x44

#define BQ40Z50_BLKRD_CMD              0x44

u8 value_id[2]={0x06,0x0};

u8 value_rd[4]={0x00,0x00,0x00,0x00};

 

i2c_smbus_write_block_data(drvdata->client, BQ40Z50_BLKWR_CMD, 2, value_id);

msleep( 1 );    

i2c_smbus_read_block_data(drvdata->client, BQ40Z50_BLKRD_CMD, value_rd);      

msleep( 1 );