Example #1
0
void
mISDNisar_irq(struct isar_hw *isar)
{
	struct isar_ch *ch;

	get_irq_infos(isar);
	switch (isar->iis & ISAR_IIS_MSCMSD) {
	case ISAR_IIS_RDATA:
		ch = sel_bch_isar(isar, isar->iis >> 6);
		if (ch)
			isar_rcv_frame(ch);
		else {
			pr_debug("%s: ISAR spurious IIS_RDATA %x/%x/%x\n",
				isar->name, isar->iis, isar->cmsb,
				isar->clsb);
			isar->write_reg(isar->hw, ISAR_IIA, 0);
		}
		break;
	case ISAR_IIS_GSTEV:
		isar->write_reg(isar->hw, ISAR_IIA, 0);
		isar->bstat |= isar->cmsb;
		check_send(isar, isar->cmsb);
		break;
	case ISAR_IIS_BSTEV:
#ifdef ERROR_STATISTIC
		ch = sel_bch_isar(isar, isar->iis >> 6);
		if (ch) {
			if (isar->cmsb == BSTEV_TBO)
				ch->bch.err_tx++;
			if (isar->cmsb == BSTEV_RBO)
				ch->bch.err_rdo++;
		}
#endif
		pr_debug("%s: Buffer STEV dpath%d msb(%x)\n",
			isar->name, isar->iis>>6, isar->cmsb);
		isar->write_reg(isar->hw, ISAR_IIA, 0);
		break;
	case ISAR_IIS_PSTEV:
		ch = sel_bch_isar(isar, isar->iis >> 6);
		if (ch) {
			rcv_mbox(isar, NULL);
			if (ch->bch.state == ISDN_P_B_MODEM_ASYNC)
				isar_pump_statev_modem(ch, isar->cmsb);
			else if (ch->bch.state == ISDN_P_B_T30_FAX)
				isar_pump_statev_fax(ch, isar->cmsb);
			else if (ch->bch.state == ISDN_P_B_RAW) {
				int	tt;
				tt = isar->cmsb | 0x30;
				if (tt == 0x3e)
					tt = '*';
				else if (tt == 0x3f)
					tt = '#';
				else if (tt > '9')
					tt += 7;
				tt |= DTMF_TONE_VAL;
				_queue_data(&ch->bch.ch, PH_CONTROL_IND,
					MISDN_ID_ANY, sizeof(tt), &tt,
					GFP_ATOMIC);
			} else
				pr_debug("%s: ISAR IIS_PSTEV pm %d sta %x\n",
					isar->name, ch->bch.state,
					isar->cmsb);
		} else {
			pr_debug("%s: ISAR spurious IIS_PSTEV %x/%x/%x\n",
				isar->name, isar->iis, isar->cmsb,
				isar->clsb);
			isar->write_reg(isar->hw, ISAR_IIA, 0);
		}
		break;
	case ISAR_IIS_PSTRSP:
		ch = sel_bch_isar(isar, isar->iis >> 6);
		if (ch) {
			rcv_mbox(isar, NULL);
			isar_pump_status_rsp(ch);
		} else {
			pr_debug("%s: ISAR spurious IIS_PSTRSP %x/%x/%x\n",
				isar->name, isar->iis, isar->cmsb,
				isar->clsb);
			isar->write_reg(isar->hw, ISAR_IIA, 0);
		}
		break;
	case ISAR_IIS_DIAG:
	case ISAR_IIS_BSTRSP:
	case ISAR_IIS_IOM2RSP:
		rcv_mbox(isar, NULL);
		break;
	case ISAR_IIS_INVMSG:
		rcv_mbox(isar, NULL);
		pr_debug("%s: invalid msg his:%x\n", isar->name, isar->cmsb);
		break;
	default:
		rcv_mbox(isar, NULL);
		pr_debug("%s: unhandled msg iis(%x) ctrl(%x/%x)\n",
			isar->name, isar->iis, isar->cmsb, isar->clsb);
		break;
	}
}
Example #2
0
 virtual void super_send (InterpretedIC* ic) 	{ check_send(ic); }
Example #3
0
 virtual void normal_send(InterpretedIC* ic) 	{ check_send(ic); }
Example #4
0
 virtual void self_send  (InterpretedIC* ic) 	{ check_send(ic); }
