beautypg.com

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

Page 28

background image

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

Page 28 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.7.4 Sample Source Code

The following is sample code for implementing a Master SPI driver to talk to the OEM75.

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

**

** FILE NAME: masterSpi.c

**

** DESCRIPTION: This file contains functions to manage the SPI message transfers.

**

** PUBLIC FUNCTIONS:

** InitSpi

** WriteSpi

** ReadSpi

**

** PRIVATE FUNCTIONS:

** sendSpiByte

**

**

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

/********** Project Specific Includes **********/

#include "main.h"

#include "masterSpi.h"

/***************** Private Function Prototypes ***********************/

static void sendSpiByte(UBYTE dataOut, UBYTE *pDataIn);

#define SSPSTAT_MASTER 0x00

#define SSPCON1_MASTER 0x32

#define SPI_READ 0x00

#define SPI_WRITE 0x08

#define OEM75_SS RA5

#define SPI_DELAY 50