SimAVR
AVR Simulator
Internal IRQ System (simulator callback)

Data Structures

struct  avr_irq_pool_t
 IRQ Pool structure. More...
 
struct  avr_irq_t
 Public IRQ structure. More...
 

Typedefs

typedef void(* avr_irq_notify_t) (struct avr_irq_t *irq, uint32_t value, void *param)
 Callback Prototype. More...
 
typedef struct avr_irq_pool_t avr_irq_pool_t
 IRQ Pool structure. More...
 
typedef struct avr_irq_t avr_irq_t
 Public IRQ structure. More...
 

Enumerations

enum  { IRQ_FLAG_NOT = (1 << 0), IRQ_FLAG_FILTERED = (1 << 1), IRQ_FLAG_ALLOC = (1 << 2), IRQ_FLAG_INIT = (1 << 3) }
 

Functions

avr_irq_tavr_alloc_irq (avr_irq_pool_t *pool, uint32_t base, uint32_t count, const char **names)
 Allocates 'count' IRQs, initializes their "irq" starting from 'base' and increment. More...
 
void avr_free_irq (avr_irq_t *irq, uint32_t count)
 Free allocated IRQs. More...
 
void avr_init_irq (avr_irq_pool_t *pool, avr_irq_t *irq, uint32_t base, uint32_t count, const char **names)
 Init 'count' IRQs, initializes their "irq" starting from 'base' and increment. More...
 
void avr_raise_irq (avr_irq_t *irq, uint32_t value)
 Raise an IRQ. I.e. call their 'hooks', and raise any chained IRQs, and set the new 'value'. More...
 
void avr_connect_irq (avr_irq_t *src, avr_irq_t *dst)
 Connect a source IRQ to a destination IRQ. More...
 
void avr_unconnect_irq (avr_irq_t *src, avr_irq_t *dst)
 Disconnect a source IRQ to a destination IRQ. More...
 
void avr_irq_register_notify (avr_irq_t *irq, avr_irq_notify_t notify, void *param)
 Register a notification hook (callback) for an irq. More...
 
void avr_irq_unregister_notify (avr_irq_t *irq, avr_irq_notify_t notify, void *param)
 Unregister a callback for an irq. More...
 

Detailed Description

Note
IRQ stands usually for Interrupt Request, but here it has nothing to do with AVR interrupts. It is in fact a messaging system bewteen the simulator and the user code, similar to the Qt signal-slot architecture. "Raise" means "emit" in Qt language.

This subsystem allows any piece of code to "register" a hook to be called when an IRQ is raised. The IRQ definition is up to the module defining it, for example a IOPORT pin change might be an IRQ in which case any piece of code can be notified when a pin has changed state

The notify hooks are chained, and duplicates are filtered out so you can't register a notify hook twice on one particular IRQ

IRQ calling order is not defined, so don't rely on it.

IRQ hook needs to be registered in reset() handlers, i.e. after all modules init() bits have been called, to prevent race condition of the initialization order.

Typedef Documentation

typedef void(* avr_irq_notify_t) (struct avr_irq_t *irq, uint32_t value, void *param)

Callback Prototype.

Parameters
irqis the caller
valueis the raised value
paramis the user data provided at the IRQ registration

IRQ Pool structure.

typedef struct avr_irq_t avr_irq_t

Public IRQ structure.

Enumeration Type Documentation

anonymous enum
Enumerator
IRQ_FLAG_NOT 

change polarity of the IRQ

IRQ_FLAG_FILTERED 

do not "notify" if "value" is the same as previous raise

IRQ_FLAG_ALLOC 

this irq structure was malloced via avr_alloc_irq

IRQ_FLAG_INIT 

this irq hasn't been used yet

Function Documentation

avr_irq_t* avr_alloc_irq ( avr_irq_pool_t pool,
uint32_t  base,
uint32_t  count,
const char **  names 
)

Allocates 'count' IRQs, initializes their "irq" starting from 'base' and increment.

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_connect_irq ( avr_irq_t src,
avr_irq_t dst 
)

Connect a source IRQ to a destination IRQ.

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_free_irq ( avr_irq_t irq,
uint32_t  count 
)

Free allocated IRQs.

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_init_irq ( avr_irq_pool_t pool,
avr_irq_t irq,
uint32_t  base,
uint32_t  count,
const char **  names 
)

Init 'count' IRQs, initializes their "irq" starting from 'base' and increment.

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_irq_register_notify ( avr_irq_t irq,
avr_irq_notify_t  notify,
void *  param 
)

Register a notification hook (callback) for an irq.

Parameters
paramis anything that your want passed back as argument

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_irq_unregister_notify ( avr_irq_t irq,
avr_irq_notify_t  notify,
void *  param 
)

Unregister a callback for an irq.

Here is the caller graph for this function:

void avr_raise_irq ( avr_irq_t irq,
uint32_t  value 
)

Raise an IRQ. I.e. call their 'hooks', and raise any chained IRQs, and set the new 'value'.

Here is the caller graph for this function:

void avr_unconnect_irq ( avr_irq_t src,
avr_irq_t dst 
)

Disconnect a source IRQ to a destination IRQ.