/************************************************************************/
/* Copyright 2016 MBARI, Stephen Satchell, Chuck Forsberg, and Omen Technology*/
/************************************************************************/
/* Summary	: CRC16-CCITT and Checksum Functions for OASIS				*/
/* Filename : crc16.c													*/
/* Author	: Robert Herlien (rah)										*/
/* Project	: OASIS5													*/
/* Revision: 1.0														*/
/* Created	: 8/24/2016 from public domain code found on the internet	*/
/*																			*/
/* MBARI provides this documentation and code "as is", with no warranty,	*/
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium	*/
/* Research Institute to assist in its use, correction, modification, or	*/
/* enhancement. This information should not be published or distributed to	*/
/* third parties without specific written permission from MBARI.			*/
/*																			*/
/************************************************************************/
/* Modification History:												*/
/* 24aug2016 rah - created												*/
/************************************************************************/

#ifndef INCcrc16h
#define INCcrc16h		1

extern unsigned short icrctab[];

/*
 * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. 
 *  NOTE: First argument must be in range 0 to 255.
 *        Second argument is referenced twice.
 * 
 * Programmers may incorporate any or all code into their programs, 
 * giving proper credit within the source. Publication of the 
 * source routines is permitted so long as proper credit is given 
 * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, 
 * Omen Technology.
 */

#define updcrc(cp, crc) ( icrctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp)


#endif	/* INCcrc16h */
