示例#1
0
void nmi_drv_video(tNmDrvMode mode, tNmDtvStream *p, int enable)
{
	tNmiDrv *pd = &drv;

	/* isdbt mode */
	if (enable) {
		tIsdbtTso tsconfig;

		memset((void*)&tsconfig, 0, sizeof(tIsdbtTso));
		if(p->transporttype == nTS) {
			memcpy(&tsconfig, &p->tso, sizeof(tIsdbtTso));
			tsconfig.mode = pd->opmode/*p->tso.mode*/; 
			//tsconfig.tstype = nSerial;
			tsconfig.blocksize = 1;
			//tsconfig.clkrate = nClk_s_05;
			
			dPrint(N_VERB, "nmi_drv_video: TS mode, mode=[%d], tstype=[%d], blocksize[%d], clkrate[%d], datapol[%d], validpol[%d], syncpol[%d], clkedge[%d], gatedclk[%d]\n", 
					tsconfig.mode, tsconfig.tstype, 
					tsconfig.blocksize, tsconfig.clkrate,
					tsconfig.datapol, tsconfig.validpol,
					tsconfig.syncpol, tsconfig.clkedge,
					tsconfig.gatedclk); 
			
			pd->dtv.vf.tscfg((void *)&tsconfig);
			
			dPrint(N_VERB, "nmi_drv_video: tsctl(1)\n"); 
			pd->dtv.vf.tsctl(1);
		}else if(p->transporttype == nSPI) {
			tIsdbtIrq irqconfig;

			memset((void*)&irqconfig, 0, sizeof(tIsdbtIrq));
			memcpy(&tsconfig, &p->tso, sizeof(tIsdbtTso));
			tsconfig.mode = pd->opmode/*p->tso.mode*/; 
			//tsconfig.blocksize = p->tso.blocksize;
			//tsconfig.dropbadts = p->tso.dropbadts;
			dPrint(N_VERB, "nmi_drv_video: spi mode, tscfg(opmode=[%d], blocksize=[%d]) --> enableirq --> spidma(1)\n", tsconfig.mode, tsconfig.blocksize); 
			pd->dtv.vf.tscfg((void *)&tsconfig);

			irqconfig.pllresync = p->irq.pllresync;
			irqconfig.dirq.u.dmaready = p->irq.dirq.u.dmaready;
			pd->dtv.vf.enableirq((void *)&irqconfig);

			pd->dtv.vf.spidma(1);
		}
	} else {
		if(p->transporttype == nTS) {
			dPrint(N_VERB, "nmi_drv_video: tsctl(0)\n"); 
			pd->dtv.vf.tsctl(0);
		}
		else if(p->transporttype == nSPI) {
			dPrint(N_VERB, "nmi_drv_video: spidma(0)\n"); 
			pd->dtv.vf.spidma(0);
		}
	}
}
void nmi_i2c_deinit(void)
{
	dPrint(N_TRACE,"nmi_i2c_deinit: enter...\n");

#if 0
	NMI_SET_GPIO_MODE_ENABLE(NMI_SDA_PIN);
	NMI_SET_GPIO_MODE_ENABLE(NMI_SCL_PIN);

	//set as input
	NMI_SET_GPIO_DIR( NMI_SDA_PIN,0);
	NMI_SET_GPIO_DIR( NMI_SCL_PIN,0);
#endif
	dPrint(N_TRACE,"nmi_i2c_deinit: exit...\n");

}
示例#3
0
static int nmi_bus_t_burstread(int count, int isOverFlow)
{
	unsigned int pos = ntv->tsdmasize;

	dPrint(N_INTR, "nmi_bus_t_burstread, pos (%d)\n", pos);
	
	if(ntv->ptsbuf != NULL){
		dPrint(DF_INTR, "nmi_bus_t_burstread, count (%d)\n", count);
		poem->bus.burstr(ntv->ptsbuf + pos, (unsigned long)count);
		if(isOverFlow == 0)	/* if overflow not happened, move the position. */
		ntv->tsdmasize += count;	/* accumulate the received size. */
		dPrint(DF_INTR, "nmi_bus_t_burstread, ntv->tsdmasize (%d)\n", ntv->tsdmasize);
	}

	return 0;
}
示例#4
0
void cliFunc_connectLst( char* args )
{
	const char *Command_strs[] = {
		"CableCheck",
		"IdRequest",
		"IdEnumeration",
		"IdReport",
		"ScanCode",
		"Animation",
		"RemoteCapability",
		"RemoteOutput",
		"RemoteInput",
		"CurrentEvent",
	};

	print( NL );
	info_msg("List of UARTConnect commands");
	for ( uint8_t cmd = 0; cmd < Command_TOP; cmd++ )
	{
		print( NL );
		printInt8( cmd );
		print(" - ");
		dPrint( (char*)Command_strs[ cmd ] );
	}
}
示例#5
0
void cliFunc_layerList( char* args )
{
	print( NL );
	info_msg("Layer List");

	// Iterate through all of the layers and display them
	for ( index_uint_t layer = 0; layer < LayerNum; layer++ )
	{
		print( NL "\t" );
		printHex( layer );
		print(" - ");

		// Display layer name
		dPrint( (char*)LayerIndex[ layer ].name );

		// Default map
		if ( layer == 0 )
			print(" \033[1m(default)\033[0m");

		// Layer State
		print( NL "\t\t Layer State: " );
		printHex( LayerState[ layer ] );

		// First -> Last Indices
		print(" First -> Last Indices: ");
		printHex( LayerIndex[ layer ].first );
		print(" -> ");
		printHex( LayerIndex[ layer ].last );
	}
}
static int nmi5625_release(struct inode * inode, struct file * file)
{
	int ret = 0;
	struct nmi_5625_dev *d = file->private_data;
	
	func_enter();
	dPrint(N_INFO, "LHJ nmi: nmi5625_release %d \n",already_init);
	 
	//kdCISModulePowerOn(DUAL_CAMERA_SUB_SENSOR,SENSOR_DRVNAME_DB8V63L_YUV,false,"atv");
/*
	if(TRUE != hwPowerDown(CAMERA_POWER_VCAM_A,"mode_name")) {
		// PK_DBG("[CAMERA SENSOR] Fail to OFF analog power\n");
		//return -EIO;
		return ret;
	}
*/	
	//Disable I2D Data pin
	#ifdef NMI_USE_MTK_I2C_DMA    
		if(gpDMABuf_va){
			dma_free_coherent(NULL, 4096, gpDMABuf_va, gpDMABuf_pa);
			gpDMABuf_va = NULL;
			gpDMABuf_pa = NULL;
		}
	#endif

	#ifndef NMI_HW_I2C
		nmi_i2c_deinit();
	#endif
	
	func_exit();	
	return ret;
}
示例#7
0
int nmi_drv_init(void *pv)
{
	tNmiDrv *pd = &drv;
	int result	= NMI_S_OK;
	tNmiIsdbtIn inp1;
	tNmDrvInit *p = (tNmDrvInit *)pv;

	if (!already_init) {
		memset((void *)pd, 0, sizeof(tNmiDrv));

		pd->dtvbustype = p->isdbt.bustype;						/* dtv bus type */
		memcpy(&pd->ai2c, &p->isdbt.ai2c, sizeof(tI2CAdr));		/* isdbt address for master and slave */

		dPrint(N_INFO, "nmi_drv_init, ISDBT INITIALIZING.......................\n");
		/**
			Isdbt Asic Driver init
		**/
		memcpy(&inp1, &p->isdbt.core, sizeof(tNmiIsdbtIn));

		pd->bustype = pd->dtvbustype;
		
		pd->opmode = inp1.op;		/* save the opmode: nDiversity, nSingle or nPip */
		pd->dcopt = inp1.dco;

		inp1.zone					= N_ERR | N_INFO;
		inp1.hlp.write		= nmi_bus_write;
		inp1.hlp.read			= nmi_bus_read;
		inp1.hlp.t.write	= nmi_bus_t_write;
		inp1.hlp.t.read		= nmi_bus_t_read;
		inp1.hlp.t.burstread	= nmi_bus_t_burstread;
		inp1.hlp.delay		= nmi_delay;
		inp1.hlp.gettick	= nmi_get_tick;
		inp1.hlp.log			= nmi_log;

#ifndef FIX_POINT
		dPrint(N_INFO, "nmi_drv_init, ISDBT op mode=[%d], dco=[%d], xo=[%d], ldoby=[%d]\n", pd->opmode, inp1.dco, (int)inp1.xo, inp1.ldoby);
#else
		dPrint(N_INFO, "nmi_drv_init, ISDBT op mode=[%d], dco=[%d], ldoby=[%d]\n", pd->opmode, inp1.dco, inp1.ldoby);
#endif
		nmi_isdbt_common_init(&inp1, &pd->dtv.vf); 
		already_init = 1;
	}

	return result;
}
int nmi_i2c_init(void)
{
	dPrint(N_TRACE,"nmi_i2c_init: enter...\n");

#if 0
       //disable all inside pull( pullup & pulldown)
	NMI_SET_GPIO_PULL_DISABLE(NMI_SDA_PIN);
	NMI_SET_GPIO_PULL_DISABLE(NMI_SCL_PIN);
	//set gpio mode
	NMI_SET_GPIO_MODE_ENABLE(NMI_SDA_PIN);
	NMI_SET_GPIO_MODE_ENABLE(NMI_SCL_PIN);

#ifdef _DRIVE_
	//set output mode
	NMI_SET_GPIO_DIR( NMI_SDA_PIN,1);
	NMI_SET_GPIO_DIR( NMI_SCL_PIN,1);
      //set gpio high
	NMI_SET_GPIO_LEVEL( NMI_SDA_PIN,1);
	NMI_SET_GPIO_LEVEL( NMI_SCL_PIN,1);
#else
	//set input mode
	NMI_SET_GPIO_DIR( NMI_SDA_PIN,0);
	NMI_SET_GPIO_DIR( NMI_SCL_PIN,0);
#endif
#else
	//config scl
	mt_set_gpio_mode(NMI_SCL_PIN,GPIO_MODE_00);
	mt_set_gpio_dir(NMI_SCL_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(NMI_SCL_PIN,true);
	mt_set_gpio_pull_select(NMI_SCL_PIN, GPIO_PULL_UP);
	mt_set_gpio_out(NMI_SCL_PIN, GPIO_OUT_ONE);

	//config sda
	mt_set_gpio_mode(NMI_SDA_PIN, GPIO_MODE_00);
	mt_set_gpio_dir(NMI_SDA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(NMI_SDA_PIN,true);
	mt_set_gpio_pull_select(NMI_SDA_PIN, GPIO_PULL_UP);
	mt_set_gpio_out(NMI_SDA_PIN, GPIO_OUT_ONE);
#endif
	dPrint(N_TRACE,"nmi_i2c_init: exit...\n");

	return 1;
}
示例#9
0
// XXX this should maybe not be called from another thread while doing some parsing
// Currently only called once after starting, will probably be called after having
// finished the whole route
void MotionControl::setRoute(const LocList& route) {
	midpoints = route;
	dPrint(0, "reload waypoint from current location");
	routeStarting = true;
	startPoint.x = route.front().x;
	startPoint.y = route.front().y;
	auto it = route.begin(); ++it;
	float dx = it->x - startPoint.x;
	float dy = it->y - startPoint.y;
	startPoint.theta = atan2(dy, dx);
}
static int nmi5625_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int ret = 0;
	
	struct device *dev;
	func_enter();

	if (!already_init) {
		memset(&nd, 0, sizeof(struct nmi_5625_dev));

		/**
			initialize mutex
		**/
		mutex_init(&nd.mu);

		/**
			register our driver
		**/
		if ((ret = alloc_chrdev_region (&nd.devn, 0, 1, "nmi")) < 0) {
			dPrint(N_ERR, "nmi: failed unable to get major...%d\n", ret);
			goto _fail_;
		}
		dPrint(N_INFO, "nmi:dynamic major(%d),minor(%d)\n", MAJOR(nd.devn), MINOR(nd.devn));

		cdev_init(&nd.cdv, &nmi5625_fops);
		nd.cdv.owner = THIS_MODULE;
		ret = cdev_add(&nd.cdv, nd.devn, 1);
		if (ret) {
			dPrint(N_ERR, "nmi: failed to add device...%d\n", ret);
			goto _fail_;
		}

		nd.tv_class = class_create(THIS_MODULE, "atv");
		if (IS_ERR(nd.tv_class)) {
			dPrint(N_ERR, "nmi: failed to create the atv class\n");
		}

     
		dev = device_create(nd.tv_class, NULL, nd.devn, NULL, "nmi");
		if (IS_ERR(dev)) {
			dPrint(N_ERR, "nmi: failed to create device\n");
		}
		device_create_file(dev, &dev_attr_ant);
		/*User interface end */
static const struct file_operations nmi_proc_fops = {
		.write = nmi_status_write_proc,
		.read = nmi_status_read_proc,
};
//kangting
	nmi_status_proc = proc_create(NMI60X_STATUS, 0666, NULL, &nmi_proc_fops);
    if (nmi_status_proc) {
        //nmi_status_proc->read_proc = nmi_status_read_proc;
        //nmi_status_proc->write_proc = nmi_status_write_proc;
    }
    else {
        dPrint(N_ERR,"add create_proc_entry %s fail \n",NMI60X_STATUS);
    }
//ting.kang
		already_init = 1;
	}
示例#11
0
int nmi_drv_run(tNmDrvMode mode, tNmiIsdbtChip cix, void *pv)
{
	tNmiDrv *pd = &drv;
	int lock = 0;

	tIsdbtTune tune;
	tIsdbtRun *p = (tIsdbtRun *)pv;

	tune.frequency = p->frequency;
	tune.highside = p->highside;

	/**
		Tune to frequency
	**/
	pd->dtv.vf.tune(cix, (void *)&tune);

	/**
		Configure demod:
		opmode = DIVERSITY, PIP, or SINGLE
	**/
	pd->dtv.vf.demod(cix);

	/**
		Check locking
	**/
	lock = pd->dtv.vf.checklock(cix, 900);
	dPrint(N_INFO, "[nmi_drv_run]: isdbt, tune, lock (%d)\n", lock);
	
	if(lock) {
		tIsdbtTmccInfo tmccinfo;
		
		pd->dtv.vf.decoder(cix, 0, NULL);
		pd->dtv.vf.gettmccinfo(cix, &tmccinfo);
		memcpy((void *)&pd->tmcc, (void *)&tmccinfo, sizeof(tIsdbtTmccInfo));

		pd->decoder_initialized = 1;
	}else {
		pd->decoder_initialized = 0;
	}

	/**
		save the current frequency
	**/
	if(cix == nMaster)
		pd->mfrequency = p->frequency;
	else 
		pd->sfrequency = p->frequency;

	return lock;
}
示例#12
0
void cliFunc_i2cRecv( char* args )
{
	char* curArgs;
	char* arg1Ptr;
	char* arg2Ptr = args;

	// Buffer used after interpretting the args, will be sent to I2C functions
	// NOTE: Limited to 8 bytes currently (can be increased if necessary
	#define i2cSend_BuffLenMax 8
	uint8_t buffer[ i2cSend_BuffLenMax ];
	uint8_t bufferLen = 0;

	// No \r\n by default after the command is entered
	print( NL );
	info_msg("Sending: ");

	// Parse args until a \0 is found
	while ( bufferLen < i2cSend_BuffLenMax )
	{
		curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
		CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );

		// Stop processing args if no more are found
		if ( *arg1Ptr == '\0' )
			break;

		// If | is found, end sequence and start new one
		if ( *arg1Ptr == '|' )
		{
			print("| ");
			I2C_Send( buffer, bufferLen, 0 );
			bufferLen = 0;
			continue;
		}

		// Interpret the argument
		buffer[ bufferLen++ ] = (uint8_t)numToInt( arg1Ptr );

		// Print out the arg
		dPrint( arg1Ptr );
		print(" ");
	}

	print( NL );

	I2C_Send( buffer, bufferLen, 1 ); // Only 1 byte is ever read at a time with the ISSI chip
}
/**************************************************************
	
	Module:

**************************************************************/
static __init int nmi5625_init(void)
{
	int ret = 0;
	
	func_enter();

	// 如果是硬件i2c,部分还需要修改此i2c的port number
	i2c_register_board_info(NMI_I2C_NUMBER, &nmi5625_i2c_dev, 1);

	ret = i2c_add_driver(&nmi5625_i2c_driver);
	if (ret < 0) {
		dPrint(N_ERR, "nmi: failed register i2c driver...(%d)\n", ret);
	}

	func_exit();

	return ret;
}
示例#14
0
// XXX Just an example command showing how to parse arguments (more complex than generally needed)
void cliFunc_echo( char* args )
{
	char* curArgs;
	char* arg1Ptr;
	char* arg2Ptr = args;

	// Parse args until a \0 is found
	while ( 1 )
	{
		print( NL ); // No \r\n by default after the command is entered

		curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
		CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );

		// Stop processing args if no more are found
		if ( *arg1Ptr == '\0' )
			break;

		// Print out the arg
		dPrint( arg1Ptr );
	}
}
示例#15
0
int nmi_drv_init_core(tNmDrvMode mode, tNmiIsdbtChip cix)
{
	tNmiDrv *pd = &drv;
	int result = NMI_S_OK;

	if(already_init) {

		/**
			initialize chip
		**/
		dPrint(N_INFO, "nmi_drv_init_core: isdbt, chip init, index=[%d]\n", cix); 	
		if(pd->dtv.vf.init(cix) <= 0) {
			dPrint(N_ERR, "nmi_drv_init_core: isdbt, fail to chip init, index=[%d]\n", cix); 	
			result = NMI_E_FAIL;
			goto _fail_;
		}

		/* probe the chip */
		if(pd->dtv.vf.probe(nMaster) <= 0) {
			dPrint(N_ERR, "nmi_drv_init_core: isdbt, fail to probe the master chip\n"); 	
			result = NMI_E_NO_MASTER;
			goto _fail_;
		}
		
		dPrint(N_INFO, "nmi_drv_init_core: isdbt, found the master chip\n"); 		
		if(pd->opmode != nSingle) {
			if(pd->dtv.vf.probe(nSlave) <= 0) {
				dPrint(N_ERR, "nmi_drv_init_core: isdbt, fail to probe the slave chip\n"); 	
				result = NMI_E_NO_SLAVE;
				goto _fail_;	
			}

			dPrint(N_INFO, "nmi_drv_init_core: isdbt, found the slave chip\n"); 		
		}
	}

_fail_:
	return result;
}
static unsigned char i2c_write_byte(unsigned char data)
{
	unsigned char i;

#ifdef _DRIVE_
	/* loop */
	for	(i = 0; i < 8; i++) {
		/* set SDA high or low depend on the data bit */
		if (data & 0x80)
			set_i2c_sda_PIN;
		else
			clr_i2c_sda_PIN;
		/* delay */
		i2c_delay(I2C_DELAY_UNIT << 0);

		data <<= 1;

		/* set SCL high */
		set_i2c_scl_PIN;
		/* delay */
		i2c_delay(I2C_DELAY_UNIT << 0);

		/* set SCL low */
		clr_i2c_scl_PIN;
		/* delay */
		i2c_delay(I2C_DELAY_UNIT << 0);
	}
#else
	int retry, retry_val = 10000000;

	//set_sda_output();

	for	(i = 0; i < 8; i++) {
		if (data & 0x80)
			set_sda_input();
		else
			set_sda_output();

		data <<= 1;

		i2c_delay(I2C_DELAY_UNIT << 0);
		set_scl_input();
		i2c_delay(I2C_DELAY_UNIT << 0);
		retry = retry_val;
		while (retry >= 0) 
		{
			if (get_i2c_scl_PIN)
				break;
			else
			{
				i2c_delay(I2C_DELAY_UNIT << 0);
				retry--;
			}
		}

		//if (retry != retry_val)
		if (retry < (retry_val-10000))
		{
			dPrint(N_TRACE,"i2c write_byte: retry = %d\n",retry);
		}
		set_scl_output();		
		i2c_delay(I2C_DELAY_UNIT << 0);
	}
	
#endif
	
	return i2c_read_ack();
}
static unsigned char i2c_read_ack(void)
{
	unsigned char ret;

#ifdef _DRIVE_
	/* set SDA to input */
	set_sda_input();
	/* delay */
	i2c_delay(I2C_DELAY_UNIT << 0);
	
	/* read */
	if (!get_i2c_sda_PIN) {
		ret = 1;
	} else {
		ret = 0;
		dPrint(N_ERR,"[MTKI2C] 1. i2c_read_ack (Error.. No Ack received)\n");
		i2c_delay(I2C_DELAY_UNIT << 0);
		if (!get_i2c_sda_PIN) {
			ret = 1;
			dPrint(N_ERR,"[MTKI2C] 2.i2c_read_ack (Correct after additional delay.)\n");	
		} else {
			ret = 0;
			dPrint(N_ERR,"[MTKI2C] 2.i2c_read_ack (Error.. No Ack received)\n");
		}
	}

	/* set SCL high */
	set_i2c_scl_PIN;
	i2c_delay(I2C_DELAY_UNIT << 0);

	/* set SCL low */
	clr_i2c_scl_PIN;
	i2c_delay(I2C_DELAY_UNIT << 0);

	/* set SDA back to output */
	set_sda_output();

#else

	set_sda_input();
	i2c_delay(I2C_DELAY_UNIT << 0);

	if (!get_i2c_sda_PIN) {
		ret = 1;
	} else {
		ret = 0;
		dPrint(N_ERR,"[MTKI2C] 1. i2c_read_ack (Error.. No Ack received)\n");
		i2c_delay(I2C_DELAY_UNIT << 0);
		if (!get_i2c_sda_PIN) {
			ret = 1;
			dPrint(N_ERR,"[MTKI2C] 2.i2c_read_ack (Correct after additional delay.)\n");	
		} else {
			ret = 0;
			dPrint(N_ERR,"[MTKI2C] 2.i2c_read_ack (Error.. No Ack received)\n");
		}
	}
	
	set_scl_input();
	i2c_delay(I2C_DELAY_UNIT << 0);
	set_scl_output();
	i2c_delay(I2C_DELAY_UNIT << 0);
	   
#endif
	return ret;
}
//ting.kang
static int nmi5625_ioctl(struct file *file,
		    unsigned int cmd, unsigned long arg)
{
	struct nmi_5625_dev *d = file->private_data;
	long ret = 0;
	

	
	#ifdef NMI_USE_MTK_I2C_DMA
		U8 *pReadData = 0;
		U8 *pWriteData = 0;
		U8 *pa_addr = 0;
		int *user_data_addr;
	#else
		U8 *kbuf = &i2cBuf[0];
	#endif
	
    U16 len;
	
	switch ((cmd&0xffff0000)) {
        case NM5625_PWR_2P8_CTL:
		printk("NM5625_PWR_2P8_CTL, power11 %s\n",(arg==1)?"on":"off");

		if (arg == 1) {	/* on */
			// mt_set_gpio_out(u32 pin,u32 output)(NMI_POWER_VDDIO_PIN, 1);
			if (0 != cust_matv_power_on()) {
				goto _fail_;
			}
			mt_set_gpio_out(NMI_FM_ANT_PIN, GPIO_OUT_ONE);
			mt_set_gpio_out(NMI_ATV_ANT_PIN, GPIO_OUT_ZERO);
		} else{
			// mt_set_gpio_out(NMI_POWER_VDDIO_PIN, 0);
			if (0 != cust_matv_power_off()) {
				goto _fail_;
			}
			mt_set_gpio_out(NMI_FM_ANT_PIN, GPIO_OUT_ZERO);
			mt_set_gpio_out(NMI_ATV_ANT_PIN, GPIO_OUT_ONE);
		}
		break;
		
	case NM5625_PWR_1P2_CTL:
		printk("NM5625_PWR_1P2_CTL, power %s\n",(arg==1)?"on":"off");
		
		if (arg == 1) {	/* on */
#if 0
			if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_A, VOL_2800, "nmitv")) {
				goto _fail_;
			}
			mt_set_gpio_mode(GPIO_CAMERA_CMRST1_PIN,GPIO_CAMERA_CMRST1_PIN_M_GPIO);
			mt_set_gpio_dir(GPIO_CAMERA_CMRST1_PIN,GPIO_DIR_OUT);
			mt_set_gpio_out(GPIO_CAMERA_CMRST1_PIN,GPIO_OUT_ZERO);
			mt_set_gpio_mode(GPIO_CAMERA_CMPDN1_PIN,GPIO_CAMERA_CMPDN1_PIN_M_GPIO);
			mt_set_gpio_dir(GPIO_CAMERA_CMPDN1_PIN,GPIO_DIR_OUT);
			mt_set_gpio_out(GPIO_CAMERA_CMPDN1_PIN,GPIO_OUT_ONE);
			///
			if(TRUE != hwPowerOn(MT6323_POWER_LDO_VCAM_IO, VOL_1800, "nmitv")) {
				goto _fail_;
			}
			///
#endif
			mt_set_gpio_out(NMI_POWER_VCORE_PIN, GPIO_OUT_ONE);
			g_bIsAtvStart  = true;   			
		}else {
#if 0
			mt_set_gpio_mode(GPIO_CAMERA_CMRST1_PIN,GPIO_MODE_00);
			mt_set_gpio_dir(GPIO_CAMERA_CMRST1_PIN,GPIO_DIR_OUT);
			mt_set_gpio_out(GPIO_CAMERA_CMRST1_PIN,GPIO_OUT_ZERO);
			mt_set_gpio_mode(GPIO_CAMERA_CMPDN1_PIN,GPIO_MODE_00);
			mt_set_gpio_dir(GPIO_CAMERA_CMPDN1_PIN,GPIO_DIR_OUT);
			mt_set_gpio_out(GPIO_CAMERA_CMPDN1_PIN,GPIO_OUT_ZERO);
			if(TRUE != hwPowerDown(CAMERA_POWER_VCAM_A, "nmitv")) {
				goto _fail_;
			}
			if(TRUE != hwPowerDown(MT6323_POWER_LDO_VCAM_IO, "nmitv")) {
				goto _fail_;
			}
			///
#endif
			mt_set_gpio_out(NMI_POWER_VCORE_PIN, GPIO_OUT_ZERO);
			g_bIsAtvStart = false;
			///
			mt_set_gpio_out(NMI_FM_ANT_PIN, GPIO_OUT_ZERO);
			mt_set_gpio_out(NMI_ATV_ANT_PIN, GPIO_OUT_ONE);
		}	
		break;	
	case NM5625_ATV_RESET_CTL:
		printk("NM5625_ATV_RESET_CTL, power %s\n",(arg==1)?"on":"off");
       	if (arg == 1) {
			mt_set_gpio_out(NMI_RESET_PIN, GPIO_OUT_ONE);			
		} 
		else {
			mt_set_gpio_out(NMI_RESET_PIN, GPIO_OUT_ZERO);			
		}
		break;
				
	case NM5625_ATV_I2C_READ:			

			len = cmd&0xffff;	/* Note: I used the lower 16 bits for size */	
			
			dPrint(N_INFO,"NM5625_ATV_I2C_READ , len is (%d)\n" , len );
			mutex_lock(&d->mu);
			
			#ifdef NMI_HW_I2C
				#ifdef NMI_USE_MTK_I2C_DMA
				
					user_data_addr = (int *)arg;
					
					pReadData = gpDMABuf_va;
					pa_addr   = gpDMABuf_pa;
					
					if(!pReadData){
						printk("[Error] dma_alloc_coherent failed!\n");
						mutex_unlock(&d->mu);
						goto _fail_;
					}
					ret = nmi5625_dma_read_m_byte(pReadData, pa_addr, len);    
					if (ret < 0) {
						//dPrint(N_ERR, "nmi: failed i2c read...(%d)\n", ret);
						mutex_unlock(&d->mu);
						goto _fail_;
					}
										
					if (copy_to_user(user_data_addr, pReadData, len) ) {
						dPrint(N_ERR, "nmi: failed copy to user...\n");
						ret = -EFAULT;
						mutex_unlock(&d->mu);
						goto _fail_;
					}
				#else
					if ( len > 8 )
					{
						dPrint(N_ERR, "nmi: failed receive 8 more data from i2s bus , please use dma way to instead.\n");
						ret = -EFAULT;
						mutex_unlock(&d->mu);
						goto _fail_;
					}
					ret = i2c_master_recv(d->i2c_client_atv, kbuf, len);
					
					if (ret < 0) {
						dPrint(N_ERR, "nmi: failed i2c read...(%d)\n", ret);
						mutex_unlock(&d->mu);
						goto _fail_;
					}

					if (copy_to_user(arg, i2cBuf, len) ) {
						dPrint(N_ERR, "nmi: failed copy to user...\n");
						ret = -EFAULT;
						mutex_unlock(&d->mu);
						goto _fail_;
					}
				#endif //end for #ifdef NMI_USE_MTK_I2C_DMA
			#else
				ret = nmi_i2c_read(0x60,kbuf,len);
				
				//dPrint(N_TRACE,"kernel:nmi_i2c_read buf is (%x), length is (%d)\n",kbuf,len);

				if (copy_to_user(arg, i2cBuf, len) ) {
					dPrint(N_ERR, "nmi: failed copy to user...\n");
					ret = -EFAULT;
					mutex_unlock(&d->mu);
					goto _fail_;
				}
			#endif
			
			mutex_unlock(&d->mu);

            break;	
			
	case NM5625_ATV_I2C_WRITE:			

			len = cmd&0xffff;	/* Note: I used the lower 16 bits for size */	
			
			dPrint(N_INFO,"NM5625_ATV_I2C_WRITE , len is (%d)\n" , len );
			mutex_lock(&d->mu);
			
			#ifdef NMI_HW_I2C
				#ifdef NMI_USE_MTK_I2C_DMA
				
					user_data_addr = (int *)arg;
					
					pWriteData = gpDMABuf_va;
					pa_addr    = gpDMABuf_pa;
					if(!pWriteData){
						printk("[Error] dma_alloc_coherent failed!\n");
						mutex_unlock(&d->mu);
						goto _fail_;
					}
					ret = copy_from_user(pWriteData, user_data_addr, len);
					if ( ret < 0 ) {
						dPrint(N_ERR, "nmi: failed copy from user...\n");
						ret = -EFAULT;
						mutex_unlock(&d->mu);
						goto _fail_;
					}
					ret = nmi5625_dma_write_m_byte(pWriteData, pa_addr, len); 

					if (ret < 0) {
						//dPrint(N_ERR, "nmi: failed i2c read...(%d)\n", ret);
						mutex_unlock(&d->mu);
						goto _fail_;
					}
					
				#else
					if ( len > 8 )
					{
						dPrint(N_ERR, "nmi: failed to send 8 more data to i2s bus , please use dma way to instead.\n");
						ret = -EFAULT;
						mutex_unlock(&d->mu);
						goto _fail_;
					}
						
					if (copy_from_user(kbuf, arg, len)) {					
						dPrint(N_ERR, "nmi: failed copy from user...\n");
						ret = -EFAULT;
						goto _fail_;
					}
					
					ret = i2c_master_send(d->i2c_client_atv, kbuf, len);
						
					if (ret < 0) {
						dPrint(N_ERR, "nmi: failed i2c write...(%d)\n", ret);
						mutex_unlock(&d->mu);
						goto _fail_;
					}
				
				#endif //end for #ifdef NMI_USE_MTK_I2C_DMA
			#else
				if (copy_from_user(kbuf, arg, len)) {					
					dPrint(N_ERR, "nmi: failed copy from user...\n");
					ret = -EFAULT;
					goto _fail_;
				}
					
				ret = nmi_i2c_write(0x60,kbuf,len);
				dPrint(N_TRACE,"kernel:nmi_i2c_write buf is (%x), length is (%d)\n",kbuf,len);
			#endif
			
			mutex_unlock(&d->mu);
			
            break;
        
        default:
            break;
    }
