亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? pwm.c

?? 基于 Cortex-M3 (ARM) 內(nèi)核使用之 uC/OS-II 作業(yè)系統(tǒng),此例程可移植于 Cortex-M3 (ARM)內(nèi)核的微處理器上的應(yīng)用,于 Keil MDK 3.15b以上 工程編譯,而
?? C
?? 第 1 頁 / 共 3 頁
字號:
//*****************************************************************************
//
// pwm.c - API for the PWM modules
//
// Copyright (c) 2005,2006 Luminary Micro, Inc.  All rights reserved.
//
// Software License Agreement
//
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's Stellaris Family of microcontroller products.
//
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  Any use in violation
// of the foregoing restrictions may subject the user to criminal sanctions
// under applicable laws, as well as to civil liability for the breach of the
// terms and conditions of this license.
//
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 852 of the Stellaris Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup pwm_api
//! @{
//
//*****************************************************************************

#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_pwm.h"
#include "hw_types.h"
#include "debug.h"
#include "interrupt.h"
#include "pwm.h"

//*****************************************************************************
//
// Misc macros for manipulating the encoded generator and output defines used
// by the API.
//
//*****************************************************************************
#define PWM_GEN_BADDR(_mod_, _gen_)                                           \
                                ((_mod_) + (_gen_))
#define PWM_OUT_BADDR(_mod_, _out_)                                           \
                                ((_mod_) + ((_out_) & 0xFFFFFFC0))
#define PWM_IS_OUTPUT_ODD(_out_)                                              \
                                ((_out_) & 0x00000001)

