📄 example_pip.c
字号:
/**
* \file $Id: example_pip.c,v 1.12 2005/11/29 16:24:03 jasper Exp $
*
* \brief example of an application that controls two demodulators (Picture In Picture)
*
* \author Jasper Schrader
*
*
* $(c) 2004-2005 Micronas GmbH. All rights reserved.
*
* This software and related documentation (the 'Software') are intellectual
* property owned by Micronas and are copyright of Micronas, unless specifically
* noted otherwise.
*
* Any use of the Software is permitted only pursuant to the terms of the
* license agreement, if any, which accompanies, is included with or applicable
* to the Software ('License Agreement') or upon express written consent of
* Micronas. Any copying, reproduction or redistribution of the Software in
* whole or in part by any means not in accordance with the License Agreement
* or as agreed in writing by Micronas is expressly prohibited.
*
* THE SOFTWARE IS WARRANTED, IF AT ALL, ONLY ACCORDING TO THE TERMS OF THE
* LICENSE AGREEMENT. EXCEPT AS WARRANTED IN THE LICENSE AGREEMENT THE SOFTWARE
* IS DELIVERED 'AS IS' AND MICRONAS HEREBY DISCLAIMS ALL WARRANTIES AND
* CONDITIONS WITH REGARD TO THE SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIT
* ENJOYMENT, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL
* PROPERTY OR OTHER RIGHTS WHICH MAY RESULT FROM THE USE OR THE INABILITY
* TO USE THE SOFTWARE.
*
* IN NO EVENT SHALL MICRONAS BE LIABLE FOR INDIRECT, INCIDENTAL, CONSEQUENTIAL,
* PUNITIVE, SPECIAL OR OTHER DAMAGES WHATSOEVER INCLUDING WITHOUT LIMITATION,
* DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
* INFORMATION, AND THE LIKE, ARISING OUT OF OR RELATING TO THE USE OF OR THE
* INABILITY TO USE THE SOFTWARE, EVEN IF MICRONAS HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES, EXCEPT PERSONAL INJURY OR DEATH RESULTING FROM
* MICRONAS' NEGLIGENCE. $
*
*/
/*-----------------------------------------------------------------------------
INCLUDES
------------------------------------------------------------------------------*/
/* application include */
#include "example_aux.c.inc" /* for logging text output */
/* driver includes */
#include "drx3973d.h" /* drx397xd specific drxdriver include */
#include "drx3973d_mc.h" /* file containg the microcode (firmware) */
/*-----------------------------------------------------------------------------
DEFINES
------------------------------------------------------------------------------*/
#define LOCK_TIMEOUT 1500 /* timeout for lock-status retrieval (msec)*/
/*------------------------------------------------------------------------------
TUNER SELECTION
------------------------------------------------------------------------------*/
/* using pre-configured tuner */
#define TUNER_THOMSON_DTT_759X
#include "bsp_tuner_tables.h"
/*------------------------------------------------------------------------------
VARABLES
------------------------------------------------------------------------------*/
/* declare two tuners */
static TUNERInstance_t tuner[2];
static TUNERCommonAttr_t tunerCommAttr[2];
/* declare two demods */
static I2CDeviceAddr_t demodAddr[2];
static DRXCommonAttr_t demodCommAttr[2];
static DRXDemodInstance_t demod[2];
/* declare list for two demod instances */
static pDRXDemodInstance_t demodulators[] = { NULL, NULL, NULL };
/*------------------------------------------------------------------------------
MAIN APPLICATION
------------------------------------------------------------------------------*/
int main ( void )
{
/* channels to set */
DRXFrequency_t freqs[] = { 570000 ,
578000 }; /* kHz */
DRXBandwidth_t bandwidths[] = { DRX_BANDWIDTH_8MHZ ,
DRX_BANDWIDTH_8MHZ };
/* other variables */
u32_t start, delta, k;
DRXChannel_t channels[2];
DRXLockStatus_t lockStatus = DRX_NOT_LOCKED;
/* add demods to list */
demodulators[0] = &demod[0];
demodulators[1] = &demod[1];
/* fill out demod structures */
for ( k = 0 ; k < 2 ; k++ )
{
tuner[k] = PRE_CONF_TUNER;
tunerCommAttr[k] = *(PRE_CONF_TUNER.myCommonAttr);
tuner[k].myCommonAttr = &tunerCommAttr[k];
demodAddr[k] = DRX3973DDefaultAddr_g;
demodCommAttr[k] = DRX3973DDefaultCommAttr_g;
demod[k] = DRX3973DDefaultDemod_g;
demod[k].myI2CDevAddr = &demodAddr[k];
demod[k].myCommonAttr = &demodCommAttr[k];
demod[k].myTuner = &tuner[k];
demod[k].myCommonAttr->microcode = MC_IMAGE_ADDR;
demod[k].myCommonAttr->microcodeSize = MC_IMAGE_SIZE;
}
demod[0].myI2CDevAddr->i2cAddr = 0xE0;
demod[1].myI2CDevAddr->i2cAddr = 0xE2;
/*-----------------------------------------------------------------------*/
/* Initialization */
/*-----------------------------------------------------------------------*/
/* enable I2C communication */
if( DRXBSP_I2C_Init() != DRX_STS_OK )
{
XERROR( "failure: error initializing i2c\n" );
}
XPRINTF("success: I2C initialized\n");
/* initialize host bsp module */
if( DRXBSP_HST_Init() != DRX_STS_OK )
{
XERROR("failure: error initializing host bsp\n");
}
XPRINTF("success: Host bsp initialized\n");
/* initialize DRX driver */
if ( DRX_Init( demodulators ) != DRX_STS_OK )
{
XERROR("failure: error initializing driver\n");
}
XPRINTF("success: DRX driver initialized\n");
/* open demodulators */
for ( k = 0 ; k < 2 ; k++ )
{
if( DRX_Open(demodulators[k]) != DRX_STS_OK )
{
XPRINTF("failure: error opening demod[%d]\n", k);
XEND();
}
XPRINTF("success: demod[%d] opened\n", k);
}
XPRINTF("\n");
/*-----------------------------------------------------------------------*/
/* Set Channels */
/*-----------------------------------------------------------------------*/
for ( k = 0 ; k < 2 ; k++ )
{
channels[k].frequency = freqs[k];
channels[k].bandwidth = bandwidths[k];
channels[k].mirror = DRX_AUTO;
channels[k].constellation = DRX_AUTO;
channels[k].hierarchy = DRX_AUTO;
channels[k].priority = DRX_PRIORITY_HIGH;
channels[k].coderate = DRX_AUTO;
channels[k].guard = DRX_AUTO;
channels[k].fftmode = DRX_AUTO;
channels[k].classification = DRX_AUTO;
/* Program channel */
if( DRX_Ctrl( demodulators[k] , DRX_CTRL_SET_CHANNEL , &channels[k] ) != DRX_STS_OK )
{
XPRINTF( "failure: error programming channel on demod[%d]\n" , k );
XEND();
}
XPRINTF( "success: channel set on demod[%d] (%3d MHz)\n" , k , ((u16_t)(freqs[k]/1000)) );
/* Wait for lock */
start = DRXBSP_HST_Clock();
do{
if( DRX_Ctrl( demodulators[k] , DRX_CTRL_LOCK_STATUS, &lockStatus ) != DRX_STS_OK )
{
XPRINTF( "failure: error retrieving lockstatus of demod[%d]\n" , k );
XEND();
}
delta = DRXBSP_HST_Clock() - start;
}while( (lockStatus != DRX_LOCKED) && (delta < LOCK_TIMEOUT) );
if (lockStatus != DRX_LOCKED)
{
XPRINTF( "timeout: demod[%d] did not achieve lock\n" , k );
}
else
{
XPRINTF( "success: demod[%d] locked\n" , k );
}
XPRINTF("\n");
}
/*-----------------------------------------------------------------------*/
/* Terminate system */
/*-----------------------------------------------------------------------*/
XWAITKEYPRESSED( "Press enter to quit.\n" );
/* close system */
for ( k = 0 ; k < 2 ; k++ )
{
DRX_Close( demodulators[k] );
}
DRX_Term();
DRXBSP_HST_Term();
DRXBSP_I2C_Term();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -