Syntax, Example, Update_address( ) function – Echelon Neuron C User Manual

Page 170

Advertising
background image

150

Functions

that are all similar, a bit array can be more code-efficient than a series of

bitfields because the array can be accessed using an array index rather than
separate lines of code for each bitfield. See also clr_bit( ) and set_bit( ).

Syntax

#include <byte.h>

boolean tst_bit (void *

array

, unsigned

bitnum

);

Example

#include <byte.h>

unsigned short a[4];

void f(void)
{

memset(a, 0, 4);

// Clear all bits at once

set_bit(a, 4); // Set a[0] to 0x08 (5th bit)


if (tst_bit(a, 4)) {

// Code executes here if bit was set

}
}

update_address( )

Function

The update_address( ) function copies from the structure referenced by the

address

pointer parameter to the address table entry specified by the

index

parameter.
Important: This function has a mechanism that ensures that a reset or power
cycle during an EEPROM modification does not cause the device to go

unconfigured. This mechanism uses the error log to serve as a semaphore. Thus,

the error log is written to on every call to this function, even if the net effect of
the function is to not modify or write to the configuration data at all (because the

new contents match the old). Applications must minimize calls to this function to

ensure that the maximum number of supported writes for EEPROM is not
exceeded over the lifetime of the application.
See the ISO/IEC 14908 (ANSI/EIA/CEA-709.1)

Control Network Specification

for

a description of the data structure.

Syntax

#include <access.h>

void update_address (const address_struct *

address

, int

index

);

Example

#include <access.h>
address_struct address_copy;
msg_tag my_mt;

Advertising