MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / i2c_receive_data

Function i2c_receive_data

bsp/loongson/ls1cdev/libraries/ls1c_i2c.c:259–281  ·  view source on GitHub ↗

* �������� * @i2c_info_p i2cģ����Ϣ * @buf ���ݻ��� * @len ���������ݵij��� */

Source from the content-addressed store, hash-verified

257 * @len ���������ݵij���
258 */
259ls1c_i2c_ret_t i2c_receive_data(ls1c_i2c_info_t *i2c_info_p, unsigned char *buf, int len)
260{
261 void *i2c_base = i2c_get_base(i2c_info_p->I2Cx);
262 int i = 0;
263
264 for (i=0; i<len; i++)
265 {
266 // ��ʼ����
267 if (i != (len - 1))
268 i2c_cmd_read_ack(i2c_info_p);
269 else
270 i2c_cmd_read_nack(i2c_info_p);
271
272 // �ȴ���ֱ���������
273 if (!i2c_poll_status(i2c_info_p, LS1C_I2C_STATUS_TIP))
274 return LS1C_I2C_RET_TIMEOUT;
275
276 // ��ȡ���ݣ�������
277 *buf++ = reg_read_8(i2c_base + LS1C_I2C_DATA_OFFSET);
278 }
279
280 return LS1C_I2C_RET_OK;
281}
282
283
284/*

Callers 1

rt_i2c_master_xferFunction · 0.85

Calls 5

i2c_get_baseFunction · 0.85
i2c_cmd_read_ackFunction · 0.85
i2c_cmd_read_nackFunction · 0.85
i2c_poll_statusFunction · 0.85
reg_read_8Function · 0.70

Tested by

no test coverage detected