Zigbee Module Examples

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hal_stellaris_softi2c.h File Reference

Implements an I2C interface using software. More...

`#include <stdint.h>`

## Functions
uint8_t | i2cAddressTest (uint8_t addressToTest)
void | i2cAddressSearch (void)
uint8_t | i2cWrite (uint8_t *bytes, uint8_t numBytes)
int8_t | i2cInit (uint8_t i2cAddress)
uint8_t | i2cRead (uint8_t *bytes, uint8_t numBytes)
uint8_t | i2cReadOneByte (uint8_t *value)
void | displayI2cError (unsigned long i2cErr)
uint8_t | i2cBlockRead (uint8_t numOutputBytes, uint8_t *outputBytes, uint8_t numBytes, uint8_t *bytes)
void | i2cTest ()

## Detailed Description

Implements an I2C interface using software.

Uses the Hardware Abstraction Layer (hal).

Rev:
  1642

Author:
  dsmith

Date:
  2012-10-31 11:17:04 -0700 (Wed, 31 Oct 2012)

# Support

Please refer to the wiki at www.anaren.com/air-wiki-zigbee for more information. Additional support is available via email at the following addresses:

- Questions on how to use the product: AIR@a.nosp@m.nare.nosp@m.n.com
- Feature requests, comments, and improvements: featu.nosp@m.rere.nosp@m.quest.nosp@m.s@te.nosp@m.slaco.nosp@m.ntro.nosp@m.ls.co.nosp@m.m
- Consulting engagements: sales.nosp@m.@tes.nosp@m.lacon.nosp@m.trol.nosp@m.s.com

# License

Copyright (c) 2012 Anaren Microwave. All rights reserved. This Software may only be used with an Anaren A2530E24AZ1, A2530E24CZ1, A2530R24AZ1, or A2530R24CZ1 module. Redistribution and use in source and binary forms, with or without modification, are subject to the Software License Agreement in the file "anaren_eula.txt"

YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL ANAREN MICROWAVE OR TESLA CONTROLS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSE INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

## Function Documentation

void displayI2cError | ( | unsigned long | i2cErr | ) |

Displays the i2c error(s) based on the contents of bitfield i2cErr.

Displays the i2c error(s) based on the contents of bitfield i2cErr.

Parameters:

  i2cErr | the bitfield containing the error.

void i2cAddressSearch | ( | void |  | ) |

    Searches the entire i2c address space (0x00 through 0x7F) for devices which return an ACK.

Displays to console which addresses have ACK'd.

Precondition:
  I2C bus has been initialized using i2cInit(). Address used does not matter.

uint8_t i2cAddressTest | ( | uint8_t | addressToTest | ) |

    Writes to the specified address, looks to see if it was ACK'd.

Returns:
  1 if that address responded to an ACK, else 0

Parameters:

  addressToTest | the address to check

uint8_t i2cBlockRead | ( | uint8_t | numOutputBytes,
|  | uint8_t * | outputBytes,
|  | uint8_t | numBytes,
|  | uint8_t * | bytes
| ) |  |

Writes one or more bytes out via I2C, then reads the specified number of bytes in from the I2C port. Order: Start, ADDRESS(W), write first outputByte ... last outputByte, followed immediately by: Start, ADDRESS(R), read first byte ... last byte, NAK,stop

Parameters:

  outputByte | the bytes that shall be output
  numOutputBytes | the number of bytes to be output (typically 1 or 2)
  bytes | where the received bytes will be written to
  numBytes | the number of bytes to be read

Returns:
  0 if success, else an error code

int8_t i2cInit | ( | uint8_t | i2cAddress | ) |

    Initialization code. This must be called before any other method. Stores the I2C address we wish

to talk to.

Precondition:
  SDA and SCL were configured as GPIOs.

Parameters:

  address | which I2C address we will be communicating with. Must be a valid I2C address, between 0x08 and 0x77, inclusive. For example, a TI TMP006 has an address of 0x40; the TAOS TCS3414 has an address of 0x39.

Note:
  some manufacturers give a "read address" and "write address". To get the true I2C address, discard the LSB and shift this one bit to the right.

Returns:
  0 if success, else -1 if invalid i2c Address.

Initialize the SoftI2C interface.

Parameters:

  i2cAddress | the slave address we want to talk to.

uint8_t i2cRead | ( | uint8_t * | bytes,
|  | uint8_t | numBytes
| ) |  |

    Reads the specified number of bytes from the I2C port.

Precondition:
  bytes is large enough to hold count number of bytes.

Note:
  Assumes the IC2_MASTER_SCL is low
  Order: Start, ADDRESS, first byte ... last byte, NAK,stop

Parameters:

  bytes | where the received bytes will be written to
  numBytes | the number of bytes to be read

Postcondition:
  bytes contains the bytes read from the I2C interface

uint8_t i2cReadOneByte | ( | uint8_t * | value | ) |

    Special method for generating a NAK after only one byte is read. Use with caution.

Order: Start, ADDRESS, byte, NAK, stop.

Note:
  this can be used in place of legacy method i2cReadCurrentAddress().

Parameters:

  value | where to read the byte into

Returns:
  0 if success, else an error code

    Special method for generating a NAK after only one byte is read.

Order: Start, ADDRESS, byte, NAK, stop.

Parameters:

  value | where to read the byte into

Returns:
  0 if success, else an error code

void i2cTest | ( |  | ) |

Simple test routine to exercise the softI2c functions. Not normally used.

uint8_t i2cWrite | ( | uint8_t * | outputBytes,
|  | uint8_t | numOutputBytes
| ) |  |

    Writes the specified number of bytes out the I2C port.

Note:
  Order: Start, ADDRESS, first byte ... last byte, stop

Precondition:
  bytes contains the bytes to be written

Parameters:

  bytes | where the received bytes will be written to
  numBytes | the number of bytes to be read