Пример #1
0
void ButtonSprite::onClicked()
{
    if (callbackFunc) {
        callbackFunc();
        //        touchListener->setEnabled(false);
    }
}
Пример #2
0
/**  This function runs as a polling task at the system clock rate if there is no interrupt driver (such as Ip-Unidig) being used */
void drvAPS_EM::pollerThread()
{
    while(1) { /* Do forever */
        if (acquiring_) callbackFunc(0);
        epicsThreadSleep(epicsThreadSleepQuantum());
    }
}
Пример #3
0
/*FUNCTION**********************************************************************
 *
 * Function Name : HWTIMER_SYS_UnblockCallback
 * Description   : The function is used to unblock previously blocked callbacks.
 * If there is a callback pending, it gets immediately executed. This function 
 * must not be called from a callback routine (it does not make sense to do so
 * anyway as callback function never gets executed while callbacks are blocked).
 *
 *END**************************************************************************/
_hwtimer_error_code_t HWTIMER_SYS_UnblockCallback(hwtimer_t *hwtimer)
{
    hwtimer_callback_t callbackFunc;
    hwtimer_t volatile *hwtimerVol = hwtimer;

    /* Check input parameters */
    if (NULL == hwtimer)
    {
        return kHwtimerInvalidInput;
    }

    /* Unblock callbacks in ISR. No more pending request could arrive after this. */
    hwtimerVol->callbackBlocked = 0U;
    /* Check for any previously set pending requests during blocked state */
    if (hwtimerVol->callbackPending)
    {
        callbackFunc = hwtimerVol->callbackFunc;
        if (NULL != callbackFunc)
        {
            /* Prevent invocation of callback from ISR (callback may not be re-entrant) */
            hwtimerVol->callbackFunc = NULL;
            callbackFunc(hwtimerVol->callbackData);
            /* Allow invocation of callback from ISR */
            hwtimerVol->callbackFunc = callbackFunc;
        }
        /* Clear pending flag, callback just serviced */
        hwtimerVol->callbackPending = 0U;
    }

    return kHwtimerSuccess;
}
	IGraphAlg* CreateAlgorithm()
	{
		//initialize random seed (necessary before calling doubleSweep() ).
		srand( static_cast<unsigned int>(time(nullptr)) );

		sa_prob_func_ptr probFunc(new ExpProbability);
		sa_temp_func_ptr tempFunc(new IntervalTemperature);
		sa_callback_func_ptr callbackFunc(new DrawingCallback("."));
		IGraphAlg* alg = new SimulatedAnnealing(probFunc, tempFunc, callbackFunc);
		return alg;
	}
Пример #5
0
int
rf_State_LastState(RF_RaidAccessDesc_t *desc)
{
	void    (*callbackFunc) (RF_CBParam_t) = desc->callbackFunc;
	RF_CBParam_t callbackArg;

	callbackArg.p = desc->callbackArg;

	/*
	 * We don't support non-async IO.
	 */
	KASSERT(desc->async_flag);

	/*
	 * That's all the IO for this one... unbusy the 'disk'.
	 */

	rf_disk_unbusy(desc);

	/*
	 * Wakeup any requests waiting to go.
	 */

	rf_lock_mutex2(desc->raidPtr->mutex);
	desc->raidPtr->openings++;
	rf_unlock_mutex2(desc->raidPtr->mutex);

	rf_lock_mutex2(desc->raidPtr->iodone_lock);
	rf_signal_cond2(desc->raidPtr->iodone_cv);
	rf_unlock_mutex2(desc->raidPtr->iodone_lock);

	/*
	 * The parity_map hook has to go here, because the iodone
	 * callback goes straight into the kintf layer.
	 */
	if (desc->raidPtr->parity_map != NULL &&
	    desc->type == RF_IO_TYPE_WRITE)
		rf_paritymap_end(desc->raidPtr->parity_map, 
		    desc->raidAddress, desc->numBlocks);

	/* printf("Calling biodone on 0x%x\n",desc->bp); */
	biodone(desc->bp);	/* access came through ioctl */

	if (callbackFunc)
		callbackFunc(callbackArg);
	rf_FreeRaidAccDesc(desc);

	return RF_FALSE;
}
Пример #6
0
int
rf_State_LastState(RF_RaidAccessDesc_t *desc)
{
	void (*callbackFunc) (RF_CBParam_t) = desc->callbackFunc;
	RF_CBParam_t callbackArg;

	callbackArg.p = desc->callbackArg;

	/*
	 * If this is not an async request, wake up the caller.
	 */
	if (desc->async_flag == 0)
		wakeup(desc->bp);

	/*
	 * That's all the IO for this one... Unbusy the 'disk'.
	 */

	rf_disk_unbusy(desc);

	/*
	 * Wakeup any requests waiting to go.
	 */

	RF_LOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
	((RF_Raid_t *) desc->raidPtr)->openings++;
	RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);

	/* Wake up any pending I/O. */
	raidstart(((RF_Raid_t *) desc->raidPtr));

	/* printf("%s: Calling biodone on 0x%x.\n", __func__, desc->bp); */
	splassert(IPL_BIO);
	biodone(desc->bp);	/* Access came through ioctl. */

	if (callbackFunc)
		callbackFunc(callbackArg);
	rf_FreeRaidAccDesc(desc);

	return RF_FALSE;
}
Пример #7
0
	static DWORD WINAPI ThreadProc(LPVOID param)
	{
		auto threadRef = static_cast<ThreadRef*>(param);
		threadRef->callbackFunc(threadRef->callbackObj);
		return 0;
	}