//*****************************************************************************
//
//! Configures a PWM generator.
//!
//! \param ulBase is the base address of the PWM module.
//! \param ulGen is the PWM generator to configure.  Must be one of
//! \b PWM_GEN_0, \b PWM_GEN_1, or \b PWM_GEN_2.
//! \param ulConfig is the configuration for the PWM generator.
//!
//! This function is used to set the mode of operation for a PWM generator.
//! The counting mode, synchronization mode, and debug behavior are all
//! configured.  After configuration, the generator is left in the disabled
//! state.
//!
//! A PWM generator can count in two different modes:  count down mode or count
//! up/down mode.  In count down mode, it will count from a value down to zero,
//! and then reset to the preset value.  This will produce left-aligned PWM
//! signals (i.e. the rising edge of the two PWM signals produced by the
//! generator will occur at the same time).  In count up/down mode, it will
//! count up from zero to the preset value, count back down to zero, and then
//! repeat the process.  This will produce center-aligned PWM signals (i.e. the
//! middle of the high/low period of the PWM signals produced by the generator
//! will occur at the same time).
//!
//! When the PWM generator parameters (period and pulse width) are modified,
//! their affect on the output PWM signals can be delayed.  In synchronous
//! mode, the parameter updates are not applied until a synchronization event
//! occurs.  This allows multiple parameters to be modified and take affect
//! simultaneously, instead of one at a time.  Additionally, parameters to
//! multiple PWM generators in synchronous mode can be updated simultaneously,
//! allowing them to be treated as if they were a unified generator.  In
//! non-synchronous mode, the parameter updates are not delayed until a
//! synchronization event.  In either mode, the parameter updates only occur
//! when the counter is at zero to help prevent oddly formed PWM signals during
//! the update (i.e. a PWM pulse that is too short or too long).
//!
//! The PWM generator can either pause or continue running when the processor
//! is stopped via the debugger.  If configured to pause, it will continue to
//! count until it reaches zero, at which point it will pause until the
//! processor is restarted.  If configured to continue running, it will keep
//! counting as if nothing had happened.
//!
//! The \b ulConfig parameter contains the desired configuration.  It is the
//! logical OR of the following: \b PWM_GEN_MODE_DOWN or
//! \b PWM_GEN_MODE_UP_DOWN to specify the counting mode, \b PWM_GEN_MODE_SYNC
//! or \b PWM_GEN_MODE_NO_SYNC to specify the synchronization mode, and
//! \b PWM_GEN_MODE_DBG_RUN or \b PWM_GEN_MODE_DBG_STOP to specify the debug
//! behavior.
//!
//! \note Changes to the counter mode will affect the period of the PWM signals
//! produced.  PWMGenPeriodSet() and PWMPulseWidthSet() should be called after
//! any changes to the counter mode of a generator.
//!
//! \return None.
//
//*****************************************************************************
void
PWMGenConfigure(unsigned long ulBase, unsigned long ulGen,
                unsigned long ulConfig)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == PWM_BASE);
    ASSERT((ulGen == PWM_GEN_0) || (ulGen == PWM_GEN_1) ||
           (ulGen == PWM_GEN_2));

    //
    // Compute the generator's base address.
    //
    ulGen = PWM_GEN_BADDR(ulBase, ulGen);

    //
    // Change the global configuration of the generator.
    //
    HWREG(ulGen + PWM_O_X_CTL) = ((HWREG(ulGen + PWM_O_X_CTL) &
                                   ~(PWM_X_CTL_MODE | PWM_X_CTL_DEBUG |
                                     PWM_X_CTL_LOADUPD | PWM_X_CTL_CMPAUPD |
                                     PWM_X_CTL_CMPBUPD)) | ulConfig);

    //
    // Set the individual PWM generator controls.
    //
    if(ulConfig & PWM_X_CTL_MODE)
    {
        //
        // In up/down count mode, set the signal high on up count comparison
        // and low on down count comparison (i.e. center align the signals).
        //
        HWREG(ulGen + PWM_O_X_GENA) = ((PWM_GEN_ACT_ONE <<
                                        PWM_GEN_ACT_A_UP_SHIFT) |
                                       (PWM_GEN_ACT_ZERO <<
                                        PWM_GEN_ACT_A_DN_SHIFT));
        HWREG(ulGen + PWM_O_X_GENB) = ((PWM_GEN_ACT_ONE <<
                                        PWM_GEN_ACT_B_UP_SHIFT) |
                                       (PWM_GEN_ACT_ZERO <<
                                        PWM_GEN_ACT_B_DN_SHIFT));
    }
    else
    {
        //
        // In down count mode, set the signal high on load and low on count
        // comparison (i.e. left align the signals).
        //
        HWREG(ulGen + PWM_O_X_GENA) = ((PWM_GEN_ACT_ONE <<
                                        PWM_GEN_ACT_LOAD_SHIFT) |
                                       (PWM_GEN_ACT_ZERO <<
                                        PWM_GEN_ACT_A_DN_SHIFT));
        HWREG(ulGen + PWM_O_X_GENB) = ((PWM_GEN_ACT_ONE <<
                                        PWM_GEN_ACT_LOAD_SHIFT) |
                                       (PWM_GEN_ACT_ZERO <<
                                        PWM_GEN_ACT_B_DN_SHIFT));
    }
}

//*****************************************************************************
//
//! Set the period of a PWM generator.
//!
//! \param ulBase is the base address of the PWM module.
//! \param ulGen is the PWM generator to be modified.  Must be one of
//! \b PWM_GEN_0, \b PWM_GEN_1, or \b PWM_GEN_2.
//! \param ulPeriod specifies the period of PWM generator output, measured
//! in clock ticks.
//!
//! This function sets the period of the specified PWM generator block, where
//! the period of the generator block is defined as the number of \b PWM 
//! clock ticks between pulses on the generator block \b zero signal.
//!
//! \note Any subsequent calls made to this function before an update occurs
//! will cause the previous values to be overwritten.
//!
//! \return None.
//
//*****************************************************************************
void
PWMGenPeriodSet(unsigned long ulBase, unsigned long ulGen,
                unsigned long ulPeriod)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == PWM_BASE);
    ASSERT((ulGen == PWM_GEN_0) || (ulGen == PWM_GEN_1) ||
           (ulGen == PWM_GEN_2));

    //
    // Compute the generator's base address.
    //
    ulGen = PWM_GEN_BADDR(ulBase, ulGen);

    //
    // Set the reload register based on the mode.
    //
    if(HWREG(ulGen + PWM_O_X_CTL) & PWM_X_CTL_MODE)
    {
        //
        // In up/down count mode, set the reload register to half the requested
        // period.
        //
        ASSERT((ulPeriod / 2) < 65536);
        HWREG(ulGen + PWM_O_X_LOAD) = ulPeriod / 2;
    }
    else
    {
        //
        // In down count mode, set the reload register to the requested period
        // minus one.
        //
        ASSERT((ulPeriod <= 65536) && (ulPeriod != 0));
        HWREG(ulGen + PWM_O_X_LOAD) = ulPeriod - 1;
    }
}