_fail_:
	//func_exit();
	//dPrint(N_TRACE, "nmi_ioctl return value...(%d)\n", ret);
	return ret; 
}
示例#19
0
static void nmi_drv_dtv_ts_test_pattern(int pattern)
{
	tNmiDrv *pd = &drv;
	dPrint(N_INFO, "nmi_drv_dtv_ts_test_pattern pattern (%d)\n", pattern);
	pd->dtv.vf.dtvtspattern(pattern);
}
示例#20
0
void nmi_drv_scan(tNmDrvMode mode, tNmiIsdbtChip cix, void *pv)
{
	tNmiDrv *pd = &drv;

	tIsdbtTune tune;
	tIsdbtScan *p = (tIsdbtScan *)pv;
	pd->mfrequency = tune.frequency = p->frequency;	// tony, 20111122, to save the current frequency
	tune.highside = 0;
	p->found = pd->dtv.vf.scanpoll((void *)&tune);
#ifndef FIX_POINT
	p->tim.tscan = pd->dtv.vf.scantime();
	dPrint(N_VERB, "scan time (%f)\n", p->tim.tscan);
#endif
	dPrint(N_INFO, "Scan: freq(%d), found (%d)\n", p->frequency, p->found);

	if(p->found) {
		int lock;
		if(!pd->firstscan) {
			/**
				enable TS
			**/
			pd->dtv.vf.tsctl(1);	/* why ???, tony */

			/**
				need to run decoder for the first time
			**/
			lock = pd->dtv.vf.checklock(cix, 900);
			if (lock) {
				pd->dtv.vf.decoder(cix, 0, NULL);
				pd->firstscan = 1;
			} else {
				dPrint(N_ERR, "Error: find in scan but can't locked...\n");
				p->found = 0;
			}
		}

		if (p->found) {
			unsigned int val = 0, val1 = 0;
			uint32_t stim = nmi_get_tick();
			do {
				val = pd->dtv.vf.r32(nMaster, 0xa8f0);
				dPrint(N_VERB, "0xa8f0 (%08x)\n", val);
				if (val != 0) {
					if (val == val1) {
#ifndef FIX_POINT		// rachel - have to check SCAN TIME
						tIsdbtAcqTime acq;
		
						pd->dtv.vf.getacqtime(cix, (void *)&acq);
						p->tim.found = 1;
						p->tim.tsync = acq.totalacq - p->tim.tscan; 
#endif
						break;
					} else {
						val1 = val;
					}
				} else {
					val1 = val;
				}
			} while ((nmi_get_tick() - stim) <= 1010);
		}
	}

	/**
		get demod status
		tony, 20111122
	**/
	{
		tIsdbtSignalStatus signal;
		memset(&signal, 0, sizeof(tIsdbtSignalStatus));
		signal.get_simple_mode = 0;
		nmi_isdbt_get_status(nMaster, &signal);
		dPrint(N_VERB, "nmi_drv_scan, freq=[%d], lock=[%d], snr=[%d], rssi=[%d], lnamode=[%d]\n", 
				signal.frequency, signal.lock, signal.nsnr, signal.rssi, signal.lnamode);
	}
}
示例#21
0
void nmi_isdbt_get_status(tNmiIsdbtChip cix, tIsdbtSignalStatus *p)
{
	int tmcclock;
	tNmiDrv *pd = &drv;
	tIsdbtBer ber;
	//tIsdbtPer per;
	uint32_t nber; // cys
	//int nber;//, nper;
	tIsdbtGainInfo ginfo;
#ifndef FIX_POINT
	tIsdbtAcqTime acqtime;
#endif
	tIsdbtTmccInfo tmccinfo;
	uint32_t sq, coeff;
	int acq_mode = p->get_simple_mode;

	//dPrint(N_INFO, "nmi_isdbt_get_status: cix=[%d]\n", cix); 
	
	tmcclock = 0;
	pd->dtv.vf.chkpll(cix);		// it shoud be checked with system guys...
	tmcclock = pd->dtv.vf.tmcclock(cix);

	if (tmcclock) {
		p->lock 			= 1;
		if(!pd->decoder_initialized) {
			dPrint(N_INFO, "nmi_isdbt_get_status: pd->decoder_initialized != 1\n"); 
			pd->dtv.vf.decoder(cix, 0, NULL);
			pd->dtv.vf.gettmccinfo(cix,&tmccinfo);
			memcpy((void *)&pd->tmcc, (void *)&tmccinfo, sizeof(tIsdbtTmccInfo));
			pd->decoder_initialized = 1;
		} 
#if 0
		pd->dtv.vf.gettmccinfo(cix,&tmccinfo);
		if ((tmccinfo.mode != pd->tmcc.mode) ||
				(tmccinfo.guard != pd->tmcc.guard) ||
				(tmccinfo.coderate != pd->tmcc.coderate) ||
				(tmccinfo.modulation != pd->tmcc.modulation) ||
				(tmccinfo.interleaver != pd->tmcc.interleaver)) {
			dPrint(N_INFO, "nmi_isdbt_get_status: calling the decoder...\n"); 
			pd->dtv.vf.decoder(cix, 0, NULL);
		}
		p->mode				= tmccinfo.mode;
		p->guard			= tmccinfo.guard;
		p->modulation		= tmccinfo.modulation;
		p->interleaver		= tmccinfo.interleaver;
		p->fec				= tmccinfo.coderate;
		// [[ added by tony
		p->emerg_flag		= tmccinfo.emerg_flag;
		// ]]
#else	
		// nmi_drv_run() should have the backup of the tmcc.
		p->mode				= pd->tmcc.mode;
		p->guard			= pd->tmcc.guard;
		p->modulation		= pd->tmcc.modulation;
		p->interleaver		= pd->tmcc.interleaver;
		p->fec				= pd->tmcc.coderate;
		p->emerg_flag		= pd->tmcc.emerg_flag;
#endif
		if(acq_mode != __DEBUG_SIMPLE__) {
      p->doppler      = pd->dtv.vf.getdoppler(cix);
#ifndef FIX_POINT
			p->chanlen			= pd->dtv.vf.getchanlen(cix);		
#endif
		}
	} else {
		dPrint(N_INFO, "nmi_isdbt_get_status, tmcclock = 0\n"); 
		p->lock = 0;
	}

	/* get snr */
	if ((cix == nMaster) && (pd->opmode == nDiversity)) {
#ifndef FIX_POINT
		p->dsnr = pd->dtv.vf.getsnr(cix, 1);	/* combiner */
#else
		p->nsnr = pd->dtv.vf.getsnr(cix, 1);
#endif
		p->dsmstate = pd->dtv.vf.dsmstate();
		p->dsmlock = pd->dtv.vf.dsmlock();
	} else {
#ifndef FIX_POINT
		p->dsnr = pd->dtv.vf.getsnr(cix, 0);
#else
		p->nsnr = pd->dtv.vf.getsnr(cix, 0);
#endif
	}
	
#ifndef FIX_POINT
	dPrint(N_VERB, "lock (%d), snr (%f)\n", p->lock, p->dsnr);
#else
	dPrint(N_VERB, "lock (%d), snr (%d)\n", p->lock, p->nsnr);
#endif

	if(acq_mode != __DEBUG_SIMPLE__) {
		/**
			get ber before viterbi 
		**/
		if (pd->dtv.vf.getberb(cix, (void *)&ber) > 0) {
			nber = ber.bec / ber.becw;
			p->dbbvinst = nber;
			pd->sq[cix].abbv = ((pd->sq[cix].abbv * pd->sq[cix].npol) + nber)/(pd->sq[cix].npol + 1);//pd->sq[cix].abbv = ((pd->sq[cix].abbv * pd->sq[cix].npol) + dber)/(pd->sq[cix].npol + 1); 
			p->dbbv = pd->sq[cix].abbv;
		} else {
			/**
				review: BER counter not turn on 
			**/
			p->dbbvinst = 1;
			p->dbbv = 1;
		}
	}

	/**
		get ber 
		ber should be less than 0.0002.
	**/
	if (tmcclock) {
		pd->dtv.vf.getber(cix, (void *)&ber);
    nber = ((ber.bec * 1000000) / ber.becw); // cys
		//nber = ber.bec/ber.becw;
		p->dberinst = nber;
	
		pd->sq[cix].aber = ((pd->sq[cix].aber * pd->sq[cix].npol) + nber)/(pd->sq[cix].npol + 1);
		p->dber = pd->sq[cix].aber;
	} else {
		p->dberinst = 1;
	}

#ifdef FIX_POINT
	if(tmcclock) 
		p->dperinst = 0;
	else			
		p->dperinst = 1;
#else
	if(acq_mode != __DEBUG_SIMPLE__) {
		/**
			get per 
			per should be less than 0.0001.
		**/
		pd->dtv.vf.getper(cix, (void *)&per);
		nper = per.pec /per.pecw;
		p->dperinst = nper;
		pd->sq[cix].aper = ((pd->sq[cix].aper * pd->sq[cix].npol) + nper)/(pd->sq[cix].npol + 1);
		p->dper = pd->sq[cix].aper;	
		
		pd->sq[cix].npol++;
	}
#endif

	/**
		get rssi 
	**/
	pd->dtv.vf.getrssi(cix, (void *)&ginfo);
	p->dagc = ginfo.dagc;
	p->lnagain = (int)ginfo.bblnadb;
	p->lnagaincode = ginfo.bblnacode;
	p->lnamode = ginfo.rflna;
	p->rssi = ginfo.rssi;

	if(acq_mode != __DEBUG_SIMPLE__) {
		/**
			get offset 
		**/
#ifndef FIX_POINT
		p->freqoffset = pd->dtv.vf.getfreqoffset(cix);
		p->timeoffset = pd->dtv.vf.gettimeoffset(cix);
#endif
		
		/* get acquisation time */
		if(cix == nMaster) {
#ifndef FIX_POINT
			pd->dtv.vf.getacqtime(cix,&acqtime);

			p->agcacq		= acqtime.agcacq;
			p->syracq		= acqtime.syracq;
			p->ppmacq		= acqtime.ppmacq;
			p->tmccacq	= acqtime.tmccacq;
			p->tsacq			= acqtime.tsacq;
			p->totalacq		= acqtime.totalacq;
#endif
		}

		if (pd->opmode == nDiversity) {
			p->regad48 = pd->dtv.vf.r32(cix, 0xad48);
			p->regad4c = pd->dtv.vf.r32(cix, 0xad4c);
			p->regacc8 = pd->dtv.vf.r32(cix, 0xacc8);
		}
	}

	/**
		save the current frequency
	**/
	if(cix == nMaster)
		p->frequency = pd->mfrequency;
	else
		p->frequency = pd->sfrequency;

	if(p->rssi < -100)
		p->rssi = -100;

#ifndef FIX_POINT
	coeff = p->dsnr * 0.0625;
#else
	coeff = p->nsnr * 1;			
#endif
	sq = 2 * (100 + p->rssi);
	sq *= coeff;
	
	if(p->lock == 0)
		p->sqindicator = 0;
	else if(sq > 100)
		p->sqindicator = 100;
	else 
		p->sqindicator = (unsigned int)sq;

#if 1 //cys test
  ISDBT_MSG_SHARP_BB("[%s] snr=[%d], rssi=[%d], bec=[%d], becw=[%d], lnamode=[%d], dagc=[%d], lnagain=[%d], lnagaincode=[%d]\n",
                            __func__, p->nsnr, p->rssi, ber.bec, ber.becw, p->lnamode, p->dagc, p->lnagain, p->lnagaincode);
#endif

	return;
}
示例#22
0
void Robot::threadSense(void) {
	// FIXME: separate events could be in different threads as they all have a timeout setting.
	// It's maybe fine to poll them very fast (with a small timeout), though
	int positionSeq = -1, laserSeq = -1, bumperSeq = -1;
	
//	unsigned int cameraSeq = 0;
	while (!IsRequestTermination()) {
		// TODO: call motionControl.pollPosition(); or something here
		MaCI::Position::CPositionData pd;
		if (j2b2.iPositionOdometry->GetPositionEvent(pd, &positionSeq, 10)) {
			statistics.odometry++;
			const MaCI::Position::TPose2D* pose = pd.GetPose2D();
			if (pose) {
				lastMeas.pose.set(*pose);
				slam.updateOdometryData(SLAM::RobotLocation(pose->x, pose->y, pose->a));
				navigation.updateLocation(slam.getCurrentMapData().getGridLocation());
			} else {
				dPrint(1, "WTF, got position event with no pose");
			}

		}

		// Fetch image from robot using Camera module
		try {
			camera.updateCameraData(slam.getCurrentMapData().getRobotLocation());
			lastMeas.image.set(camera.getCameraImage());
			statistics.camera++;
		} catch ( ... ) {
			dPrint(1, "WTF, got image data with no data");
		}

/*		MaCI::Image::CImageData imgData;
		if (j2b2.iImageCameraFront->GetImageData(imgData, &cameraSeq)) {
			MaCI::Image::CImageContainer image;
			if (imgData.GetImage(image, NULL, true)) {
				lastMeas.image.set(image);
				statistics.camera++;
			} else {
				dPrint(1, "WTF, got image data with no data");
			}
		}
*/
		// TODO: actually use the additional data for something
		// timestamp sounds useful
		MaCI::Ranging::TDistanceHeader laserHeader;
		MaCI::Common::TTimestamp laserTimestamp;
		MaCI::Ranging::TDistanceArray laserDistance;
		if (j2b2.iRangingLaser->GetDistanceArray(laserDistance, &laserHeader, &laserTimestamp, &laserSeq, 10)) {
			lastMeas.lidar.set(laserDistance);
			statistics.lidar++;
		}

		MaCI::Ranging::TDistanceHeader bumperHeader;
		MaCI::Common::TTimestamp bumperTimestamp;
		MaCI::Ranging::TDistanceArray bumperDistance;
		if (j2b2.iRangingBumpers->GetDistanceArray(bumperDistance, &bumperHeader, &bumperTimestamp, &bumperSeq, 10)) {
			// four bumpers, one has data, others at distance -1
			bool hit = false;
			for(EACH_IN_i(bumperDistance)) {
				if (i->distance >= 0.00) {
					dPrint(1,"Bumpers hit: %f meters @ %f rad", i->distance, i->angle);
					taskLock.Lock();
					taskState = BACK_OFF;
					taskLock.Unlock();
					hit = true;
				}
			}
			if (taskState == BACK_OFF && hit == false) {
				taskState = EXPLORE;
				motionControl.stopBackingOff();
			}
			// TODO: do something meaningful if we crash
			// tell main planner about it
		}
	}
示例#23
0
int main(int argc, char *argv[])
{
  // Initialize Debugging library to see the dPrint():s
  debugInit();
  debugSetGlobalDebugLvl(1);

  // Construct instance of J2B2 Client
  CJ2B2Client j2b2;
  std::string machineGroup = "J2B2";

  // Just print.
  printf("\nJ2B2-UI-example - v1.1\n\n");

  // Check that required number of parameters are present, otherwise
  // print usage and exit.
  if (argc < 3 ) {
    printf("Usage:\n%s <GIMnetAP address> <GIMnetAP port> [Machine group]\n\n", argv[0]);
    exit(1);
  }

  // Open the client, store the return result. (Use command line
  // positional args directly)
  const bool open_result = j2b2.Open(argv[1], atoi(argv[2]), "", argc>3?argv[3]:"J2B2");

  // Check the Open() result
  if (open_result) {
    printf("J2B2 Open() was succesfull!\n\n");

  } else {
    printf("J2B2 Open() failed!\n\n");

  }

  // Check presence of each interface
  printf("CameraFront\t %spresent!\n", j2b2.iImageCameraFront?"":"NOT "); 
  printf("ServoCtrl\t %spresent!\n", j2b2.iServoCtrl?"":"NOT "); 
  printf("MotionCtrl\t %spresent!\n", j2b2.iMotionCtrl?"":"NOT ");
  printf("PositionOdometry %spresent!\n", j2b2.iPositionOdometry?"":"NOT ");
  printf("BehaviourCtrl\t %spresent!\n", j2b2.iBehaviourCtrl?"":"NOT "); 
  printf("RangingLaser\t %spresent!\n", j2b2.iRangingLaser?"":"NOT ");
  printf("RangingBumpers\t %spresent!\n", j2b2.iRangingBumpers?"":"NOT ");
  printf("IOBoardAD5414\t %spresent!\n", j2b2.iIOBoardAD5414?"":"NOT "); 
  printf("IOBoardESC\t %spresent!\n", j2b2.iIOBoardESC?"":"NOT "); 
  printf("TextToSpeech\t %spresent!\n", j2b2.iTextToSpeech?"":"NOT ");


  // Check for minimum setup for the Demo to work at some
  // level. Remember, that if some services are missing, the features
  // they provide will not be usable in the demo. For example, without
  // camera - no image is displayed. Also, these work as a test
  // whether _NOTHING_ was found. - in which case there is no sense to
  // run the demo.
  if (j2b2.iServoCtrl && j2b2.iMotionCtrl && 
      j2b2.iPositionOdometry &&
      j2b2.iBehaviourCtrl) {
    
    // Call demo :)
    CJ2B2Demo demo(j2b2);
    demo.Execute();
    

    // Not the cleanest way to wait. Using a signal handler (Ctrl-C
    // catcher) is recommended, but left out here to keep the code
    // more readable)
    while(1) {
      dPrint(8,"Still waiting...");
      ownSleep_ms(5000);
    }
    
    // Terminate the demostration. This will attempt to gracefully close
    // and terminate all the demonstration threads before returning
    // executing to this module.
    demo.Terminate();

  } else {
    dPrint(ODTEST,"");

  } 

  // Guess.
  printf("\nExit.\n\n");
  
  return 0;
}