Beispiel #1
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
void FDrive_Update(void)
{
    if (gBF.needToMountFlash == 1)      // Если обнаружено физическое подключение внешнего диска
    {
        uint timeStart = gTimerMS;
        gBF.needToMountFlash = 0;
        Display_SetDrawMode(DrawMode_Hand, FuncDrawDisplay);
        Timer_Enable(kTimerMountFlash, 10, Display_Update);
        if (f_mount(&USBDISKFatFs, (TCHAR const*)USBDISKPath, 1) != FR_OK)
        {
            Display_ShowWarning(WrongFileSystem);
        }
        else
        {
            gFlashDriveIsConnected = true;
            FM_Init();
            ChangeStateFlashDrive();
        }
        while (gTimerMS - timeStart < 3000)
        {
        };
        Timer_Disable(kTimerMountFlash);
        Display_SetDrawMode(DrawMode_Auto, 0);
    }
    else
    {
        USBH_Process(&handleUSBH);
    }
}
Beispiel #2
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
void OnTimerPressedKey(void)
{
    if(pressedKey != B_Empty)
    {
        void (*func)(void) = funcButton[pressedKey].funcLongPressure;
        Menu_ReleaseButton(pressedKey);
        if(func != 0)
        {
            func();
        }
        pressedKey = B_Empty;
    }
    Timer_Disable(kPressKey);
}
Beispiel #3
0
void OnPress_ResetSettings(void)
{
    Panel_Disable();
    Display_SetDrawMode(DrawMode_Hand, FuncDraw_ResetSettings);
    Timer_Enable(kTimerDrawHandFunction, 100, OnTimerDraw_ResetSettings);

    if (Panel_WaitPressingButton() == B_Start)
    {
        Settings_Load(true);
    }

    Timer_Disable(kTimerDrawHandFunction);
    Display_SetDrawMode(DrawMode_Auto, 0);
    Panel_Enable();
    FuncBtnStart(1);
}
Beispiel #4
0
/*
 * Timer_SetInterrupt(): sets timer Interrupt
 * timer: timer on which interrupt is set
 * time_us: reloading time in us
 */
void Timer_SetInterrupt(uint32_t timer, uint32_t time_us)
{
    /* Verify if the Timer is enabled */
    if (Timer_isEnabled(timer) == 1) {
        /* Disable Timer */
        Timer_Disable(timer);
        /* Enable Interrupt */
        (Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk;
        /* Initialize Timer Value */
        Timers[timer].timerReload = (time_us) * TIMER_TICKS_US;
        (Timers[timer].timerN)->RELOAD = Timers[timer].timerReload;
        (Timers[timer].timerN)->VALUE = Timers[timer].timerReload;
        /* Enable Counter */
        (Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk;
        /* Change timer state */
        Timers[timer].state |= TIMER_ENABLED;
    }
}
Beispiel #5
0
/******** Timer_GetCCPPeriod ************************************************
// Count the number of system ticks during one period of CCP input frequency										
// Input: timer is one of the Timer_T value ( Timer1A, Timer1B... )
// Output: none										
// ------------------------------------------------------------------------*/
void Timer_GetCCPPeriod	( Timer_T timer )
{
	unsigned long ticks = 0;
	static unsigned long last_time = 0;
	static unsigned long this_time = 0;
	static char counter = 0;
	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

	if ( counter )
	{
		// finish
		this_time = Timer_GetTime ( timer );

		if ( this_time >= last_time )
		{
			// sysTick overflow, flush data
			last_time = 0;
			this_time = 0;
			counter = 0;
		}
		else
		{
			// get the number of ticks in a period, push on to the Queue
			ticks = last_time - this_time;
			while ( xQueueSendFromISR (CCPQueue[timer], &ticks, &xHigherPriorityTaskWoken) != pdTRUE );

			// reset ISR and disable interrupt
			counter = 0;
			Timer_Disable ( timer ) ;
		}

	}
	else
	{
		// begin
		last_time = Timer_GetTime ( timer );

		// next interrupt will finish system tick calculation
		counter = 1;
	}
}
Beispiel #6
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
void Panel_Update(void)
{
    if (pressButton)
    {
        pressedButton = pressButton;
    }

    if (isRunning)
    {
        if (releaseButton)
        {
            Menu_ReleaseButton(releaseButton);
            funcButton[releaseButton].funcOnKey(-1);
            if (pressedKey != B_Empty)
            {
                Menu_ShortPressureButton(releaseButton);
                pressedKey = B_Empty;
            }
            Timer_Disable(kPressKey);
        }
        else if (pressButton)
        {
            funcButton[pressButton].funcOnKey(1);
            Menu_PressButton(pressButton);
            pressedKey = pressButton;
            Timer_Enable(kPressKey, 500, OnTimerPressedKey);
        }
        else if (regLeft)
        {
            for (int i = 0; i < numReg; i++)
            {
                funculatorReg[regLeft].rotate(-1);
            }
        }
        else if (regRight)
        {
            for (int i = 0; i < numReg; i++)
            {
                funculatorReg[regRight].rotate(1);
            }
        }
        else if (regPress)
        {
            funculatorReg[regPress].press(1);
            regPress = R_Empty;
        }
        else if (regRelease)
        {
            funculatorReg[regRelease].press(-1);
            regRelease = R_Empty;
        }
        else
        {
            ProcessingCommand();
        }
    }

    pressButton = B_Empty;
    releaseButton = B_Empty;
    regLeft = R_Empty;
    regRight = R_Empty;
    numReg = 0;

    gBF.panelControlReceive = 0;
}
Beispiel #7
0
// *************** Sensor_DisableCCPTimer ***************
int Sensor_DisableCCPTimer ( PORT_T *port )
{
	Timer_Disable (	(Timer_T)(port->port_number-1) );
	return SENSOR_SUCCESS;
}