//*****************************************************************************
//
//! Gets the period of a PWM generator block.
//!
//! \param ulBase is the base address of the PWM module.
//! \param ulGen is the PWM generator to query.  Must be one of
//! \b PWM_GEN_0, \b PWM_GEN_1, or \b PWM_GEN_2.
//!
//! This function gets the period of the specified PWM generator block.  The
//! period of the generator block is defined as the number of \b PWM clock
//! ticks between pulses on the generator block \b zero signal.
//!
//! If the update of the counter for the specified PWM generator has yet
//! to be completed, the value returned may not be the active period.  The
//! value returned is the programmed period, measured in \b PWM clock ticks.
//!
//! \return Returns the programmed period of the specified generator block
//! in \b PWM clock ticks.
//
//*****************************************************************************
unsigned long
PWMGenPeriodGet(unsigned long ulBase, unsigned long ulGen)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == PWM_BASE);
    ASSERT((ulGen == PWM_GEN_0) || (ulGen == PWM_GEN_1) ||
           (ulGen == PWM_GEN_2));

    //
    // Compute the generator's base address.
    //
    ulGen = PWM_GEN_BADDR(ulBase, ulGen);

    //
    // Figure out the counter mode.
    //
    if(HWREG(ulGen + PWM_O_X_CTL) & PWM_X_CTL_MODE)
    {
        //
        // The period is twice the reload register value.
        //
        return(HWREG(ulGen + PWM_O_X_LOAD) * 2);
    }
    else
    {
        //
        // The period is the reload register value plus one.
        //
        return(HWREG(ulGen + PWM_O_X_LOAD) + 1);
    }
}

//*****************************************************************************
//
//! Enables the timer/counter for a PWM generator block.
//!
//! \param ulBase is the base address of the PWM module.
//! \param ulGen is the PWM generator to be enabled.  Must be one of
//! \b PWM_GEN_0, \b PWM_GEN_1, or \b PWM_GEN_2.
//!
//! This function allows the \b PWM clock to drive the timer/counter for the
//! specified generator block.
//!
//! \return None.
//
//*****************************************************************************
void
PWMGenEnable(unsigned long ulBase, unsigned long ulGen)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == PWM_BASE);
    ASSERT((ulGen == PWM_GEN_0) || (ulGen == PWM_GEN_1) ||
           (ulGen == PWM_GEN_2));

    //
    // Enable the PWM generator.
    //
    HWREG(PWM_GEN_BADDR(ulBase, ulGen) + PWM_O_X_CTL) |= PWM_X_CTL_ENABLE;
}

//*****************************************************************************
//
//! Disables the timer/counter for a PWM generator block.
//!
//! \param ulBase is the base address of the PWM module.
//! \param ulGen is the PWM generator to be disabled.  Must be one of
//! \b PWM_GEN_0, \b PWM_GEN_1, or \b PWM_GEN_2.
//!
//! This function blocks the \b PWM clock from driving the timer/counter for 
//! the specified generator block.
//!
//! \return None.
//
//*****************************************************************************
void
PWMGenDisable(unsigned long ulBase, unsigned long ulGen)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == PWM_BASE);
    ASSERT((ulGen == PWM_GEN_0) || (ulGen == PWM_GEN_1) ||
           (ulGen == PWM_GEN_2));

    //
    // Disable the PWM generator.
    //
    HWREG(PWM_GEN_BADDR(ulBase, + ulGen) + PWM_O_X_CTL) &= ~(PWM_X_CTL_ENABLE);
}

