- spsr = SPSR;
- if (SPIF & (1 << SPIF)) {
- uint8_t byte = SPDR;
- if (!ao_fifo_full(ao_spi_slave_rx_fifo))
- ao_fifo_insert(ao_spi_slave_rx_fifo, byte);
- ao_spi_slave_tx_started = 0;
- ao_spi_slave_tx_start();
- ao_wakeup(&ao_spi_slave_rx_fifo);
- ao_wakeup(&ao_spi_slave_tx_fifo);
+ /* Figure out the outbound data */
+ switch (ao_companion_command.command) {
+ case AO_COMPANION_SETUP:
+ buf = (uint8_t *) &ao_companion_setup;
+ len = sizeof (ao_companion_setup);
+ break;
+ case AO_COMPANION_FETCH:
+ buf = (uint8_t *) &ao_adc_ring[ao_adc_ring_prev(ao_adc_head)].adc;
+ len = NUM_ADC * sizeof (uint16_t);
+ break;
+ default:
+ return;