beautypg.com

Syntax, Usage – Echelon I/O Model Reference for Smart Transceivers and Neuron Chips User Manual

Page 93

background image

I/O Model Reference

83

For I

2

C input/output, io_in( ) and io_out( ) return a 0 or 1 value reflecting the fail

(0) or pass (1) status of the transfer. A failed status indicates that the addressed
device did not acknowledge positively on the bus, or that the SCL was low at the

start of the transfer.
For more information on this protocol and the devices that it supports, see
documentation for Philips Semiconductors Microcontroller Products, under I

2

C

bus descriptions. This I/O model implementation was modified for Neuron C
Version 2.1. To use the previous implementation (in case of modification to

existing applications where the previous implementation is required for memory

considerations) use the #pragma codegen use_i2c_version_1 compiler directive.
See the

Neuron C Reference Guide

for information about this pragma. If you use

the Version 1 i2c model, you must use pin IO_8 and you cannot use any

modifiers.

Syntax

pin

i2c [use_stop_condition] [__slow] [__fast]

io-object-name

;

pin

Specify pin IO_0 or IO_8. The i2c model requires pins IO_0 and IO_1, or

IO_8 and IO_9.

use_stop_condition

Optionally specifies that data transfers should be repeated until a stop

condition is reached. A stop condition is defined as a change in the state of

the data line (SDA), from LOW to HIGH, while the clock line (SCL) is HIGH.

__slow

Optionally specifies that the I

2

C bus should use the standard mode of 100

kbps. This mode is the default if no mode is specified. Mutually exclusive

with __fast.

__fast

Optionally specifies that the I

2

C bus should use the fast mode of 400 kbps.

Mutually exclusive with __slow.

io-object-name

A user-specified name for the I/O object, in the ANSI C format for variable

identifiers.

Usage

boolean

return-value

;

unsigned int

data-buffer

[

buffer-size

];

unsigned int

dev-address

,

count

;

// i2c I/O object without the stop condition specified (stop assumed)

return

-

value

= io_in(

io

-

object

-

name

,

data

-

buffer

,

dev

-

address

,

count

);

return

-

value

= io_out(

io

-

object

-

name

,

data

-

buffer

,

dev

-

address

,

count

);