Exemple #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);
    }
}
Exemple #2
0
/*******************************************************************************
* Function Name: Timer_Wakeup
********************************************************************************
*
* Summary:
*  Restores the user configuration and restores the enable state.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void Timer_Wakeup(void)
{
    Timer_RestoreConfig();

    if(0u != Timer_backup.enableState)
    {
        Timer_Enable();
    }
}
Exemple #3
0
/*******************************************************************************
* Function Name: Timer_Wakeup
********************************************************************************
*
* Summary:
*  Restores and enables the user configuration
*
* Parameters:
*  void
*
* Return:
*  void
*
* Global variables:
*  Timer_backup.enableState:  Is used to restore the enable state of
*  block on wakeup from sleep mode.
*
*******************************************************************************/
void Timer_Wakeup(void) 
{
    Timer_RestoreConfig();
    #if(!Timer_UDB_CONTROL_REG_REMOVED)
        if(Timer_backup.TimerEnableState == 1u)
        {     /* Enable Timer's operation */
                Timer_Enable();
        } /* Do nothing if Timer was disabled before */
    #endif /* Remove this code section if Control register is removed */
}
Exemple #4
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);
}
Exemple #5
0
void main(void) {
	anypio_write(LED, false);

	// prepare the RGB outputs for PWM (timer and digital mode)
	ANY_GPIO_SET_FUNCTION(0,8,TMR,IOCON_IO_ADMODE_DIGITAL);
	ANY_GPIO_SET_FUNCTION(0,9,TMR,IOCON_IO_ADMODE_DIGITAL);
	ANY_GPIO_SET_FUNCTION(0,10,TMR,IOCON_IO_ADMODE_DIGITAL);

	// enable the timer
	Timer_Enable(CT16B0, true);

	// And set the match value to "about half"
	Timer_SetMatchValue(CT16B0, 0, 32000);
	Timer_SetMatchBehaviour(CT16B0, 0, 0);
	// enable PWM on red pin ...
	Timer_EnablePWM(CT16B0, 0, true);

	// repeat for green ...
	Timer_SetMatchValue(CT16B0, 1, 32000);
	Timer_SetMatchBehaviour(CT16B0, 1, 0);
	Timer_EnablePWM(CT16B0, 1, true);

	// ... and blue
	Timer_SetMatchValue(CT16B0, 2, 32000);
	Timer_SetMatchBehaviour(CT16B0, 2, 0);
	Timer_EnablePWM(CT16B0, 2, true);

	// finally, provide an additional matchvalue to reset the timer to 0 when
	// it reach 65635. Not technically necessary, because the timer's
	// maximum value is 65635 anyway and it would wrap back to 0 by
	// itself.

	Timer_SetMatchValue(CT16B0, 3, 65535);
	Timer_SetMatchBehaviour(CT16B0, 3, TIMER_MATCH_RESET);
	
	// now start the timer!
	Timer_Start(CT16B0);
	
	// There's a `systick` routine below that updates the rainbow
	// animation every 10ms, activate this routine:
	SYSCON_StartSystick_10ms();

}
Exemple #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;
}
Exemple #7
0
// *************** Sensor_EnableCCPTimer ***************
int Sensor_EnableCCPTimer ( PORT_T *port )
{
	Timer_Enable ( (Timer_T)(port->port_number-1) );
	return SENSOR_SUCCESS;
}
Exemple #8
0
/** Sets the requested entry to run.
  This routine adds the entry to the running queue and then decides if it needs
  to start the timer (if it's not running) or alter the timer's clock for a shorter
  period.
  @param timerEntry pointer to the FastTimerEntry to be run. 
  */
int Timer_Set( TimerEntry* timerEntry )
{
  // this could be a lot smarter - for example, modifying the current period?
  if ( !Timer.servicing ) 
    TaskEnterCritical();

  if ( !Timer.running )
  {
    Timer_SetActive( true );
    Timer_SetTimeTarget( timerEntry->timeInitial );
    Timer_Enable();
  }  

  // Calculate how long remaining
  int target = Timer_GetTimeTarget();
  int timeCurrent = Timer_GetTime();
  int remaining = target - timeCurrent;

  // Get the entry ready to roll
  timerEntry->timeCurrent = timerEntry->timeInitial;

  // Add entry
  TimerEntry* first = Timer.first;
  Timer.first = timerEntry;
  timerEntry->next = first;

  // Are we actually servicing an interupt right now?
  if ( !Timer.servicing )
  {
    // No - so does the time requested by this new timer make the time need to come earlier?
    if ( timerEntry->timeCurrent < ( remaining - TIMER_MARGIN ) )
    {
      // Damn it!  Reschedule the next callback
      Timer_SetTimeTarget( target - ( remaining - timerEntry->timeCurrent ));
    }
    else
    {
      // pretend that the existing time has been with us for the whole slice so that when the 
      // IRQ happens it credits the correct (reduced) time.
      timerEntry->timeCurrent += timeCurrent;
    }
  }
  else
  {
    // Yep... we're servicing something right now

    // Make sure the previous pointer is OK.  This comes up if we were servicing the first item
    // and it subsequently wants to delete itself, it would need to alter the next pointer of the 
    // the new head... err... kind of a pain, this
    if ( Timer.previous == NULL )
      Timer.previous = timerEntry;

    // Need to make sure that if this new time is the lowest yet, that the IRQ routine 
    // knows that.  Since we added this entry onto the beginning of the list, the IRQ
    // won't look at it again
    if ( Timer.nextTime == -1 || Timer.nextTime > timerEntry->timeCurrent )
        Timer.nextTime = timerEntry->timeCurrent;
  }

  if ( !Timer.servicing ) 
    TaskExitCritical();

  return CONTROLLER_OK;
}
Exemple #9
0
/**
 * \fn HMI_Setup(const THMISetup * const aHMISetup)
 * \brief Setup HMI system.
 * \param aHMIContext A pointer of HMI configuration structure
 * \return TRUE if HMI is set properly or FALSE when failed
 */
