/**
 * \file CHKMO16X.C
 * 
 * \author Axel Wolf, SCI Cupertino
 * \author Dr. Jens Barrenscheen, HL MC PD, Munich
 * \author Hubert Piontek, University of Ulm
 *
 * Routine for checking for new data in one of the message objects 1..14
 *
 * Most of this is based von the Infineon/Siemens Application Note AP2922.
 * Some additions made at University of Ulm, February 2003.
 *
 * This CAN driver is mainly meant to be used by the publisher/subscriber
 * library developed at the University of Ulm, 1999-2003.
 */

/*********************************************************************
 * Program name:	"CHKMO16X.C"                                     *
 * Compiler used:	BSO/Tasking C166                                 *
 * Task:		Source File for function check_mo_16x                *
 *			belonging to Siemens ApNote AP2922                       *
 *			"'C' CAN Driver Routines for the C166 family"            *
 *                                                                   * 
 * Last modifications:	April 28nd 1997                              *
 * Version:		1.0                                                  *
 * Authors:		Axel Wolf,  SCI Cupertino                            *
 *			Dr. Jens Barrenscheen, HL MC PD, Munich                  *
 *********************************************************************/

/* ----------------------------------- externals, prototypes: ------ */

/// pointer to message control registers.
extern unsigned int *msgctrl_ptr_16x[16];

/**
 * Checks if the specified message object (1..14) has new data. If
 * you want to check the last message object, please use check_mo15_16x().
 *
 * \param nr number of the message object to check (1..14)
 *
 * \return indication of new data
 * \retval 0 No new data received.
 * \retval 1 New data received.
 */
unsigned char check_mo_16x(unsigned char nr)
{
	unsigned char new_data_var=0;

	if ((nr<15) && (nr)) {
		/* if NEWDAT is set, return 1 */
		if (*msgctrl_ptr_16x[nr] & 0x0200) 
			new_data_var=1;
	}
	return new_data_var;
}