beautypg.com

4 sample source code - i²c, Sample source code - i²c – HID Hi-O iCLASS Installation Guide User Manual

Page 34

background image

iCLASS OEM75 Integration Guide, 3141-907, Rev. B.0

Page 34 of 49

January 2014

HID GLOBAL CONFIDENTIAL AND/OR PROPRIETARY INFORMATION. This document contains confidential and/or proprietary

information, which may not be duplicated, published, disseminated or disclosed, or used for any purpose, without the written

consent of HID Global Corporation. If you are an unintended recipient of this information or are unwilling to accept the above

restrictions, please immediately return this document to HID Global Corporation, 15370 Barranca Pkwy, Irvine, CA 92618-3106.

6.8.4 Sample Source Code - I²C

Below is some sample code to help in implementing a Master I²C driver to talk to the OEM75.

/*======================================================================

** Copyright © 2008 HID Corporation. All rights reserved.

**

** This software is protected by copyright law and international treaties.

** Any unauthorized reproduction, distribution or use of the software

** is prohibited.

**======================================================================

***

** FILE NAME: masterI2C.h

** DESCRIPTION: This file contains the definitions used by the

** masterI²C.c file functions.

**

**======================================================================

**

**====================================================================*/

#ifndef ITG_MASTER_I2C_H

#define ITG_MASTER_I2C_H

#else

#error masterI2C.h is included multiple times.

#endif

//

// Slave device address

//

#define SLAVE_ADDR 0x02

#define I2C_MSG_BUFSIZE 200

#define I2C_ACK 0

#define I2C_NAK 1

#define NULL_MSG 0

/********** External function declarations (prototypes) **********/

/*

** These functions are defined in one module, but called in another.

** Functions that are local to a module are declared static

** and their prototypes appear only in that module.

*/

void InitI2C (void);

void WriteI2C(UBYTE *pData, UBYTE numBytes);

void ReadI2C(UBYTE *pData, UBYTE *pNumBytes);