int lm3_main(int fd,int argc, char *argv[], int sign)
{
	int m3_cmd_back = 0; 
	int ro=0;
	if(argc>1)
	{
	strncpy(tx_buff.data,(char *)tx,20);
		if(!strcmp(argv[1],"-r"))
		{
			ro=1;
		}
		else if(!strcmp(argv[1],"-g"))
		{
			tx_buff.cmd = CMD_POWER;//RCMD_KEY;
			tx_buff.datalen = 0;
		}
		else if(!strcmp(argv[1],"-p"))
		{
			tx_buff.cmd = CMD_PLAN_POWER_OFF;//RCMD_KEY;
			printf("cmd = CMD_PLAN_POWER_OFF\n");
			tx_buff.datalen = 0;
		}
		else if(!strcmp(argv[1],"-c"))
		{
			printf("cmd = CMD_POWER_OFF_NOW\n");
			tx_buff.cmd = CMD_POWER_OFF_NOW;//RCMD_KEY;
			tx_buff.datalen = 0;
		}
		else if(!strcmp(argv[1],"-l1"))
		{
			printf("cmd = CMD_430_STAT_LIGHT1\n");
			tx_buff.cmd = CMD_430_STAT_LIGHT1;
			if(sign)
			tx_buff.data[0] =0x01;
			else
			printf("ture off the l1\n");
			tx_buff.data[0] =0x00;
			tx_buff.datalen = 1;
		}
		else if(!strcmp(argv[1],"-o"))
		{
			printf("cmd = CMD_OUT_12V\n");
			tx_buff.cmd = CMD_OUT_12V;
			if(sign)
			tx_buff.data[0] =0x01;
			else
			tx_buff.data[0] =0x00;
			tx_buff.datalen = 1;
		}
		else if(!strcmp(argv[1],"-l2"))
		{
			printf("cmd = CMD_430_STAT_LIGHT2\n");
			tx_buff.cmd = CMD_430_STAT_LIGHT2;
			if(sign)
			tx_buff.data[0] =0x01;
			else
			tx_buff.data[0] =0x00;
			tx_buff.datalen = 1;
		}
		else if(!strcmp(argv[1],"-l3"))
		{
			printf("cmd = CMD_430_STAT_LIGHT3\n");
			tx_buff.cmd = CMD_430_STAT_LIGHT3;
			if(sign)
			tx_buff.data[0] =0x01;
			else
			tx_buff.data[0] =0x00;
			tx_buff.datalen = 1;
		}
		else if(!strcmp(argv[1],"-b"))
		{
			//printf("cmd = CMD_BACk_LIGHT\n");
			tx_buff.cmd = CMD_KEY_BACK_LIGHT;
			if(sign)
			tx_buff.data[0] =0x01;
			else
			tx_buff.data[0] =0x00;
			tx_buff.datalen = 1;
		}else if(!strcmp(argv[1],"-k"))
		{
			printf("cmd = CMD_ENABLE_KEY\n");
			
			tx_buff.cmd = CMD_ENABLE_KEY;
			tx_buff.datalen = 0;
		}else if(!strcmp(argv[1],"-re"))
		{
			printf("cmd = CMD_RESTART\n");
			
			tx_buff.cmd = CMD_RESTART;
			tx_buff.datalen = 0;
		}

	}
	tx_buff.magic =  LM3_MSG_MAGIC;
	tx_buff.sig = 0;
	tx_buff.check = check_send(&tx_buff);
//	printf("start spi test!\n");
	write(fd,&tx_buff,sizeof(struct lm3msg));
	FD_ZERO(&fds);
	FD_SET(fd,&fds);
	timeout.tv_sec = 0;
	timeout.tv_usec = 1000*500;
	switch(select(fd+1,&fds,NULL,NULL,&timeout))
	{
		case -1:
		case 0:
			break;
		default:
			read(fd,&rx_buff,sizeof(struct lm3msg));
			switch(rx_buff.cmd){
			case CMD_POWER:
			for(i=0;i<6;i++)
			{
					v[i] = (rx_buff.data[(i*2)]*100)+rx_buff.data[(i*2)+1];
				switch(i)
				{
					case 0:
					//	read_v[0] = (v[0]*16.2) / 1.62;   //input power 10 - 60
						read_v[0] = (v[0]*(R12 + R30)) / R30;   //input power 10 - 60
//						printf( "  %d  ", readv);
						break;
					case 1:
					//	read_v[1] = (v[1]*27) / 5;        //12v
						read_v[1] = (v[1]*(R25 + R31)) / R31;        //12v
						break;
					case 2:
					//	read_v[2] = (v[2]*30) / 10;       //5v
						read_v[2] = (v[2]*(R27 + R32)) / R32;       //5v
						break;
					case 3:
						read_v[3] = (v[3]*(R33 + R28)) / R33;       //3.3v
						break;
					case 4:
						read_v[4] = (v[4]*(R29 + R40)/R29)/3.83;       //output 0.7I
						
						break;
					case 5:
						read_v[5] = v[5];                 //1.2v
						break;

				}
			}
			m3_cmd_back =  read_v[4];
			break;
		case CMD_PLAN_POWER_OFF:
			printf("*************** get the CMD_PLAN_POWER_OFF **************\n");
			m3_cmd_back  = POWER_OFF_PLAN;	 // 2 
			break;	
		case CMD_ACK:
			printf("*************** get the CMD_ACK *************************\n");
			m3_cmd_back =  ACK_BACK;		//  1 
			break;
		case CMD_NAK:
			printf("*************** get the CMD_NAK *************************\n");
			m3_cmd_back = NAK_ERROR;		// -1 
			break;
		default:
			printf("**************** default get this way *******************\n");
			break;
		}
	}
	return m3_cmd_back;
}