}
avr->log = (log > LOG_TRACE ? LOG_TRACE : log);
avr->trace = trace;
- for (int ti = 0; ti < trace_vectors_count; ti++)
- if (avr->interrupts.vector[trace_vectors[ti]])
- avr->interrupts.vector[trace_vectors[ti]]->trace = 1;
+ for (int ti = 0; ti < trace_vectors_count; ti++) {
+ for (int vi = 0; vi < avr->interrupts.vector_count; vi++)
+ if (avr->interrupts.vector[vi]->vector == trace_vectors[ti])
+ avr->interrupts.vector[vi]->trace = 1;
+ }
// even if not setup at startup, activate gdb if crashing
avr->gdb_port = 1234;
// cpu is in limbo before init is finished.
avr->state = cpu_Limbo;
avr->frequency = 1000000; // can be overridden via avr_mcu_section
+ avr_interrupt_init(avr);
if (avr->special_init)
avr->special_init(avr);
if (avr->init)
avr->pc = 0;
for (int i = 0; i < 8; i++)
avr->sreg[i] = 0;
- if (avr->reset)
- avr->reset(avr);
avr_interrupt_reset(avr);
avr_cycle_timer_reset(avr);
+ if (avr->reset)
+ avr->reset(avr);
avr_io_t * port = avr->io_port;
while (port) {
if (port->reset)
#define INT_FIFO_MOD(_v) ((_v) & (INT_FIFO_SIZE - 1))
void
-avr_interrupt_reset(
+avr_interrupt_init(
avr_t * avr )
{
avr_int_table_p table = &avr->interrupts;
memset(table, 0, sizeof(*table));
}
+void
+avr_interrupt_reset(
+ avr_t * avr )
+{
+ printf("%s\n", __func__);
+ avr_int_table_p table = &avr->interrupts;
+ table->pending_r = table->pending_w = 0;
+ table->pending_wait = 0;
+ for (int i = 0; i < table->vector_count; i++)
+ table->vector[i]->pending = 0;
+}
+
void
avr_register_vector(
avr_t *avr,
struct avr_t * avr,
uint8_t v);
+// Initializes the interrupt table
+void
+avr_interrupt_init(
+ struct avr_t * avr );
+
// reset the interrupt table and the fifo
void
avr_interrupt_reset(