/* Probe for a maXTouch connected to a specific TWI line.  */
status_code_t mxt_probe_device(twihs_master_t interface, uint8_t chip_adr)
/* Probe for a maXTouch connected to a specific TWI line.  */
status_code_t mxt_probe_device(twihs_master_t interface, uint8_t chip_adr)
{
	struct mxt_info_object info;
	uint8_t status;
	twihs_package_t packet = {
		.addr[0]      = MXT_MEM_ADDR,
		.addr[1]      = MXT_MEM_ADDR >> 8,
		.addr_length  = sizeof(mxt_memory_adr),
		.chip         = chip_adr,
		.buffer       = &info,
		.length       = sizeof(info)
	};
	status = twihs_master_read(interface, &packet);
	if (status != TWIHS_SUCCESS) {
		return (status_code_t)status;
	}
	if ((info.family_ID != MXT_FAMILY_143E)
			|| (info.variant_ID != MXT_VARIANT_143E)) {
		return ERR_BAD_ADDRESS;
	}
	return STATUS_OK;
}