/* Check communication is ready and able to read Chip ID.  */
enum status_code qt_get_comm_ready(void)
/* Check communication is ready and able to read Chip ID.  */
enum status_code qt_get_comm_ready(void)
{
	enum status_code ret;
	uint8_t chip_id = 0;
	volatile uint32_t timeout = QT_COMM_TIMEOUT;
	do {
		ret = qt_read_regs(QT_REG_CHIP_ID, &chip_id, sizeof(uint8_t));
		timeout--;
		if (timeout == 0) {
			return ERR_IO_ERROR;
		}
	} while (ret != STATUS_OK);
	if (chip_id != QT_DEVICE_ID) {
		return ERR_UNSUPPORTED_DEV;
	} else {
		return STATUS_OK;
	}
}