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

Function i2c_send_data

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

* �������� * @i2c_info_p i2cģ����Ϣ * @data �����͵����� * @len ���������ݵij��� */

Source from the content-addressed store, hash-verified

320 * @len ���������ݵij���
321 */
322ls1c_i2c_ret_t i2c_send_data(ls1c_i2c_info_t *i2c_info_p, unsigned char *data, int len)
323{
324 void *i2c_base = i2c_get_base(i2c_info_p->I2Cx);
325 int i = 0;
326
327 for (i=0; i<len; i++)
328 {
329 // ��һ���ֽ�����д�����ݼĴ���
330 reg_write_8(*data++, i2c_base + LS1C_I2C_DATA_OFFSET);
331
332 // ��ʼ����
333 reg_write_8(LS1C_I2C_CMD_WRITE, i2c_base + LS1C_I2C_CMD_OFFSET);
334
335 // �ȴ���ֱ���������
336 if (!i2c_poll_status(i2c_info_p, LS1C_I2C_STATUS_TIP))
337 return LS1C_I2C_RET_TIMEOUT;
338
339 // ��ȡӦ���ź�
340 if (LS1C_I2C_ACK != i2c_receive_ack(i2c_info_p))
341 return len;
342 }
343
344 return LS1C_I2C_RET_OK;
345}
346
347
348

Callers 1

rt_i2c_master_xferFunction · 0.85

Calls 4

i2c_get_baseFunction · 0.85
i2c_poll_statusFunction · 0.85
i2c_receive_ackFunction · 0.85
reg_write_8Function · 0.70

Tested by

no test coverage detected