OR1K support
 All Functions Typedefs Groups
Typedefs | Functions
OR1K interrupt control

Typedefs

typedef void(* or1k_interrupt_handler_fptr )(void *data)
 

Functions

void or1k_interrupt_handler_add (uint32_t line, or1k_interrupt_handler_fptr handler, void *data)
 
void or1k_interrupt_enable (int line)
 
void or1k_interrupt_disable (int line)
 
uint32_t or1k_interrupts_disable (void)
 
void or1k_interrupts_enable (void)
 
void or1k_interrupts_restore (uint32_t status)
 
uint32_t or1k_critical_start ()
 
void or1k_critical_end (uint32_t restore)
 

Detailed Description

Interrupt control function prototypes

Typedef Documentation

typedef void(* or1k_interrupt_handler_fptr)(void *data)

Function pointer to interrupt handler functions

Function Documentation

void or1k_critical_end ( uint32_t  restore)

Enable timer and interrupt exception

Restore the timer and interrupt exception enable. The restore value is the return value from or1k_critical_start().

Parameters
restoreInterrupt and timer exception enable restore value
uint32_t or1k_critical_start ( )

Disable timer and interrupt exception

This function disables the timer and interrupt exception to guard critical sections. It returns the status of the enable bits before the critical section, that is restored with or1k_critical_end().

Example:

...
uint32_t status = or1k_critical_start();
// critical part
...
Returns
Status of timer and interrupt exception at time of call
void or1k_interrupt_disable ( int  line)

Disable interrupts from a given line

Mask given interrupt line. It can be unmasked using or1k_interrupt_enable().

Parameters
lineInterrupt line to disable
void or1k_interrupt_enable ( int  line)

Enable interrupts from a given line

Unmask the given interrupt line. It is also important to enable interrupts in general, e.g., using or1k_interrupts_enable().

Parameters
lineInterrupt line to enable
void or1k_interrupt_handler_add ( uint32_t  line,
or1k_interrupt_handler_fptr  handler,
void *  data 
)

Add interrupt handler for interrupt line

Registers a callback function for a certain interrupt line.

Parameters
lineInterrupt line/id to register a handler for
handlerHandler to register
dataData value passed to the handler
uint32_t or1k_interrupts_disable ( void  )

Disable interrupts

This disables the interrupt exception. This is sufficient to disable all interrupts. It does not change the mask register (which is modified using or1k_interrupt_enable() and or1k_interrupt_disable()).

The interrupt exception can be enabled using or1k_interrupts_enable().

Finally, the status of the interrupt exception enable flag is returned by this function. That allows to call this function even if interrupts are already disabled. To restore the value of the interrupt exception enable flag, use the or1k_interrupts_restore() function. That way you avoid to accidentally enable interrupts. Example:

void f() {
uint32_t interrupt_status = or1k_interrupts_disable();
// do something
}

This code will preserve the original status of the interrupt enable flag.

Returns
Interrupt exception enable flag before call
void or1k_interrupts_enable ( void  )

Enable interrupt exception

Enable the interrupt exception. Beside the interrupt exception, it is also necessary to enable the individual interrupt lines using or1k_interrupt_enable().

You should avoid using this function together with or1k_interrupts_disable() to guard atomic blocks as it unconditionally enables the interrupt exception (see documentation of or1k_interrupts_disable()).

void or1k_interrupts_restore ( uint32_t  status)

Restore interrupt exception enable flag

This function restores the given status to the processor. or1k_interrupts_restore(0) is identical to or1k_interrupts_disable() and or1k_interrupts_restore(SPR_SR_IEE) is identical to or1k_interrupts_enable().

It is for example used to guard an atomic block and restore the original status of the interrupt exception enable flag as returned by or1k_interrupts_disable(). See the documentation of or1k_interrupts_disable() for a usage example.

Parameters
statusStatus of the flag to restore