Пример #8
0
/*******************************************************************************
	Routine Name:	i2c_continue
	Form:			int i2c_continue( void )
	Parameters:		none
	Return value:	int
						I2C_R_TRANS_FIN(=1)      : send and receive is finished
						I2C_R_TRANS_CONT_OK(=0)  : send and receive is continued (success)
						I2C_R_TRANS_CONT_NG(=-1) : send and receive is continued (failure)
						I2C_R_TRANS_FIN_NG(=-2)  : send and receive is finished (failure)
	Description:	process to continue send and receive
******************************************************************************/
int i2c_continue( void )
{
	unsigned char i2c0stat;
	unsigned char setbit;
	cbfI2c callbackFunc;

	i2c0stat = I2C0STAT;
	switch(_gsCtrlParam.status){
		case I2C_SEND_SLAVE_ADDRESS:
			/* transmission error check */
			if((i2c0stat&I2C0STAT_I20ER) == I2C0STAT_I20ER){
				_gsCtrlParam.status = I2C_TRANS_END;
				_gsCtrlParam.errStat = I2C_ERR_SEND_ERR;
				I2C0CON = (unsigned char)0x00;	/* stop i2c */
				if( _gsCtrlParam.callBack != (void *)0 ){
					callbackFunc = _gsCtrlParam.callBack;
					_gsCtrlParam.callBack = (void *)0;
					callbackFunc( _gsCtrlParam.cnt, _gsCtrlParam.errStat );
				}
				return ( I2C_R_TRANS_FIN );
			}
			/* NACK reception check */
			else if((i2c0stat&I2C0STAT_I20ACR) == I2C0STAT_I20ACR){
				_gsCtrlParam.status = I2C_TRANS_END;
				_gsCtrlParam.errStat = I2C_ERR_ACR;
				I2C0CON = (unsigned char)I2C0CON_I20SP;	/* Stop condition */
			}
			/* Slave address transmission success */
			else{
				if(_gsCtrlParam.addr_size != 0){
					_gsCtrlParam.status = I2C_SEND_ADDRESS;
					I2C0TD = (unsigned char)*_gsCtrlParam.addr;
					_gsCtrlParam.addr++;
					_gsCtrlParam.addr_size--;
					I2C0CON = (unsigned char)I2C0CON_I20ST;	/* i2c start */
				}
				else{
					if(_gsCtrlParam.mode != 0 ){
						_gsCtrlParam.status = I2C_RECEIVE_DATA;
						setbit = I2C0CON_I20ST;
						if( ( _gsCtrlParam.data_size - 1) == _gsCtrlParam.cnt ){
							setbit |= (unsigned char)I2C0CON_I20ACT;
						}
						I2C0CON = setbit;
					}
					else{
						_gsCtrlParam.status = I2C_SEND_DATA;
						I2C0TD = (unsigned char)*_gsCtrlParam.data;
						_gsCtrlParam.data++;
						_gsCtrlParam.cnt++;
						I2C0CON = (unsigned char)I2C0CON_I20ST;
					}
				}
			}
			return(I2C_R_TRANS_CONT_OK);

		case I2C_SEND_ADDRESS:
			if((i2c0stat&I2C0STAT_I20ACR) == I2C0STAT_I20ACR){
				_gsCtrlParam.status = I2C_TRANS_END;
				_gsCtrlParam.errStat = I2C_ERR_ACR;
				I2C0CON = (unsigned char)I2C0CON_I20SP;	/* Stop condition */
			}
			else{
				if( _gsCtrlParam.addr_size != 0 ){
					I2C0TD = (unsigned char)*_gsCtrlParam.addr;
					_gsCtrlParam.addr++;
					_gsCtrlParam.addr_size--;
					I2C0CON = (unsigned char)I2C0CON_I20ST;	/* i2c start */
				}
				/* Address transmission success */
				else{
					if(_gsCtrlParam.data_size == 0){
						_gsCtrlParam.status = I2C_TRANS_END;
						I2C0CON = (unsigned char)I2C0CON_I20SP;	/* Stop condition */
					}
					else{
						if(_gsCtrlParam.mode != 0 ){/* receive mode */
							_gsCtrlParam.status = I2C_SEND_SLAVE_ADDRESS;
							I20RW = 1;		/* Receive mode */
							I20RS = 1;		/* Restart condition */
						}
						else{/* send mode */
							_gsCtrlParam.status = I2C_SEND_DATA;
							I2C0TD = (unsigned char)*_gsCtrlParam.data;
							_gsCtrlParam.data++;
							_gsCtrlParam.cnt++;
							I2C0CON = (unsigned char)I2C0CON_I20ST;
						}
					}
				}
			}
			return ( I2C_R_TRANS_CONT_OK );

		case I2C_SEND_DATA:
			if((i2c0stat&I2C0STAT_I20ACR) == I2C0STAT_I20ACR){
				_gsCtrlParam.status = I2C_TRANS_END;
				_gsCtrlParam.errStat = I2C_ERR_ACR;
				I2C0CON = (unsigned char)I2C0CON_I20SP;	/* Stop condition */
			}
			else if( _gsCtrlParam.data_size != _gsCtrlParam.cnt ){
				I2C0TD = (unsigned char)*_gsCtrlParam.data;
				_gsCtrlParam.data++;
				_gsCtrlParam.cnt++;
				I2C0CON = (unsigned char)I2C0CON_I20ST;
			}
			else{
				_gsCtrlParam.status = (unsigned char)I2C_TRANS_END;
				/*---	Stop condition send ?	---*/
				I2C0CON = (unsigned char)I2C0CON_I20SP;	/* Stop condition */
			}
			return ( I2C_R_TRANS_CONT_OK );

		case I2C_RECEIVE_DATA:
			*_gsCtrlParam.data = I2C0RD;
			_gsCtrlParam.data++;
			_gsCtrlParam.cnt++;
			if( _gsCtrlParam.data_size != _gsCtrlParam.cnt ){
				setbit = (unsigned char)I2C0CON_I20ST;
				if( ( _gsCtrlParam.data_size - 1) == _gsCtrlParam.cnt ){
					setbit |= (unsigned char)I2C0CON_I20ACT;
				}
				I2C0CON = setbit;
			}
			else{
				_gsCtrlParam.status = (unsigned char)I2C_TRANS_END;
				I2C0CON = (unsigned char)I2C0CON_I20SP;	/* Stop condition */
			}
			return(I2C_R_TRANS_CONT_OK);

		case I2C_TRANS_END:
		default:
			if( _gsCtrlParam.callBack != (void *)0 ){
				callbackFunc = _gsCtrlParam.callBack;
				_gsCtrlParam.callBack = (void *)0;
				callbackFunc( _gsCtrlParam.cnt, _gsCtrlParam.errStat );
			}
			break;
	}
	return ( I2C_R_TRANS_FIN );
}