* �������� * @i2c_info_p i2cģ����Ϣ * @buf ���ݻ��� * @len ���������ݵij��� */
| 257 | * @len ���������ݵij��� |
| 258 | */ |
| 259 | ls1c_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 | /* |
no test coverage detected