(Page 3 of 4 in this chapter)


Configuring the Clock Mode Using SwitchPath

To configure the clock mode on the board programmatically through SwitchPath, use the CxDriverCommand function (documented in section 5.7.1) to issue the CONFIG_CLOCK command with the desired clock mode. This command adheres to MVIP-90 standard Rev. 1.0. Allowed modes are:

All applications using SwitchPath should include swpath.h. In addition, applications issuing the CONFIG_CLOCK command should include swdrv.h. This file defines the command and all available clock modes. Under Windows NT and OS/2, you can find these .H files in \NMS\INCLUDE. Under UNIX, you can find the files in /opt/nms/include.

Clock modes listed in this file other than CLOCK_REF_OSC and CLOCK_REF_MVIP do not apply to the AG Connect board.

The following code sample shows how to configure the board using SwitchPath. It configures the board according to the command line parameter.

/* ------------------------------------------------------------------------ *\
* confgclk
*
* SwitchPath-based program demonstrating programmatic control of
* MVIP bus clock mode.
*
*
\* ------------------------------------------------------------------------ */


#include <stdio.h> /* for printf() */
#include <string.h> /* for strcmp() */

#include "swpath.h" /* for SwitchPath functions */
#include "swdrv.h" /* for CONFIG_CLOCK command */


#ifdef UNIXMODE
#define DEV_NAME "/dev/agcx00"
#else
#define DEV_NAME "C:\\nms\\dll\\agcxsw.dll" /* Change path as required */
#endif


void main ( int argc, char * argv[] )
{
SwiHANDLE agcx_hd ; /* Handle for switch on board 0 */
SWPINT mode ; /* MVIP bus clock reference */
SWPINT rc ; /* Function return codes for error checking */

if ( argc != 2 )
{
printf ( "Usage: %s [master | slave]\n", argv [0] ) ;
return ;
}

/*
* Initialize SwitchPath and obtain
* a handle for the switch
*
*/
CxInitialize ( INITTYPE_RESET ) ;

rc = CxDefineSwitch ( "agcx", DEV_NAME, 0 ) ;

agcx_hd = CxGetSwitchHd ( "agcx" ) ;


/*
* Set the clock mode according to command
* line argument
*
*/
if ( strcmp ( argv [1], "master") == SUCCESS )
mode = (SEC8K_NOT_DRIVEN << 8) | (CLOCK_REF_OSC && 0xFF) ;
else
mode = (SEC8K_NOT_DRIVEN << 8) | (CLOCK_REF_MVIP && 0xFF) ;


rc = CxDriverCommand ( agcx_hd,
(SWPINT) CONFIG_CLOCK,
(SWPINT FAR * ) & mode,
(SWPINT) sizeof(mode) / sizeof(SWPINT)
) ;


if ( rc != SUCCESS )
printf ( "Clock Configuration failed: %d\n", rc ) ;

/* Other processing ... */

return ;
}


(Page 3 of 4 in this chapter)


Tech_Support@nmss.com
Copyright © 1996, Natural MicroSystems, Inc. All rights reserved.