--- /dev/null
+/*
+ * Copyright © 2025 Bdale Garbee <bdale@gag.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+/* this I2C implementation written specifically to support the use of an
+ * LPC11U12 on QuantiMotor pretending to be an AD7997 ADC chip. So we're an
+ * I2C slave, with almost all the work done as an interrupt service routine.
+ */
+
+#include <ao.h>
+
+static uint8_t ao_i2c_state;
+static uint16_t ao_i2c_addr;
+
+static void
+ao_i2c_isr()
+{
+ ao_wakeup(&ao_i2c_state);
+}
+
+uint8_t
+ao_i2c_start(uint16_t addr)
+{
+ ao_i2c_state = I2C_IDLE;
+ ao_i2c_addr = addr;
+
+ ao_arch_block_interrupts();
+
+ /* set up I2C interrupt */
+ /* wait for chip to go ready with some max wait? */
+
+ ao_arch_release_interrupts();
+ return ao_i2c_state == I2C_RUNNING;
+}
+