Manual

52 Functions
Function Description
io_set_clock( ) Set timer/counter clock rate
io_set_direction( ) Change direction of I/O pins
sci_abort( ) Abort pending sci transfer
sci_get_error( ) Read most recent sci error code
spi_abort( ) Abort pending spi transfer
spi_get_error( ) Read most recent spi error code
Signed 32-Bit Integer Support Functions
The Neuron C compiler does not directly support the use of the C arithmetic and
comparison operators with 32-bit integers. However, there is a complete library
of functions for signed 32-bit integer math. These functions are listed in
Integer
Math
on page 43. For example, in standard ANSI C, to evaluate X = A + B * C in
long (32-bit) arithmetic, the '+' and '*' infix operators can be used as follows:
long X, A, B, C;
X = A + B * C;
With Neuron C, this can be expressed as follows:
s32_type X, A, B, C;
s32_mul(&B, &C, &X);
s32_add(&X, &A, &X);
The signed 32-bit integer format can represent numbers in the range of
±2,147,483,647 with an absolute resolution of ±1.
An s32_type structure data type for signed 32-bit integers is defined by means of
a typedef in the <s32.h> file. It defines a structure containing an array of four
bytes that represents a signed 32-bit integer in Neuron C format. This is
represented as a two’s complement number stored with the most significant byte
first. The type declaration is shown here for reference:
typedef struct {
int bytes[4];
} s32_type;
All of the constants and functions in the <s32.h> file are defined using the
Neuron C signed 32-bit data type, which is a structure. Neuron C does not
permit structures to be passed as parameters or returned as values from
functions. When these objects are passed as parameters to C functions, they are
passed as addresses (using the '&' operator) rather than as values. However,
Neuron C does support structure assignment, so signed 32-bit integers can be
assigned to each other with the '=' assignment operator.
No errors are detected by the 32-bit functions. Overflows follow the rules of the C
programming language for integers, namely, they are ignored. Only the least
significant 32 bits of the results are returned.
Initializers can be defined using structure initialization syntax. For example: