Exemple #1
0
void
Accelerometer::Run(const String& command) {
	if (!command.IsEmpty()) {
		Uri commandUri;
		commandUri.SetUri(command);
		String method = commandUri.GetHost();
		StringTokenizer strTok(commandUri.GetPath(), L"/");
		if(strTok.GetTokenCount() == 1) {
			strTok.GetNextToken(callbackId);
			AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer());
		}
		if(method == L"com.cordova.Accelerometer.watchAcceleration" && !callbackId.IsEmpty() && !IsStarted()) {
			StartSensor();
		}
		if(method == L"com.cordova.Accelerometer.clearWatch" && IsStarted()) {
			StopSensor();
		}
		if(method == L"com.cordova.Accelerometer.getCurrentAcceleration" && !callbackId.IsEmpty() && !IsStarted()) {
			GetLastAcceleration();
		}
		AppLogDebug("Acceleration command %S completed", command.GetPointer());
	} else {
		AppLogDebug("Can't run empty command");
	}
}
Exemple #2
0
void
Compass::Run(const String& command) {
	if (!command.IsEmpty()) {
		String args;
		String delim(L"/");
		command.SubString(String(L"gap://").GetLength(), args);
		StringTokenizer strTok(args, delim);
		if(strTok.GetTokenCount() < 2) {
			AppLogDebug("Not Enough Params");
			return;
		}
		String method;
		strTok.GetNextToken(method);
		// Getting callbackId
		strTok.GetNextToken(callbackId);
		AppLogDebug("Method %S, callbackId: %S", method.GetPointer(), callbackId.GetPointer());
		// used to determine callback ID
		if(method == L"com.phonegap.Compass.watchHeading" && !callbackId.IsEmpty() && !IsStarted()) {
			AppLogDebug("watching compass...");
			StartSensor();
		}
		if(method == L"com.phonegap.Compass.clearWatch" && !callbackId.IsEmpty() && IsStarted()) {
			AppLogDebug("stop watching compass...");
			StopSensor();
		}
		if(method == L"com.phonegap.Compass.getCurrentHeading" && !callbackId.IsEmpty() && !IsStarted()) {
			AppLogDebug("getting current compass...");
			GetLastHeading();
		}
		AppLogDebug("Compass command %S completed", command.GetPointer());
	} else {
		AppLogDebug("Can't run empty command");
	}
}
/**
 \if INCLUDE_IN_HTML_ONLY
 \fn        void StopResource(uint8_t e_StreamResource)
 \brief     Low level function to stop a resource
 \param     e_StreamResource    :   The resource which is to be stopped, possible values are StreamResource_e_Sensor and StreamResource_e_Rx
 \return    None
 \ingroup   Stream
 \callgraph
 \callergraph
 \endif
*/
void
StopResource(
uint8_t e_StreamResource)
{
    if (StreamResource_e_Rx == e_StreamResource)
    {
        if
        (
            (
                (Flag_e_TRUE == g_SystemSetup.e_Flag_abortRx_OnStop)
            ||  (Flag_e_TRUE == g_ErrorHandler.e_Flag_Error_Abort)
            )
        &&  (!Zoom_IsFDMRequestPending())
        )
        {
            OstTraceInt0(TRACE_FLOW, "Aborting smia-rx");

            // write abort_rx on to the RX_CTRL hw register
            Set_ISP_SMIARX_ISP_SMIARX_CTRL(0, 0, 1);    // rx_start,rx_stop,rx_abort

            // reset ISP
            ResetISPBlocks();

            if (Flag_e_TRUE == e_Flag_FSC_Sent)
            {
                OstTraceInt0(TRACE_DEBUG, "<INT> FEC");
                LLA_Abstraction_SendSignal_FEC();
                e_Flag_FSC_Sent = Flag_e_FALSE;
            }


            // reset flag to memorize that smia-rx has been aborted. stop is not needed now.
            g_Stream_InputStatus.e_Flag_RxStopRequested = Flag_e_FALSE;
        }
        else
        {
            Set_ISP_SMIARX_ISP_SMIARX_CTRL(0, 1, 0);    // rx_start,rx_stop,rx_abort

            // set the StopRequestedFlag to True.\n
            // the stop will be written on to HW in the context of interrupt.
            g_Stream_InputStatus.e_Flag_RxStopRequested = Flag_e_FALSE;
        }
    }
    else if (StreamResource_e_Sensor == e_StreamResource)
    {
        // procedure to stop the sensor:
        // 0) Launch timer (1 frame delay + configurable margin)
        // 1) switch to emulated sensor clock
        // 2) Disables DPHY
        // - IPP_INTERNAL_EN_CLK_CCP = 0 (only if CCP, not CSI2)
        // - wait ofr 15us (pictor_fs.pdf- page 5)
        // - (DPHY_TOP_IF_EN=0, actually stops DPHY clock)
        // 3) Stop sensor (through i2c command)
        // 4) After timer expires, free to restart the sensor if needed
        // since we have a blocking timeout, we cannot launch the timer first, we launch the timer AFTER stop sensor command

        /* Reset the Cropper of both pipes i.e. CE0 and CE1. The values to be used by cropper should be recalculated in BMS case and
        upon restarting any of the pipe. So reseting the values here.*/
        // TODO: AG : remove workaround to make BMS work
        Set_ISP_CE1_CROP_ISP_CE1_CROP_H_START_crop_h_start(0x0);
        Set_ISP_CE1_CROP_ISP_CE1_CROP_V_START_crop_v_start(0x0);

        Set_ISP_CE1_CROP_ISP_CE1_CROP_H_SIZE_crop_h_size(0x0);
        Set_ISP_CE1_CROP_ISP_CE1_CROP_V_SIZE_crop_v_size(0x0);

        Set_ISP_CE0_CROP_ISP_CE0_CROP_H_START_crop_h_start(0x0);
        Set_ISP_CE0_CROP_ISP_CE0_CROP_V_START_crop_v_start(0x0);

        Set_ISP_CE0_CROP_ISP_CE0_CROP_H_SIZE_crop_h_size(0x0);
        Set_ISP_CE0_CROP_ISP_CE0_CROP_V_SIZE_crop_v_size(0x0);

        if (SystemConfig_IPPSetupRequired())
        {
            if (SystemConfig_IsInputInterfaceCCP())
            {

            /**
                CCP stop sequence is documented in x500 raw-bayer camera start/stop sequences
                Refer 8.4 8500V2 CCP2 Sensor STOP sequence – last frame kept, Page 23-24
                Figure 7
            */
                // before stopping sensor, switch to emulated clock
                CRM_SwitchToEmulatedSensorClocks();

                Set_IPP_IPP_INTERNAL_EN_CLK_CCP(0);

                // wait for 15us
                GPIOManager_Delay_us(15);

                // Disable DPHY
                Set_IPP_IPP_DPHY_TOP_IF_EN(0);


                // Reset ISP Front end, IPP_SD_RESET = 0x1 << 8
                // NOTE1: Any IPP register access should be on 16 bit boundary from xP70, Individual access of bit will lead to undefined behaviour.
                // This problem was faced on actual customer h/w.
                Set_IPP_IPP_SD_RESET(0,0,1);


                StopSensor();

                CRM_SetSensorClockUnavailable();

                //<TODO>: Declare a macro in FrameDimension module.
                // workaround implemented in 8815. Take little more buffer than the frame length.
                GPIOManager_Delay_us((1.2 * g_FrameDimensionStatus.f_VTFrameLength_us));


                // Reset ISP Front end, IPP_SD_RESET = 0x1 << 8
                // NOTE1: Any IPP register access should be on 16 bit boundary from xP70, Individual access of bit will lead to undefined behaviour.
                // This problem was faced on actual customer h/w.
                // NOTE2: Reset of IPP_SD_RESET is suggested again in document. Might not be needed strictly. Safe to do it again.
                Set_IPP_IPP_SD_RESET(0,0,1);
            }
            else    // csi
            {
#if CRM_CSI2_CLOCK_DETECTION
                g_CRM_Status.e_Flag_StopEnabled = Flag_e_TRUE;
#else
                // before stopping sensor, switch to emulated clock
                CRM_SwitchToEmulatedSensorClocks();
#endif
                StopSensor();

#if CRM_CSI2_CLOCK_DETECTION
                OstTraceInt0(TRACE_FLOW, "Waiting for clocks to be lost");
                while (CRM_GetIsSensorClockAvailable())
                    ;
#else
                CRM_SetSensorClockUnavailable();

                //<TODO>: Declare a macro in FrameDimension module.
                // workaround implemented in 8815. Take little more buffer than the frame length.
                GPIOManager_Delay_us((1.2 * g_FrameDimensionStatus.f_VTFrameLength_us));
#endif
            }

            // Ref: Page 248, STn8500V2_SIA_HW_specification_v0.8.pdf only for V2
            // The sequence should be done only for V2. If done on V1, this will reset the full pry also.
            // issue reset only for IPP_SD_RESET - Bit 8, SDI
            // [15:9] RESERVED: default to 0
            // [8] SDI: reset sensor front-end (Sensor Data Interface) only (CSI2RX, CCPRX)
            // [7] BRML: reset BML/RML
        // [6:1] RESERVED: default to 0
        // [0] ALL: reset all sensor datapath (legacy SD_RESET)

        // Reset ISP Front end, IPP_SD_RESET = 0x1 << 8
        // NOTE1: Any IPP register access should be on 16 bit boundary from xP70, Individual access of bit will lead to undefined behaviour.
        // This problem was faced on actual customer h/w.
        // NOTE2: Reset of IPP_SD_RESET is suggested again in document. Might not be needed strictly. Safe to do it again.
        Set_IPP_IPP_SD_RESET(0,0,1);

        }
    }


    return;
}