
/*+-----------------------------------------------------------------------+  */
/*| (C) ADDI-DATA GmbH Dieselstra?e 3 D-77833 Ottersweier                 |  */
/*+-----------------------------------------------------------------------+  */
/*| Tel : +49 (0) 7223/9493-0     | email : info@addi-data.com            |  */
/*| Fax : +49 (0) 7223/9493-92    | Internet : http:$/$/www.addi-data.com   |*/
/*+-------------------------------+---------------------------------------+  */
/*| Project : APCI-3600           | Compiler : Microsoft Visual C++       |  */
/*| Module name : AI_Intern.C     |  Version : 6.0                        |  */
/*+-------------------------------+---------------------------------------+  */
/*| Author : Guinot Catherine       Date : 16/09/2004                     |  */
/*+-----------------------------------------------------------------------+  */
/*| Description : Analog Input Intern Functions of the APCI-3600          |  */
/*+-----------------------------------------------------------------------+  */
/*|                             UPDATES                                   |  */
/*+----------+-----------+------------------------------------------------+  */
/*| Date     | Author    | Description of updates                         |  */
/*+----------+-----------+------------------------------------------------+  */
/*|          |           |                                                |  */
/*+----------+-----------+------------------------------------------------+  */
#include "apci3600-private.h"


/*i_PCI3600_Intern_TestSpeedModeParameter*/
/*+----------------------------------------------------------------------------+*/
/*| Function Name : i_PCI3600_Intern_TestSpeedModeParameter ()                 |*/
/*+----------------------------------------------------------------------------+*/
/*| Task :                                                                     |*/
/*  Test the speed mode parameter                                               */
/*+----------------------------------------------------------------------------+*/
/*| Input Parameters :                                                         |*/
/*         uint32_t dw_BoardHandle     : Handle of the board                      */
/*         pstr_PCI3600_SingleBoardInformation ps_PCI3600_Board                 */
/*                                   : Board information                        */
/*         uint8_t b_ClockSelection    : Clock Selection                          */
/*         uint8_t b_SpeedMode         : Speed mode selection                     */
/*+----------------------------------------------------------------------------+*/
/*| Output Parameters : -                                                      |*/
/*                                                                              */
/*+----------------------------------------------------------------------------+*/
/*| Return Value :                                                             |*/
/*         > 0 : Warning                                                        */
/*         0 : No Error                                                         */
/*+----------------------------------------------------------------------------+*/
int i_PCI3600_Intern_TestSpeedModeParameter (pstr_PCI3600_SingleBoardInformation ps_PCI3600_Board,
		uint8_t b_ClockSelection,
		uint8_t b_SpeedMode)
{
	int i_ReturnValue = 0;

	/***********************/
	/* Test if master mode */
	/***********************/
	if (ps_PCI3600_Board->
			s_BoardInfos.
			b_MasterSlaveMode == PCI3600_MASTER_MODE) {
		if (b_ClockSelection == PCI3600_SAMPLING_CLOCK1) {
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_1) {
				if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
						(ps_PCI3600_Board->
						 s_BoardInfos.
						 b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
						||
						((b_SpeedMode == PCI3600_QUAD_SPEED) &&
						 (ps_PCI3600_Board ->
						  s_BoardInfos.
						  b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
						||
						(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
					i_ReturnValue = 0;

				} else {
					i_ReturnValue = -1;

				}
			}
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_2) {
				if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
						(ps_PCI3600_Board ->
						 s_BoardInfos.
						 b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
						||
						((b_SpeedMode == PCI3600_QUAD_SPEED) &&
						 (ps_PCI3600_Board ->
						  s_BoardInfos.
						  b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
						||
						(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
					i_ReturnValue = 0;

				} else {
					i_ReturnValue = -1;

				}
			}
		}
		if (b_ClockSelection == PCI3600_SAMPLING_CLOCK2) {
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_1) {
				if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
						(ps_PCI3600_Board ->
						 s_BoardInfos.
						 b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
						||
						((b_SpeedMode == PCI3600_QUAD_SPEED) &&
						 (ps_PCI3600_Board ->
						  s_BoardInfos.
						  b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
						||
						(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
					i_ReturnValue = 0;

				} else {
					i_ReturnValue = -1;

				}
			}
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_2) {
				if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
						(ps_PCI3600_Board ->
						 s_BoardInfos.
						 b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
						||
						((b_SpeedMode == PCI3600_QUAD_SPEED) &&
						 (ps_PCI3600_Board ->
						  s_BoardInfos.
						  b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
						||
						(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
					i_ReturnValue = 0;

				} else {
					i_ReturnValue = -1;

				}
			}
		}
	} else {
		if (b_ClockSelection == PCI3600_SAMPLING_CLOCK1) {
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SlaveSamplingClock1_Selection == PCI3600_EXT_CLOCK_1) {
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_1) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_2) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
			}
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SlaveSamplingClock1_Selection == PCI3600_EXT_CLOCK_2) {
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_1) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_2) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
			}
		}
		if (b_ClockSelection == PCI3600_SAMPLING_CLOCK2) {
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SlaveSamplingClock2_Selection == PCI3600_EXT_CLOCK_1) {
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_1) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_2) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
			}
			if (ps_PCI3600_Board ->
					s_BoardInfos.
					b_SlaveSamplingClock2_Selection == PCI3600_EXT_CLOCK_2) {
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_1) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen1_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
				if (ps_PCI3600_Board ->
						s_BoardInfos.
						b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_2) {
					if (((b_SpeedMode == PCI3600_DOUBLE_SPEED) &&
							(ps_PCI3600_Board ->
							 s_BoardInfos.
							 b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							((b_SpeedMode == PCI3600_QUAD_SPEED) &&
							 (ps_PCI3600_Board ->
							  s_BoardInfos.
							  b_ClockGen2_Divisor < PCI3600_DIVISOR_10))
							||
							(b_SpeedMode == PCI3600_SINGLE_SPEED)) {
						i_ReturnValue = 0;

					} else {
						i_ReturnValue = -1;

					}
				}
			}
		}
	}
	return (i_ReturnValue);

}
