Example #1
0
/*
** Function: PBX_Demo
**
** Description:
** PBX State Machine
**
** Input Parameters:
**
** Return:
** none
*/
uInt16 si3210_init (void) {
    ctrl_S spiGciObj; //spi interface object
    systemTimer_S timerObj;    //timer object
    controlInterfaceType *ProHWIntf; //hw interface
    ProslicDeviceType *ProSLICDevices[NUMBER_OF_PROSLIC]; //proslic device object
    proslicChanType_ptr arrayOfProslicChans[NUMBER_OF_CHAN]; //used for initialization only
    chanState ports[NUMBER_OF_CHAN];  //declare channel state structures
    uInt8 i=0;
    BOOLEAN keepRunning = TRUE;
    proslicChanType *pSlic;

#if (PRINTF_IS_OK)
    printf("Hang up phone!\n");
#endif
    //initialize timer
    TimerInit(&timerObj);
    ProSLIC_createControlInterface(&ProHWIntf);
    for (i=0; i<NUMBER_OF_PROSLIC; i++)
        ProSLIC_createDevice (&(ProSLICDevices[i]));
    for (i=0; i<NUMBER_OF_CHAN; i++) {
        widebandEn[i]=0;
        ProSLIC_createChannel(&(ports[i].ProObj));
        ProSLIC_SWInitChan (ports[i].ProObj,i,SI321X_TYPE, ProSLICDevices[i], ProHWIntf);
    }
    ProSLIC_setControlInterfaceCtrlObj (ProHWIntf, &spiGciObj);
    ProSLIC_setControlInterfaceReset (ProHWIntf, ctrl_ResetWrapper);
    ProSLIC_setControlInterfaceWriteRegister (ProHWIntf, ctrl_WriteRegisterWrapper);
    ProSLIC_setControlInterfaceReadRegister (ProHWIntf, ctrl_ReadRegisterWrapper);
    ProSLIC_setControlInterfaceWriteRAM (ProHWIntf, ctrl_WriteRAMWrapper);
    ProSLIC_setControlInterfaceReadRAM (ProHWIntf, ctrl_ReadRAMWrapper);
    ProSLIC_setControlInterfaceTimerObj (ProHWIntf, &timerObj);
    ProSLIC_setControlInterfaceDelay (ProHWIntf, time_DelayWrapper);
    ProSLIC_setControlInterfaceTimeElapsed (ProHWIntf, time_TimeElapsedWrapper);
    ProSLIC_setControlInterfaceGetTime (ProHWIntf, time_GetTimeWrapper);


#if (PRINTF_IS_OK)
    printf ("-------Si321x Rev ");
    printf (VERSIONSTR);
    printf (" PBX Demo Program------\n\n");
#endif


    ProSLIC_Reset((ports[0].ProObj));	//Reset the ProSLIC(s) before we begin

    //initialize SPI interface
    if (SPI_Init (&spiGciObj) ==  FALSE) {
#if (PRINTF_IS_OK)
        printf ("Cannot connect\n");
#endif
        return 0;
    }

    //Initialize the channel state for each channel
    for (i=0; i<NUMBER_OF_CHAN; i++) {
        arrayOfProslicChans[i] = (ports[i].ProObj); //create array of channel pointers (for broadcast init)
        ProSLIC_setSWDebugMode (ports[i].ProObj, 1);
    }
    ProSLIC_Init(arrayOfProslicChans,NUMBER_OF_CHAN);
    ProSLIC_RingSetup(ports[0].ProObj,USA_DEFAULT_RING);
    ProSLIC_SetLinefeedStatus(ports[0].ProObj,LF_FWD_ACTIVE);
    ProSLIC_EnableInterrupts(ports[0].ProObj);
    pSlic = (ports[0].ProObj);
    printChipDetails(pSlic);

    for (i=0; i<NUMBER_OF_CHAN; i++) {
        pSlic = (ports[i].ProObj);
        InitStateMachine(&(ports[i])); //initialize the call state machine
        ProSLIC_InitializeDialPulseDetect(&(ports[i].pulseDialData),&(ports[i].offHookTime),&(ports[i].onHookTime));
        if(pSlic->error==SPIFAIL)
            return 0;
        pSlic->deviceId->ctrlInterface->getTime_fptr(pSlic->deviceId->ctrlInterface->hTimer,&(ports[i].offHookTime));
        pSlic->deviceId->ctrlInterface->getTime_fptr(pSlic->deviceId->ctrlInterface->hTimer,&(ports[i].onHookTime));
    }


    //printMenu();
    callDoRinging (&(ports[0]));
    {
        int nTry = 20;
        uInt8 hkStat;
        do {
            ProSLIC_ReadHookStatus(ports[0].ProObj,&hkStat);
            if (hkStat != ONHOOK) {
                ProSLIC_ToneGenStop(ports[0].ProObj);
                break;
            }
            else {
                printf ("Waiting OnHOOK Event..%d\n", nTry);
            }
            nTry--;
            mdelay(300);
        } while(nTry>0);
    }


    ProSLIC_PCMTimeSlotSetup(ports[0].ProObj,ppcm_config->ts_start[0],ppcm_config->ts_start[0]);

#if	defined(PCM_LINEAR)
    callDoWideband(&(ports[0]));
#else
    callDoNarrowband(&(ports[0]));
#endif
    ProSLIC_PCMStart(ports[0].ProObj);
    ProSLIC_SetLinefeedStatus(ports[0].ProObj,LF_FWD_ACTIVE);
    //start the demo
    /*
    	while (keepRunning){
    		for (i=0;i<NUMBER_OF_CHAN;i++){
    			if (ports[i].ProObj->channelEnable){
    				channelDemo(&(ports[i]),&timerObj,&keepRunning);
    				if (ports[i].connectionWith != NOCONNECT)
    					connectionManager(&(ports[i]),&(ports[ports[i].connectionWith]));
    			}
    		}
    	}
    */
    return 1;
}
Example #2
0
int CustomerVoice_HWInit() 
{
	int i; 
ctrl_S  spiGciObj;              /* User¡¦s control interface object */ 
systemTimer_S timerObj;         /* User¡¦s timer object */ 

 
/* Define Voice control interface object */ 
SiVoiceControlInterfaceType *VoiceHWIntf; 
 
/* Define array of Voice device objects */ 
SiVoiceDeviceType *VoiceDevices[NUMBER_OF_DEVICES]; 
 
/* Define array of ProSLIC channel object pointers */ 
SiVoiceChanType_ptr arrayOfVoiceChans[NUMBER_OF_CHAN]; 

    ProSLIC_dbgRingCfg ringCfg; 
    uInt8 hsState;  
    /* 
    ** Step 1: (optional) 
    ** Initialize user¡¦s control interface and timer objects ¡V this 
    ** may already be done, if not, do it here  
    */ 
 
    /*  
    ** Step 2: (required) 
    ** Create Voice Control Interface Object 
    */  
    SiVoice_createControlInterface(&VoiceHWIntf); 
 
    /* 
    ** Step 3: (required) 
    ** Create Voice Device Objects 
    */ 
    for(i=0;i<NUMBER_OF_DEVICES;i++) 
    { 
        SiVoice_createDevice(&(VoiceDevices[i])); 
    } 
 
    /* 
    ** Step 4: (required) 
    ** Create and initialize Voice channel objects 
    ** Also initialize array pointers to user¡¦s proslic channel object 
    ** members to simplify initialization process. 
    */ 
    for(i=0;i<NUMBER_OF_CHAN;i++) 
    { 
        SiVoice_createChannel(&(ports[i].VoiceObj)); 
        SiVoice_SWInitChan(ports[i].VoiceObj,i,VOICE_DEVICE_TYPE, 
                           VoiceDevices[i/CHAN_PER_DEVICE],VoiceHWIntf); 
        arrayOfVoiceChans[i] = ports[i].VoiceObj; 
        SiVoice_setSWDebugMode(ports[i].VoiceObj,TRUE);  /* optional */ 
        //ProSLIC_setSWDebugMode(ports[i].ProObj,TRUE); /* optional */
    } 
 
    /* 
    ** Step 5: (required) 
    ** Establish linkage between host objects/functions and 
    ** API  
    */ 
    SiVoice_setControlInterfaceCtrlObj (VoiceHWIntf, &spiGciObj); 
    SiVoice_setControlInterfaceReset (VoiceHWIntf, ctrl_ResetWrapper); 
    SiVoice_setControlInterfaceWriteRegister (VoiceHWIntf, ctrl_WriteRegisterWrapper); 
    SiVoice_setControlInterfaceReadRegister (VoiceHWIntf, ctrl_ReadRegisterWrapper);   
    SiVoice_setControlInterfaceWriteRAM (VoiceHWIntf, ctrl_WriteRAMWrapper); 
    SiVoice_setControlInterfaceReadRAM (VoiceHWIntf, ctrl_ReadRAMWrapper); 
    SiVoice_setControlInterfaceTimerObj (VoiceHWIntf, &timerObj); 
    SiVoice_setControlInterfaceDelay (VoiceHWIntf, time_DelayWrapper); 
    SiVoice_setControlInterfaceTimeElapsed (VoiceHWIntf, time_TimeElapsedWrapper); 
    SiVoice_setControlInterfaceGetTime (VoiceHWIntf, time_GetTimeWrapper); 
    SiVoice_setControlInterfaceSemaphore (VoiceHWIntf, NULL); 
/* 
    ** Step 6: (system dependent) 
    ** Assert hardware Reset ¡V ensure VDD, PCLK, and FSYNC are present and stable 
    ** before releasing reset 
    */ 
    SiVoice_Reset(ports[0].VoiceObj);    
 
    /* 
    ** Step 7: (required) 
    ** Initialize channels (loading of general parameters, calibrations,  
    **   dc-dc powerup, etc.) 
    ** Note that VDAA channels are ignored by ProSLIC_Init and ProSLIC  
    ** channels are ignored by Vdaa_Init. 
    */ 
    ProSLIC_Init(arrayOfVoiceChans,NUMBER_OF_CHAN);
    for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		if(arrayOfVoiceChans[i]->error!=0)
		{
			printk("ProSLIC_Init[%d] ERR=%d\n",i,arrayOfVoiceChans[i]->error);
			return 0;
		}
	}
