CMX865AEのソース解析



int cmx_callprogress_detect()
{
	
	int i;
	u16 status ;
	int	high=0;
	
	
	cmx_reset();
	cmx_write(GENERALCONTROL,(u16)0x0180);
	OSTimeDly(100);
	cmx_write(GENERALCONTROL,(u16)0x0100);
	
	cmx_write(RXMODE,(u16)0x1e03);
	//cmx_write(RXMODE,(u16)0x0e03);
	
	cmx_write(GENERALCONTROL,(u16)0x0100);
	
	LINE_HOLD = 1;
	LINE_CHANGE = 1;
	LINE_MUTE = 0;
	OSTimeDly(500);
	
	for(i = 0 ;i  < 100 ; i++)
	{
		status = cmx_read(STATUS);
		if(status & 0x0400) high++;
		OSTimeDly(10);
	}
	
	if(high > 90) return 1;
	else if(high > 40 && high < 60) return -1;
	
	
	return 0;
}





int cmx_info_call_kj(u8 mode)
{
	int retry = 2;
	int ret,i,j;
	u8  res;
	// Line off

	debug("\n\rcmx_info_call\n\r");
	LINE_HOLD = 0;
	LINE_CHANGE = 0;
	OSTimeDly(500);

	cmx_reset();
	cmx_read(STATUS);
	INTC.IER.BIT.IRQ6E = 1;
	cmx_write_pgm_tone();
	cmx_write(GENERALCONTROL,(u16)G_CTL_DATA);


	ret = cmx_callprogress_detect();
	if(ret != 1)
	{
		debug("[Error]call progress not found\n\r");
		return;
	}
	// Line on
	LINE_MUTE = 1;
	OSTimeDly(1000);

	for(i = 0 ; i < 11 ; i++){
		cmx_tx_dial(0x04);
	}

	pb_select_dial_kj();


	//OSTimeDly();
	LINE_MUTE = 0;

	ret = cmx_check_ring_end(0x00);

	if(ret == 1)
	{
		ret = 0;
		res = cmx_tone_wait_time2(5000);
		if(res & 0x20)
		{
			int len;

			LINE_MUTE = 1;

			len = cmx_make_test(0,cmx_test_buf);
			for(j = 0 ; j < retry ; j++)
			{
				for(i = 0 ; i< len ; i++)
				{
					cmx_tx_data(0,cmx_dtmf_code(cmx_test_buf[i]));
				}
			}

			LINE_MUTE = 0;
			res = cmx_tone_wait_time2(5000);

			if(res & 0x20)
			{
				ret = true;
			}
		}
	}

	LINE_HOLD = 0;
	LINE_CHANGE = 0;
	return ret;
}