Neuron c variables, Neuron c variable types, Neuron c storage classes – Echelon IzoT NodeBuilder User Manual

Page 190

Advertising
background image

Neuron C Variables

The following sections briefly discuss various aspects of Neuron C-specific variable declarations.
Data types affect what sort of data a variable represents. Storage classes affect where the variable
is stored, whether it can be modified (and if so, how often), and whether there are any device
interface aspects to modifying the data.

Neuron C Variable Types

Neuron C supports the following C variable types. The keywords shown in square brackets below
are optional. If omitted, they will be assumed by the Neuron C language, per the rules of the
ANSI C standard:

[signed] long [int]

16-bit quantity

unsigned long [int]

16-bit quantity

signed char

8-bit quantity

[unsigned] char 8-bit quantity
[signed] [short][int]

8-bit quantity

unsigned [short][int]

8-bit quantity

enum

8-bit quantity (int type)

Neuron C provides some predefined enum types. One example is shown below:

typedef enum {FALSE, TRUE} boolean;

You should use the unsigned int type whenever possible because it is the type best supported by
the Neuron Chip and Smart Transceiver’s hardware architecture. The unsigned int type is
preferred over signed int type.

Neuron C also provides predefined objects that, in many ways, provide the look and feel of an
ANSI C language variable. These objects include Neuron C timer and I/O objects. See Chapter 2
of the Neuron C Programmer’s Guide for more details on I/O objects, and see Chapter 4 in the
Neuron C Reference Guide for more details on timer objects.

The extended arithmetic library also defines float_type and s32_type for IEEE 754 and signed
32-bit integer data respectively. These types are detailed further in Chapter 3 of the Neuron C
Reference Guide
.

Neuron C Storage Classes

If no class is specified for a declaration at file scope, the data or function is global. File scope is
that part of a Neuron C program that is not contained within a function, a when-task, or an
interrupt-task. Global data (including all data declared with the static keyword) is present
throughout the entire execution of the program, starting from the point where the symbol was
declared. Declarations using extern references can be used to provide forward references to
variables, and function prototypes must be declared to provide forward references to functions. In
addition, extern references can be used to publish a symbol and allow for linking with other object
files.

Upon power-up or reset of a Neuron Chip or Smart Transceiver, the global data in RAM is
initialized to its initial-value expression, if present; otherwise, it is set to 0.

Neuron C supports the following ANSI C storage classes and type qualifiers:

auto declares a variable of local scope. Typically, this would be within a function body. This is

the default storage class within a local scope and the keyword is normally not specified. Variables
of auto scope that are not also static are not initialized upon entry to the local scope, unless you
provide an explicit initializer. The value of the variable is not preserved once program execution
leaves the scope.

176

Developing Device Applications

Advertising