/**
 * This function is used to receive the header of the next T=1 frame.
 * If no data is available the function polls the data line as long as it receives the
 * start of the header and then receives the entire header.
 *
 */
respData_t * receiveHeader(struct file *filp) 
{
	int count_status = 0;
	//unsigned char *ready=NULL;
	respData_t *header=NULL;
	unsigned char *r_frame=NULL;
	int len=1;
	NFC_DBG_MSG(KERN_ALERT "receiveHeader - Enter\n");
	header = gStRecvData;
	header->data = gRecvBuff;
	header->len = PH_SCAL_T1_HEADER_SIZE_NO_NAD;
	count_status = receive(filp,&gRecvBuff,len, C_TRANSMIT_NO_STOP_CONDITION);
    NFC_DBG_MSG(KERN_ALERT "sof is :0x%x\n",gRecvBuff[0]);
	// check if we received ready
#ifdef TIMER_ENABLE
again:
#endif
        
	while(gRecvBuff[0] != sof)
	{
		NFC_DBG_MSG(KERN_ALERT "SOF not found\n");
		// receive one byte and keep SS line low
		count_status = receive(filp,&gRecvBuff,len, C_TRANSMIT_NO_STOP_CONDITION | C_TRANSMIT_NO_START_CONDITION);
		NFC_DBG_MSG(KERN_ALERT "in While SOF is : 0x%x \n",gRecvBuff[0]);
	}
#ifdef TIMER_ENABLE
        if (timer_started)
        {
            timer_started  = 0;
            cleanup_timer();
        }
        if (timer_expired == 1)
        {   
             memset(gSendframe,0,300); 
             r_frame=gSendframe;
             r_frame[0] = 0x00;r_frame[1]=0x00;r_frame[2]=0x00;r_frame[3]=0x00;
             timer_started  = 0;
             timer_expired = 0;
             cleanup_timer();
            // printk(KERN_INFO "************* Sending R Frame \n");
	     send(filp,&r_frame, C_TRANSMIT_NORMAL_SPI_OPERATION, 4);
             goto again;

        }    
#endif
	NFC_DBG_MSG(KERN_ALERT "SOF FOUND\n");
	// we received ready byte, so we can receive the rest of the header and keep SS line low
	count_status = receive(filp,&(header->data),header->len , C_TRANSMIT_NO_STOP_CONDITION | C_TRANSMIT_NO_START_CONDITION);
	NFC_DBG_MSG(KERN_ALERT "receiveHeader -Exit\n");

	return header;
}
Beispiel #2
0
xint
m4v_free_decoder(DEC_CTRL * xparam)
{
    DECODER *dec = (DECODER *) xparam->handle;
    xvid_free(dec->mbs);
    xvid_free(dec->slice);
    image_destroy(&dec->refn, dec->edged_width, dec->edged_height);
    image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
    xvid_free(dec);

    write_timer();
    cleanup_timer();

    return XVID_ERR_OK;
}
Beispiel #3
0
__stkargs unsigned int alarm(unsigned int seconds)
{
    static struct timeval tv;
    static first = 1;

    if (!treq) {
	printf("No handler installed !\n");
	if (seconds > 0)
	    return 0;		/* Heartbeat won't work :+( */
    }
    tv.tv_secs = seconds;
    tv.tv_micro = 0;

    if (seconds > 0) {
	/* first call of alarm() : WaitIO on unsent request ..... */
	if (!first) {
	    treq->tr_node.io_Message.mn_ReplyPort->mp_Flags = PA_IGNORE;
	    AbortIO((struct IORequest *) treq);
	    WaitIO((struct IORequest *) treq);
	    treq->tr_node.io_Message.mn_ReplyPort->mp_Flags = PA_SIGNAL;
	}
	first = 0;
	start_timer(&tv, treq);
    } else {
	/*
	 * if I don't use this code, AbortIO will generate a signal, which
	 * will trigger catch_alarm. catch_alarm will then generate CTRL-E.
	 * This can be resolved by preventing the signal to occur :+)
	 */
	treq->tr_node.io_Message.mn_ReplyPort->mp_Flags = PA_IGNORE;
	AbortIO((struct IORequest *) treq);
	WaitIO((struct IORequest *) treq);
	cleanup_timer(&treq);
	first = 1;
    }
    return 0;
}
Beispiel #4
0
__stkargs __sigfunc new_signal(int signo, __sigfunc handler)
{
    register struct Task *this_task;

    this_task = (struct Task *) FindTask(NULL);

    switch (signo) {
    case SIGALRM:{
	    ULONG sigalrm;

	    sigalrm = sys_signal_alarm;
	    if ((__sigfunc) handler == SIG_IGN) {	/* remove SIGALRM
							 * handler */
		SetExcept(0L, sigalrm);	/* Only sigalrm !! */
		sys_signal_alarm = 0;
		handler_alarm = NULL;
		cleanup_timer(&treq);
	    } else {		/* install handler */
		if (!setup_timer(UNIT_VBLANK, &treq)) {
		    printf("Could not setup_timer\n");
		    break;	/* What else ?? */
		}
		sigalrm = 1L << (treq->tr_node.io_Message.mn_ReplyPort->mp_SigBit);

		this_task->tc_ExceptCode = (APTR) catch_exception;
		sys_signal_alarm = sigalrm;
		handler_alarm = (void (*) ()) handler;
		SetExcept(sigalrm, sigalrm);
		/* If we start treq, handler will be called */
	    }
	    break;
	}
    case SIGHUP:{
	    ULONG sighup;

	    sighup = (((__sigfunc) handler == SIG_IGN) || ((__sigfunc) handler == SIG_DFL))
		? 0 : EXT_SIGHUP;

	    this_task->tc_ExceptCode = (APTR) catch_exception;
	    sys_signal_hup = sighup;
	    handler_hup = (void (*) ()) handler;
	    SetExcept(sighup, EXT_SIGHUP);
	    break;
	}
    case SIGUSR1:{
	    ULONG sigusr;

	    sigusr = (((__sigfunc) handler == SIG_IGN) || ((__sigfunc) handler == SIG_DFL))
		? 0 : EXT_SIGUSR;

	    this_task->tc_ExceptCode = (APTR) catch_exception;
	    sys_signal_usr = sigusr;
	    handler_usr = (void (*) ()) handler;
	    SetExcept(sigusr, EXT_SIGUSR);
	    break;
	}
    default:
	signal(signo, handler);
	break;
    }
    return handler;
}