#if 0
    Vdaa_Init(arrayOfVoiceChans,NUMBER_OF_CHAN); 
#endif	
 
    /* 
    ** Step 8: (design dependent) 
    ** Execute longitudinal balance calibration 
    ** or reload coefficients from factory LB cal 
    ** 
    ** Note: all batteries should be up and stable prior to  
    ** executing the lb cal 
    */ 
    ProSLIC_LBCal(arrayOfVoiceChans,NUMBER_OF_CHAN); 
 
     
    /* 
    ** Step 9: (design dependent) 
    ** Load custom configuration presets(generated using 
    ** ProSLIC API Config Tool) 
    */ 
    for(i=0;i<NUMBER_OF_CHAN;i++) 
    { 
        ProSLIC_DCFeedSetup(ports[i].VoiceObj,DCFEED_48V_20MA); 
        ProSLIC_RingSetup(ports[i].VoiceObj,RING_F20_45VRMS_0VDC_LPR); 
        ProSLIC_PCMSetup(ports[i].VoiceObj,PCM_DEFAULT_CONFIG); 
        ProSLIC_ZsynthSetup(ports[i].VoiceObj,ZSYN_600_0_0); 
        ProSLIC_ToneGenSetup(ports[i].VoiceObj,TONEGEN_FCC_DIAL); 
        ProSLIC_PCMTimeSlotSetup(ports[i].VoiceObj,CONFIG_PCM_TS_START+i*16,CONFIG_PCM_TS_START+i*16);
    #if 0    
        Vdaa_CountrySetup(ports[i].VoiceObj,COU_USA); 
        Vdaa_HybridSetup(ports[i].VoiceObj,HYB_600_0_0_500FT_24AWG); 
        Vdaa_PCMSetup(ports[i].VoiceObj,PCM_LINEAR16); 
 	Vdaa_PCMTimeSlotSetup(ports[i].VoiceObj,CONFIG_PCM_TS_START+i*16,CONFIG_PCM_TS_START+i*16);
    #endif
    } 
     
    /* 
    ** END OF TYPICAL INITIALIZATION  
    */ 
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		ProSLIC_PCMStart(ports[i].VoiceObj);
	}	
	
    
     /*  
    ** EXAMPLE: Change ALL ProSLIC ports to FWD_ACTIVE linefeed state 
    */ 
	for(i=0;i<NUMBER_OF_CHAN;i++) 
	{ 
		ProSLIC_SetLinefeedStatus(ports[i].VoiceObj,LF_FWD_ACTIVE); 
	} 
	#if 0
	
	ProSLIC_SetDAAEnable(ports[1].VoiceObj, 1);
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		Vdaa_PCMStart(ports[i].VoiceObj);
	}
	
	
	hsState = Vdaa_GetHookStatus(ports[1].VoiceObj);
	if(hsState == VDAA_ONHOOK) {
		Vdaa_SetHookStatus(ports[1].VoiceObj, VDAA_OFFHOOK); 
	}      
	
	hsState = Vdaa_PowerupLineside(ports[1].VoiceObj);     
	#endif
	
	//ProSLIC_PrintDebugData(ports[0].VoiceObj);
	//Vdaa_PrintDebugData(ports[1].VoiceObj);
	
	
	return 1;
} 
Example #3
0
int ProSLIC_HWInit(void)
{
	int32 i, result = 0;
	ctrl_S spiGciObj; /* User¡¦s control interface object */
	systemTimer_S timerObj; /* User¡¦s timer object */
	chanState ports[NUMBER_OF_CHAN]; /* User¡¦s channel object, which has
									** a member defined as
									** proslicChanType_ptr ProObj;
									*/
	/* Define ProSLIC control interface object */
	controlInterfaceType *ProHWIntf;
	/* Define array of ProSLIC device objects */
	ProslicDeviceType *ProSLICDevices[NUMBER_OF_PROSLIC];
	/* Define array of ProSLIC channel object pointers */
	proslicChanType_ptr arrayOfProslicChans[NUMBER_OF_CHAN];
	/*
	** Step 1: (optional)
	** Initialize user¡¦s control interface and timer objects ¡V this
	** may already be done, if not, do it here
	*/
	/*
	** Step 2: (required)
	** Create ProSLIC Control Interface Object
	*/
	ProSLIC_createControlInterface(&ProHWIntf);
	/*
	** Step 3: (required)
	** Create ProSLIC Device Objects
	*/
	for(i=0;i<NUMBER_OF_PROSLIC;i++)
	{
		ProSLIC_createDevice(&(ProSLICDevices[i]));
	}
	/*
	** Step 4: (required)
	** Create and initialize ProSLIC channel objects
	** Also initialize array pointers to user¡¦s proslic channel object
	** members to simplify initialization process.
	*/
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		ProSLIC_createChannel(&(ports[i].ProObj));
		ProSLIC_SWInitChan(ports[i].ProObj,i,PROSLIC_DEVICE_TYPE,
		ProSLICDevices[i/CHAN_PER_DEVICE],ProHWIntf);
		arrayOfProslicChans[i] = ports[i].ProObj;
		ProSLIC_setSWDebugMode(ports[i].ProObj,TRUE); /* optional */
	}
	/*
	** Step 5: (required)
	** Establish linkage between host objects/functions and
	** ProSLIC API
	*/
	ProSLIC_setControlInterfaceCtrlObj (ProHWIntf, &spiGciObj);
	ProSLIC_setControlInterfaceReset (ProHWIntf, ctrl_ResetWrapper);
	ProSLIC_setControlInterfaceWriteRegister (ProHWIntf, ctrl_WriteRegisterWrapper);
	ProSLIC_setControlInterfaceReadRegister (ProHWIntf, ctrl_ReadRegisterWrapper);
	ProSLIC_setControlInterfaceWriteRAM (ProHWIntf, ctrl_WriteRAMWrapper);
	ProSLIC_setControlInterfaceReadRAM (ProHWIntf, ctrl_ReadRAMWrapper);
	ProSLIC_setControlInterfaceTimerObj (ProHWIntf, &timerObj);
	ProSLIC_setControlInterfaceDelay (ProHWIntf, time_DelayWrapper);
	ProSLIC_setControlInterfaceTimeElapsed (ProHWIntf, time_TimeElapsedWrapper);
	ProSLIC_setControlInterfaceGetTime (ProHWIntf, time_GetTimeWrapper);
	ProSLIC_setControlInterfaceSemaphore (ProHWIntf, NULL);
	/*
	** Step 6: (system dependent)
	** Assert hardware Reset ¡V ensure VDD, PCLK, and FSYNC are present and stable
	** before releasing reset
	*/
	ProSLIC_Reset(ports[0].ProObj);
	
	//initialize SPI interface
    if (SPI_Init (NULL) ==  FALSE){

        printk ("Cannot connect\n");

        return 0;
    }

	/*
	** Step 7: (required)
	** Initialize device (loading of general parameters, calibrations,
	** dc-dc powerup, etc.)
	*/
	ProSLIC_Init(arrayOfProslicChans,NUMBER_OF_CHAN);
	printk("ProSLIC_Init done\n");
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		if(arrayOfProslicChans[i]->error!=0)
		{
			printk("ProSLIC_Init[%d] ERR=%d\n",i,arrayOfProslicChans[i]->error);
			return 0;
		}
	}
	
	/*
	** Step 8: (design dependent)
	** Execute longitudinal balance calibration
	** or reload coefficients from factory LB cal
	**
	** Note: all batteries should be up and stable prior to
	** executing the lb cal
	*/
	ProSLIC_LBCal(arrayOfProslicChans,NUMBER_OF_CHAN);
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		ProSLIC_GetLBCalResultPacked(arrayOfProslicChans[i], &result);
		printk("LBCal=0x%08X\n",result);
	}
	/*
	** Step 9: (design dependent)
	** Load custom configuration presets(generated using
	** ProSLIC API Config Tool)


	*/
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		ProSLIC_PCMTimeSlotSetup(ports[i].ProObj,ppcm_config->ts_start[i],ppcm_config->ts_start[i]);
		
		ProSLIC_DCFeedSetup(ports[i].ProObj,DCFEED_48V_20MA);
		ProSLIC_RingSetup(ports[i].ProObj,RING_F20_45VRMS_0VDC_LPR);
#if defined(PCM_LINEAR)||defined(PCM_A2L2A)||defined(PCM_U2L2U)			
		ProSLIC_PCMSetup(ports[i].ProObj,PCM_16LIN);
#endif
#if defined(PCM_ULAW)||defined(PCM_L2U2L)		
		ProSLIC_PCMSetup(ports[i].ProObj,PCM_8ULAW);
#endif
#if defined(PCM_ALAW)			
		ProSLIC_PCMSetup(ports[i].ProObj,PCM_8ALAW);
#endif
#if defined(PCM_L2A2L)			
		ProSLIC_PCMSetup(ports[i].ProObj,PCM_8ALAW);
#endif
		ProSLIC_ZsynthSetup(ports[i].ProObj,ZSYN_600_0_0_30_0);
		ProSLIC_ToneGenSetup(ports[i].ProObj,TONEGEN_FCC_DIAL);
		
	}
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		ProSLIC_PCMStart(ports[i].ProObj);
	}	
	for(i=0;i<NUMBER_OF_CHAN;i++)
	{
		ProSLIC_SetLinefeedStatus(ports[i].ProObj,LF_FWD_ACTIVE);
	}	
	return 1;
}