//*****************************************************************************
//
//! Sets the pulse width for the specified PWM output.
//!
//! \param ulBase is the base address of the PWM module.
//! \param ulPWMOut is the PWM output to modify.  Must be one of \b PWM_OUT_0,
//! \b PWM_OUT_1, \b PWM_OUT_2, \b PWM_OUT_3, \b PWM_OUT_4, or \b PWM_OUT_5.
//! \param ulWidth specifies the width of the positive portion of the pulse.
//!
//! This function sets the pulse width for the specified PWM output, where the
//! pulse width is defined as the number of \b PWM clock ticks.
//!
//! \note Any subsequent calls made to this function before an update occurs
//! will cause the previous values to be overwritten.
//!
//! \return None.
//
//*****************************************************************************
void
PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut,
                 unsigned long ulWidth)
{
    unsigned long ulGenBase, ulReg;

    //
    // Check the arguments.
    //
    ASSERT(ulBase == PWM_BASE);
    ASSERT((ulPWMOut == PWM_OUT_0) || (ulPWMOut == PWM_OUT_1) ||
           (ulPWMOut == PWM_OUT_2) || (ulPWMOut == PWM_OUT_3) ||
           (ulPWMOut == PWM_OUT_4) || (ulPWMOut == PWM_OUT_5));

    //
    // Compute the generator's base address.
    //
    ulGenBase = PWM_OUT_BADDR(ulBase, ulPWMOut);

    //
    // If the counter is in up/down count mode, divide the width by two.
    //
    if(HWREG(ulGenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
    {
        ulWidth /= 2;
    }

    //
    // Get the period.
    //
    ulReg = HWREG(ulGenBase + PWM_O_X_LOAD);

    //
    // Make sure the width is not too large.
    //
    ASSERT(ulWidth < ulReg);

    //
    // Compute the compare value.
    //
    ulReg = ulReg - ulWidth;

    //
    // Write to the appropriate registers.
    //
    if(PWM_IS_OUTPUT_ODD(ulPWMOut))
    {
        HWREG(ulGenBase + PWM_O_X_CMPB) = ulReg;
    }
    else
    {
        HWREG(ulGenBase + PWM_O_X_CMPA) = ulReg;
    }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本道免费精品一区二区三区| 亚洲在线观看免费视频| 91啪亚洲精品| 99久久久免费精品国产一区二区| 久久精品久久久精品美女| 中文字幕在线播放不卡一区| 中文字幕一区二区三区av| 国产情人综合久久777777| 久久久久亚洲综合| 欧美国产精品久久| 日韩美女视频19| 亚洲午夜电影在线观看| 亚洲精品视频在线观看网站| 亚洲综合网站在线观看| 五月婷婷激情综合| 极品销魂美女一区二区三区| 国产高清成人在线| 色婷婷国产精品综合在线观看| 不卡欧美aaaaa| 99re热视频这里只精品| 欧美在线免费视屏| 6080国产精品一区二区| 日韩欧美国产午夜精品| 日本一二三四高清不卡| 一区二区三区精品在线观看| 男男视频亚洲欧美| 成人h动漫精品一区二区| 欧美性生活大片视频| 欧美精品一区二区精品网| 中文字幕第一区第二区| 午夜精品国产更新| 国产99久久久国产精品免费看| 91偷拍与自偷拍精品| 欧美一区二区三区免费观看视频| 久久久99久久| 亚洲成人精品一区| 国产aⅴ综合色| 538在线一区二区精品国产| 亚洲国产激情av| 偷拍一区二区三区| 99re6这里只有精品视频在线观看| 欧美日韩色综合| 久久综合成人精品亚洲另类欧美 | 欧美美女bb生活片| 精品久久久久久久人人人人传媒 | 久久国产精品99精品国产| 国产91在线观看丝袜| 欧美男同性恋视频网站| 久久综合av免费| 亚洲精品久久久久久国产精华液| 国产美女一区二区三区| 欧美日本国产视频| 国产精品久久777777| 精品一区二区三区不卡| 欧美视频一区二| 国产免费成人在线视频| 久久福利资源站| 91激情五月电影| 国产精品视频线看| 国内精品写真在线观看| 欧美裸体bbwbbwbbw| 亚洲日本欧美天堂| 99精品热视频| 亚洲国产精品激情在线观看| 国内精品国产成人国产三级粉色 | 五月婷婷久久综合| 成人av资源在线| 欧美v日韩v国产v| 亚洲在线免费播放| 色悠悠久久综合| 国产精品伦一区二区三级视频| 亚洲成av人片在线观看| 成人精品高清在线| www国产亚洲精品久久麻豆| 视频一区二区三区在线| 欧美精品一级二级| 日韩国产高清在线| 色偷偷成人一区二区三区91 | 另类综合日韩欧美亚洲| 色老汉av一区二区三区| 日本一区二区三区电影| 韩国v欧美v日本v亚洲v| 精品久久久久久久久久久久久久久| 亚洲综合精品自拍| 不卡一区二区在线| 国产精品麻豆一区二区| www.亚洲免费av| 日韩久久一区二区| 欧美久久久一区| 三级精品在线观看| 日韩欧美国产成人一区二区| 三级一区在线视频先锋| 日韩精品一区二区在线观看| 美女一区二区三区在线观看| 久久亚洲免费视频| 风间由美一区二区av101 | 亚洲激情欧美激情| 欧美中文字幕久久| 日日夜夜精品视频天天综合网| 欧美三级欧美一级| 激情综合色丁香一区二区| 久久久久久久久99精品| 9l国产精品久久久久麻豆| 一区二区不卡在线播放| 日韩一二三区不卡| 高清久久久久久| 亚洲第一主播视频| 久久久亚洲午夜电影| 色88888久久久久久影院野外| 亚洲午夜久久久久久久久久久 | 色天天综合久久久久综合片| 亚洲综合成人网| 精品嫩草影院久久| 91在线视频18| 精品一区二区三区在线观看| 日韩码欧中文字| 日韩欧美一区在线| 色欧美乱欧美15图片| 久久99精品久久久| 亚洲综合偷拍欧美一区色| 精品裸体舞一区二区三区| 99re这里只有精品视频首页| 视频在线在亚洲| 久久精子c满五个校花| 91美女精品福利| 国产盗摄女厕一区二区三区| 天堂精品中文字幕在线| 亚洲情趣在线观看| 久久久精品国产免费观看同学| 91成人国产精品| 国产成a人无v码亚洲福利| 亚洲自拍偷拍av| 亚洲欧洲日产国码二区| 欧美精品一区男女天堂| 欧美性色综合网| www.在线欧美| 国产成人在线免费观看| 日本aⅴ精品一区二区三区| 亚洲欧洲一区二区在线播放| 精品国产乱码久久久久久影片| 日本国产一区二区| 99这里只有精品| 懂色av一区二区三区免费看| 五月天视频一区| 一区二区理论电影在线观看| 国产精品久久久久久久裸模| 91精品国产91久久久久久最新毛片 | 日韩美女啊v在线免费观看| 精品免费国产二区三区| 91精品国产一区二区| 欧美欧美欧美欧美首页| 欧美怡红院视频| 欧美性生交片4| 欧美色手机在线观看| 一本色道久久综合精品竹菊| 成人小视频免费观看| 成人免费视频免费观看| 成人h动漫精品一区二区| 国产精品自拍三区| 国产一区二区电影| 国产大片一区二区| 成人精品鲁一区一区二区| 国产成人在线视频网站| 成人精品一区二区三区四区| 成人小视频免费观看| 99这里只有久久精品视频| 色婷婷综合久久久久中文 | 开心九九激情九九欧美日韩精美视频电影| 亚洲一区自拍偷拍| 亚洲国产精品一区二区www| 亚洲最快最全在线视频| 亚洲国产综合色| 一区二区三区在线影院| 无吗不卡中文字幕| 一区二区高清在线| 日本成人在线看| 激情综合色播激情啊| 成人免费毛片app| 色婷婷一区二区三区四区| 欧美日韩一区中文字幕| 欧美成人午夜电影| 国产精品色哟哟| 亚洲综合视频在线观看| 免费观看在线色综合| 播五月开心婷婷综合| 欧美午夜理伦三级在线观看| 日韩免费在线观看| 国产精品久久久久影院老司| 亚洲精品你懂的| 奇米四色…亚洲| 成人国产免费视频| 欧美午夜电影在线播放| 久久婷婷色综合| 亚洲男人的天堂在线观看| 免费在线观看视频一区| 91在线免费看| 久久色在线视频| 亚洲一级二级三级在线免费观看| 久久aⅴ国产欧美74aaa| 色综合天天综合在线视频|