From: Michel Pollet Date: Tue, 7 Mar 2017 18:34:27 +0000 (+0000) Subject: irq: Added a flag for a 'floating' value X-Git-Tag: v1.6~48^2~6 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=c9b857b44126b803e4e5e81dd919aa7b3aa800a0;p=sx%2Fsimavr.git irq: Added a flag for a 'floating' value When this flag is set, the value is to be ignored. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/sim_irq.c b/simavr/sim/sim_irq.c index d0148a0..6d175cf 100644 --- a/simavr/sim/sim_irq.c +++ b/simavr/sim/sim_irq.c @@ -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; +} diff --git a/simavr/sim/sim_irq.h b/simavr/sim/sim_irq.h index bf02a35..756323b 100644 --- a/simavr/sim/sim_irq.h +++ b/simavr/sim/sim_irq.h @@ -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(