⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bspgpt.c

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 C
字号:
//------------------------------------------------------------------------------
//
// Copyright (C) 2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//
//  File:  bspgpt.c
//
//  Provides BSP-specific configuration routines for the GPT peripheral.
//
//------------------------------------------------------------------------------
#include <windows.h>
#include "gpt_priv.h"
#include "bsp.h"

//------------------------------------------------------------------------------
// External Functions


//------------------------------------------------------------------------------
// External Variables


//------------------------------------------------------------------------------
// Defines
#define GPT_CLKSRC_FREQ     BSP_CLK_CKIH_FREQ
#define TICKS_PER_US        (GPT_CLKSRC_FREQ/1000000)  // ticks per microsecond

// low frequency clock currently used as GPT will
// not work with high frequency clock
//#define GPT_CLKSRC_VAL      GPT_CR_CLKSRC_CLK32K  // use low freq
#define GPT_CLKSRC_VAL      GPT_CR_CLKSRC_HIGHFREQ  // use high freq


//------------------------------------------------------------------------------
// Types


//------------------------------------------------------------------------------
// Global Variables


//------------------------------------------------------------------------------
// Local Variables

//------------------------------------------------------------------------------
// Local Functions

//------------------------------------------------------------------------------
//
// Function: BSPGptGetClockSource
//
// This function returns the BSP-specific clock
// source selection value for the GPT.
//
// Parameters:
//      None
//
// Returns:
//      The clock source for the GPT.
//
//------------------------------------------------------------------------------
UINT32 BSPGptGetClockSource()
{
    return GPT_CLKSRC_VAL;
}

//------------------------------------------------------------------------------
//
// Function: BSPCalculateCompareVal
//
// This function computes the tick value that should go
// into the GPT output compare register to achieve
// a requested timer delay period.
//
// Parameters:
//      period
//          [in] The desired timer delay period, in microseconds.
//
// Returns:
//      The value to go into the GPT output compare register.
//
//------------------------------------------------------------------------------
UINT32 BSPGptCalculateCompareVal(UINT32 period)
{
    return period * TICKS_PER_US;
}

//------------------------------------------------------------------------------
//
// Function: BSPGptCrmSetClockGatingMode
//
// This function calls to the CRM module to
// set the clock gating mode, turning on or off
// clocks to the GPT.
//
// Parameters:
//      startClocks
//          [in] If TRUE, turn clocks to GPT on.
//                If FALSE, turn clocks to GPT off
//
// Returns:
//      TRUE if success.
//      FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL BSPGptSetClockGatingMode(BOOL startClocks)
{
    if (startClocks)
    {
        // Turn GPT clocks on
        if (!DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_GPT, 
            DDK_CLOCK_GATE_MODE_ENABLED_ALL))
        {
            DEBUGMSG(ZONE_ERROR, (TEXT("%s: Failed to set CRM clock gating mode!\r\n"), __WFUNCTION__));
            return FALSE;
        }
    }
    else
    {
        // Turn GPT clocks off
        if (!DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_GPT, 
            DDK_CLOCK_GATE_MODE_DISABLED))
        {
            DEBUGMSG(ZONE_ERROR, (TEXT("%s: Failed to set CRM clock gating mode!\r\n"), __WFUNCTION__));
            return FALSE;
        }
    }

    return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -