Echelon Neuron C User Manual

Page 172

Advertising
background image

160 Additional

Features

You can call the interrupt_control() function at any time to enable or disable one

or more of the three interrupt types.

The function prototype and predefined symbols are defined within the

<echelon.h> header file. The Neuron C compiler automatically includes this file

for every application; you do not need to include it explicitly.

Examples:

// enable I/O interrupts only
interrupt_control(INTERRUPT_IO);

// enable both I/O and timer/counter interrupts
interrupt_control(INTERRUPT_IO | INTERRUPT_TC);

// disable all interrupts
interrupt_control(0);

Recommendation: Disable all interrupts when the device goes to the offline state.

Interrupt processing can sometimes interfere with device management tasks

performed while a device is offline.

Example:

#include "status.h"

when(reset) {
// query node status:
status_struct status;
retrieve_status(&status);

// proceed with device initialization:
...

// enable interrupt system if configured and online:
if (status.status_node_state == 0x04) {
interrupt_control(INTERRUPT_IO | INTERRUPT_REPEATING);
}
}

when(offline) {
interrupt_control(0);
}

when(online) {
interrupt_control(INTERRUPT_IO | INTERRUPT_REPEATING);
}

If you call the interrupt_control() function for an interrupt type that does not
have a corresponding interrupt task defined, the call does nothing. However, if

you call the interrupt_control() function and there are no interrupt tasks defined,
the Neuron linker issues an error message.
If you need to disable or enable all interrupts at the same time, you can also use

the io_idis() function to disable interrupts and the io_iena() function to enable
interrupts. These functions have the following declaration:

void io_idis(void);
void io_iena(void);

Advertising