BOOL HMI_Setup(const THMISetup * const aHMISetup) 
{
  UINT16 i = 0, j = 0;
#ifndef NO_INTERRUPT
  TTimerSetup timerCh6;
  
  timerCh6.outputCompare    = bTRUE;
  timerCh6.outputAction     = TIMER_OUTPUT_DISCONNECT;
  timerCh6.inputDetection   = TIMER_INPUT_OFF;
  timerCh6.toggleOnOverflow = bFALSE;
  timerCh6.interruptEnable  = bFALSE;
  timerCh6.pulseAccumulator = bFALSE;
  timerCh6.routine          = &HMIRoutine;
#endif
  if (aHMISetup) 
  {
    if (LCD_Setup())
    {
      HMIContext.renderMode = aHMISetup->renderMode;
      //HMIContext.idlePanelId = aHMISetup->idlePanelId;
      HMIContext.screenFrameBufferPtr = &HMIFrameBuffer[0];
      HMIContext.renderFrameBufferPtr = &HMIFrameBuffer[1];      
      for (j = 0; j < aHMISetup->frameTemplate.height; ++j)
      {
        for (i = 0; i < aHMISetup->frameTemplate.width; ++i)
        {
          HMIContext.frameTemplate.data[j][i] = aHMISetup->frameTemplate.data[j][i];
        }
      }
      HMIContext.frameTemplate.width = aHMISetup->frameTemplate.width;
      HMIContext.frameTemplate.height = aHMISetup->frameTemplate.height;
      
      HMIContext.focusedMenuItemId = 0xFF;
      HMIContext.selectedMenuItemId = 0xFF;
      
      HMIContext.idlePanelId = aHMISetup->idlePanelId;
      HMIContext.idleTimeCount = 0;
      HMIContext.maxIdleTimeCount = aHMISetup->maxIdleTimeCount;
      HMIContext.parentPanelId = 0;
      HMIContext.currentPanelId = 0;
      HMIContext.previousPanelId = 0;
      
      HMIContext.popupPtr = (THMIPopup*)0x00;
      HMIContext.maxPopupTimeCount = 10;
      HMIContext.popupTimeCount = 0;
      
      HMIContext.oldHours = 0;
      HMIContext.oldMinutes = 0;
      HMIContext.oldSeconds = 0;      

      HMIContext.hours = 0;
      HMIContext.minutes = 0;
      HMIContext.seconds = 0;
      
      HMIContext.backlight = aHMISetup->backlight;
      HMIContext.backlightChangedCallback = aHMISetup->backlightChangedCallback;
      HMIContext.contrast = aHMISetup->contrast;
      HMIContext.contrastChangedCallback = aHMISetup->contrastChangedCallback;      
#ifndef NO_INTERRUPT
      HMIRoutinePeriod = (UINT16)(48000); // 2ms
      
      Timer_Init(TIMER_Ch6, &timerCh6);
      Timer_Set(TIMER_Ch6, HMIRoutinePeriod);
      Timer_AttachRoutine(TIMER_Ch6, &HMIRoutine);
      Timer_Enable(TIMER_Ch6, bTRUE);            
#endif
      DDRK = DDRK & (DDRK_BIT0_MASK | DDRK_BIT1_MASK);
      
      UNUSED(LCD_Backlight(aHMISetup->backlight));
      UNUSED(LCD_SetContrast((UINT8)aHMISetup->contrast));
      
      return bTRUE;
    } else {
#ifndef NO_DEBUG
      DEBUG(__LINE__, ERR_LCD_SETUP);
#endif
    }
  }
  else 
  {
    DEBUG(__LINE__, ERR_INVALID_POINTER);
  }
  return bFALSE;
}