Exemplo n.º 1
0
/*
** Called to enable amp (enable output force)
*/
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex)
{
    if (!g_bAmpEnabled)
    {
        DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_AmpEnable.\n"));

        g_bAmpEnabled = true;
        gOldForce = 0;

        /* 
        ** Ensure the PWM frequency is at the expected value. These 2 lines of code
        ** can be removed if no other application alters the PWM frequency.
        */

        // PWM_CTRL  = 0;                  /* 13Mhz / (0 + 1) = 13MHz */
        // PWM_PERIOD = PWM_DUTY_MAX;      /* 13Mhz / (PWM_DUTY_MAX + 1) = 22.4kHz */

        ///* Set duty cycle to 50% */
        // PWM_DUTY = (PWM_DUTY_MAX+1)>>1; /* Duty cycle range = [0, PWM_DUTY_MAX] */
       
        tspdrv_pwm_set(1,0);


        /* Enable amp */
        tspdrv_power_set(1);
        tspdrv_ic_enable_set(1);


    }

    return VIBE_S_SUCCESS;
}
Exemplo n.º 2
0
/*
** Called by the real-time loop to set PWM duty cycle
*/
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_SetSamples(VibeUInt8 nActuatorIndex, VibeUInt16 nOutputSignalBitDepth, VibeUInt16 nBufferSizeInBytes, VibeInt8* pForceOutputBuffer)
{
    switch (nOutputSignalBitDepth)
    {
        case 8:
            /* pForceOutputBuffer is expected to contain 1 byte */
            if (nBufferSizeInBytes != 1) return VIBE_E_FAIL;

            //nForce = pForceOutputBuffer[0];
            break;
        case 16:
            /* pForceOutputBuffer is expected to contain 2 byte */
            if (nBufferSizeInBytes != 2) return VIBE_E_FAIL;

            /* Map 16-bit value to 8-bit */
            //nForce = ((VibeInt16*)pForceOutputBuffer)[0] >> 8;
            break;
        default:
            /* Unexpected bit depth */
            return VIBE_E_FAIL;
    }
	
    	if(gOldForce == pForceOutputBuffer[0]) 
	{
		return VIBE_S_SUCCESS;
	}
	else 
	{
		gOldForce =pForceOutputBuffer[0];
		DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_SetSamples. nForce=%d\n",nForce));
		tspdrv_pwm_set(1,gOldForce);
		return VIBE_S_SUCCESS;
	}    
}
Exemplo n.º 3
0
// chui101: turns on and off vibrator from user space. should only be called from work queue
static int tspdrv_set(int timeout)
{
	if(!timeout) {
		// printk(KERN_INFO "[ImmVibe] Off\n");
		// call LG functions to turn off vibe
        tspdrv_ic_enable_set(0);
        tspdrv_power_set(0);
        tspdrv_pwm_set(0,0);
	} else {
		// printk(KERN_INFO "[ImmVibe] Enabled for %d ms\n", timeout);
		// call functions to turn on vibe
        tspdrv_pwm_set(1,platform_vibe_data->amp_value);
        tspdrv_power_set(1);
        tspdrv_ic_enable_set(1);
	}
	
	vibrator_value = timeout;
	return 0;	
}
Exemplo n.º 4
0
/*
** Called to disable amp (disable output force)
*/
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex)
{
    if (g_bAmpEnabled)
    {       
        DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_AmpDisable.\n"));
        
        g_bAmpEnabled = false;
               
        /* Dnable amp */
        tspdrv_power_set(0);
        tspdrv_ic_enable_set(0);

		/* PWM off */
        tspdrv_pwm_set(0,0);

    }
    return VIBE_S_SUCCESS;
}
Exemplo n.º 5
0
/*
** Called to set force output frequency parameters
*/
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_SetFrequency(VibeUInt8 nActuatorIndex, VibeUInt16 nFrequencyParameterID, VibeUInt32 nFrequencyParameterValue)
{
    tspdrv_pwm_set(1,nFrequencyParameterValue);

    return VIBE_S_SUCCESS;
}