Commit c9b857b44126b803e4e5e81dd919aa7b3aa800a0
authorMichel Pollet <buserror@gmail.com>
Tue, 7 Mar 2017 18:34:27 +0000 (18:34 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 7 Mar 2017 18:34:27 +0000 (18:34 +0000)
When this flag is set, the value is to be ignored.

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
simavr/sim/sim_irq.c
simavr/sim/sim_irq.h

index d0148a02a85f30e4fdd06ed46e0997c5645fd9b2..6d175cfb0f94c721360419f279b96f4e37f3fcbd 100644 (file)
@@ -189,9 +189,10 @@ avr_irq_unregister_notify(
 }
 
 void
-avr_raise_irq(
+avr_raise_irq_float(
                avr_irq_t * irq,
-               uint32_t value)
+               uint32_t value,
+               int floating)
 {
        if (!irq)
                return ;
@@ -200,7 +201,9 @@ avr_raise_irq(
        if (irq->value == output &&
                        (irq->flags & IRQ_FLAG_FILTERED) && !(irq->flags & IRQ_FLAG_INIT))
                return;
-       irq->flags &= ~IRQ_FLAG_INIT;
+       irq->flags &= ~(IRQ_FLAG_INIT | IRQ_FLAG_FLOATING);
+       if (floating)
+               irq->flags |= IRQ_FLAG_FLOATING;
        avr_irq_hook_t *hook = irq->hook;
        while (hook) {
                avr_irq_hook_t * next = hook->next;
@@ -210,7 +213,7 @@ avr_raise_irq(
                        if (hook->notify)
                                hook->notify(irq, output,  hook->param);
                        if (hook->chain)
-                               avr_raise_irq(hook->chain, output);
+                               avr_raise_irq_float(hook->chain, output, floating);
                        hook->busy--;
                }
                hook = next;
@@ -221,6 +224,14 @@ avr_raise_irq(
        irq->value = output;
 }
 
+void
+avr_raise_irq(
+               avr_irq_t * irq,
+               uint32_t value)
+{
+       avr_raise_irq_float(irq, value, !!(irq->flags & IRQ_FLAG_FLOATING));
+}
+
 void
 avr_connect_irq(
                avr_irq_t * src,
@@ -266,3 +277,18 @@ avr_unconnect_irq(
                hook = hook->next;
        }
 }
+
+uint8_t
+avr_irq_get_flags(
+               avr_irq_t * irq )
+{
+       return irq->flags;
+}
+
+void
+avr_irq_set_flags(
+               avr_irq_t * irq,
+               uint8_t flags )
+{
+       irq->flags = flags;
+}
index bf02a352e5e34dd4f237907cf288445880dfe0c2..756323b19e7463ba79e37108a5320756576bcdd7 100644 (file)
@@ -56,6 +56,7 @@ enum {
        IRQ_FLAG_FILTERED       = (1 << 1),     //!< do not "notify" if "value" is the same as previous raise
        IRQ_FLAG_ALLOC          = (1 << 2), //!< this irq structure was malloced via avr_alloc_irq
        IRQ_FLAG_INIT           = (1 << 3), //!< this irq hasn't been used yet
+       IRQ_FLAG_FLOATING       = (1 << 4), //!< this 'pin'/signal is floating
 };
 
 /*
@@ -98,11 +99,26 @@ avr_init_irq(
                uint32_t base,
                uint32_t count,
                const char ** names /* optional */);
+//! Returns the current IRQ flags
+uint8_t
+avr_irq_get_flags(
+               avr_irq_t * irq );
+//! Sets this irq's flags
+void
+avr_irq_set_flags(
+               avr_irq_t * irq,
+               uint8_t flags );
 //! 'raise' an IRQ. Ie call their 'hooks', and raise any chained IRQs, and set the new 'value'
 void
 avr_raise_irq(
                avr_irq_t * irq,
                uint32_t value);
+//! Same as avr_raise_irq(), but also allow setting the float status
+void
+avr_raise_irq_float(
+               avr_irq_t * irq,
+               uint32_t value,
+               int floating);
 //! this connects a "source" IRQ to a "destination" IRQ
 void
 avr_connect_irq(