Llosa de Viango Tollos – lpcI2CIO.c



Getting started



  Tollos libraries

  Device libraries





  Sample application


lpcI2CIO.c – I2C device functions for LPC

Low level functions to effect I2C bus I/O.

The channels are by default assigned speeds in order to allow the use of both slow and faster devices:

  • channel0: 400 kbit/s
  • channel1: 100 kbit/s
  • channel2: 400 kbit/s

These speeds can be changed using i2cInitIO before i2cIO is first called for a channel.
 i2cInitIO   initialize an I2C channel (hardware interface)
 i2cIO   I2C general I/O function

i2cInitIO – initialize an I2C channel (hardware interface)

int i2cInitIO(uint channel, uint hz);

channel – channel number to initialize

hz – speed to run the channel

returns 0 if OK, negative if error

This function is called automatically, with a default speed setting, when i2cIO is called and the channel has not been initialized. Therefore it need only be invoked explicitly for a non-default speed.

i2cIO – I2C general I/O function

int i2cIO(uint device, byte *put, uint putlen, byte *get, uint getlen);

device – channel and physical address of device (channel shifted left 16 bits and ORed with 7-bit or 10-bit I2C physical address); currently only 7-bit addresses are supported

put – start of byte(s) to write

putlen – count of byte(s) to write [may be 0]

get – start of byte(s) to read

getlen – count of byte(s) to read [may be 0]

returns 0 if OK, negative if error

put is ignored if putlen is 0 (NULL recommended). get is ignored if getlen is 0 (NULL recommended).

This function will automatically initialize the appropriate I2C channel when first called for a channel, unless already initialized by an explicit call to i2cInitIO.

Tollos and these web pages were written by Mike Cowlishaw; Please send me any corrections, suggestions, etc.
All content © Mike Cowlishaw, 2010–2012, except where marked otherwise. All rights reserved. The pages here are for non-commercial use only (see the separate licence for Tollos source code). Privacy policy: the Speleotrove website records no personal information and sets no ‘cookies’. However, statistics, etc. might be recorded by the web hosting service.

This page was last updated on 2011-01-16 by c2wiki.