2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 #include <ao_product.h>
20 #include <ao_companion.h>
22 struct ao_companion_command ao_companion_command;
24 static const struct ao_companion_setup ao_telepyro_setup = {
25 .board_id = AO_idProduct_NUMBER,
26 .board_id_inverse = ~AO_idProduct_NUMBER,
28 .channels = AO_TELEPYRO_NUM_ADC,
31 void ao_spi_slave(void)
33 if (!ao_spi_slave_recv((uint8_t *) &ao_companion_command,
34 sizeof (ao_companion_command)))
37 /* Figure out the outbound data */
38 switch (ao_companion_command.command) {
39 case AO_COMPANION_SETUP:
40 ao_spi_slave_send((uint8_t *) &ao_telepyro_setup,
41 sizeof (ao_telepyro_setup));
43 case AO_COMPANION_FETCH:
44 ao_spi_slave_send((uint8_t *) &ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.adc,
45 AO_TELEPYRO_NUM_ADC * sizeof (uint16_t));
47 case AO_COMPANION_NOTIFY: