static void handler (void) { // Disable interrupt temp extint_disable (extint1); irq_clear (AT91C_ID_IRQ1); uint8_t addr; uint8_t buffer[2]; i2c_ret_t ret; DELAY_US (4); //pio_output_toggle (LED1_PIO); ret = i2c_slave_read (i2c_slave1, buffer, sizeof (buffer), 10000); addr = buffer[0] - ARRAY_OFFSET; if (addr >= sizeof (comms_data)) addr = 0; if (ret == 1) { // Have not received photo line command. if (buffer[0] != CD_PHOTO_LINE) ret = i2c_slave_write (i2c_slave1, comms_data[addr], 130, 1000); // Return data requested. else { // check if photo ready. if (comms_data[CD_PHOTO_READY-ARRAY_OFFSET]) { ret = i2c_slave_write (i2c_slave1, comms_data[CD_PHOTO_NEXT_LINE-ARRAY_OFFSET], 130, 1000); if (ret > 0) { ret++; *comms_data[CD_FAULT - ARRAY_OFFSET] = ret; comms_data[CD_PHOTO_NEXT_LINE-ARRAY_OFFSET] += ret; if ((comms_data[CD_PHOTO_NEXT_LINE-ARRAY_OFFSET] - image) == image_size) { // We have sent the entire picture comms_data[CD_PHOTO_NEXT_LINE-ARRAY_OFFSET] = image; comms_data[CD_PHOTO_READY-ARRAY_OFFSET] = 0; } } } } } if (ret == 2) { if (buffer[0] == COMMS_COMMAND) next_command = buffer[1]; } extint_enable (extint1); }
DDE_WEAK void free_irq(unsigned int irq, void * dev_id) { irq_clear(irq); //dde_printf("free_irq not implemented\n"); }