Echelon I/O Model Reference for Smart Transceivers and Neuron Chips User Manual

Page 58

Advertising
background image

48

Direct I/O Models

limited to 275 μs, after which the touch_reset( ) function returns a -1
value with the assumption that the 1-Wire bus is stuck low. There also is
a minimum value for this period: for a Series 3100 device, it must be >4.8

μs @10 MHz, or >9.6 μs @5 MHz; for a Series 5000 device, it must be >0.3
μs @ 80 MHz, or >4.8 μs @5 MHz.

After the 1-Wire bus has appeared to go high, the Neuron firmware waits for the

presence pulse for a period up to 80 μs. If a low input level is not sensed within
this period, the function returns a 0 value. When a presence pulse is detected,

the Neuron firmware then waits for the end of the presence pulse by waiting for a

high level on the bus. This period is limited to 250 μs, after which the function
again returns a -1 if the period elapses with the input level still low. Otherwise,

after the input level is high again, the function returns with a 1 value. The
touch_reset( ) function does not return until the end of the presence pulse has

been detected.

unsigned touch_byte(

io-object-name

, unsigned

write-data

);

The touch_byte( ) function sequentially writes and reads eight bits of data on the

1-Wire bus. It can be used for either reading or writing. For reading, the

write-

data

argument should be all ones (0xFF), and the return value contains the eight

bits as read from the bus. For writing, the bits in the

write-data

argument are

placed on the 1-Wire bus, and the return value normally contains those same

bits.

This function allows combined read and write operations within a single 8-bit

boundary. For example, a 2-bit write can be followed by a 6-bit read. This read

can be accomplished with a single call to the touch_byte( ) function with a

write-

data

argument of 0b

NN

111111 where

NN

represents the two bits of write data

and (111111) is used to perform the 6-bit read.

unsigned touch_bit(

io-object-name

, unsigned

write-data

);

The touch_bit( ) function writes and reads a single bit of data on the 1-Wire bus.

It can be used for either reading or writing. For reading, the

write-data

argument should be one (0x01), and the return value contains the bit as read

from the bus. For writing, the bit value in the

write-data

argument is placed on

the 1-Wire bus, and the return value normally contains that same bit value, and
can be ignored.

int touch_first(

io-object-name

, search_data *

sd

);

int touch_next(

io-object-name

, search_data *

sd

);

These functions execute the Search ROM command, as described in the

Book of

iButton Standards

. Both functions use a search_data_s data structure for

intermediate storage of a bit marker and the current ROM data:

typedef struct search_data_s {
int search_done;
int last_discrepancy;
unsigned rom_data[8];
} search_data;

This data structure is automatically defined in Neuron C, regardless of whether a

program references the touch I/O functions.

A return value of TRUE indicates whether a device was found, and if so, that the

data stored at rom_data[ ] is valid. A FALSE return value indicates no device

found. The search_done flag is set to TRUE when there are no more devices on

Advertising