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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? class-d.c

?? 最新版IAR FOR ARM(EWARM)5.11中的代碼例子
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// class-d.c - Audio driver for the Class-D amplifier on the EK-LM3S1968.
//
// Copyright (c) 2007 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 microcontroller products.
// 
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  You may not combine
// this software with "viral" open-source software in order to form a larger
// program.  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 1952 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup ek_lm3s1968_api
//! @{
//
//*****************************************************************************

#include "../../hw_ints.h"
#include "../../hw_memmap.h"
#include "../../hw_types.h"
#include "../../src/gpio.h"
#include "../../src/interrupt.h"
#include "../../src/pwm.h"
#include "../../src/sysctl.h"
#include "class-d.h"

//*****************************************************************************
//
// The number of clocks per PWM period.
//
//*****************************************************************************
static unsigned long g_ulClassDPeriod;

//*****************************************************************************
//
// A set of flags indicating the mode of the Class-D audio driver.
//
//*****************************************************************************
static volatile unsigned long g_ulClassDFlags;
#define CLASSD_FLAG_STARTUP     0
#define CLASSD_FLAG_ADPCM       1
#define CLASSD_FLAG_PCM         2

//*****************************************************************************
//
// A pointer to the audio buffer being played.  The validity of this pointer,
// and the expected contents of this buffer, are defined by the flag set in
// g_ulClassDFlags.
//
//*****************************************************************************
static const unsigned char *g_pucClassDBuffer;

//*****************************************************************************
//
// The length of the audio buffer, in bytes.  When performing the startup ramp,
// this is the number of steps left in the ramp.
//
//*****************************************************************************
static unsigned long g_ulClassDLength;

//*****************************************************************************
//
// The volume to playback the audio stream.  This will be a value between 0
// (for silence) and 256 (for full volume).
//
//*****************************************************************************
static long g_lClassDVolume = 256;

//*****************************************************************************
//
// The previous and current audio samples, used for interpolating from 8 KHz
// to 64 KHz audio.
//
//*****************************************************************************
static unsigned short g_pusClassDSamples[2];

//*****************************************************************************
//
// The audio step, which corresponds to the current interpolation point between
// the previous and current audio samples.  The upper bits (that is, 31 through
// 3) are used to determine the sub-sample within a byte of input (for ADPCM
// and DPCM).
//
//*****************************************************************************
static unsigned long g_ulClassDStep;

//*****************************************************************************
//
// The current step index for the ADPCM decoder.  This selects a differential
// value from g_pusADPCMStep.
//
//*****************************************************************************
static long g_lClassDADPCMStepIndex;

//*****************************************************************************
//
// The adjustment to the step index based on the value of an encoded sample.
// The sign bit is ignored when using this table (that is, only the lower three
// bits are used).
//
//*****************************************************************************
static const signed char g_pcADPCMIndex[8] =
{
    -1, -1, -1, -1, 2, 4, 6, 8
};

//*****************************************************************************
//
// The differential values for the ADPCM decoder.  One of these is selected
// based on the step index.
//
//*****************************************************************************
static const unsigned short g_pusADPCMStep[89] =
{
    7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41,
    45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209,
    230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876,
    963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749,
    3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
    9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623,
    27086, 29794, 32767
};

//*****************************************************************************
//
//! Handles the PWM1 interrupt.
//!
//! This function responds to the PWM1 interrupt, updating the duty cycle of
//! the output waveform in order to produce sound.  It is the application's
//! responsibility to ensure that this function is called in response to the
//! PWM1 interrupt, typically by installing it in the vector table as the
//! handler for the PWM1 interrupt.
//!
//! This function is contained in <tt>class-d.c</tt>, with <tt>class-d.h</tt>
//! containing the API definition for use by applications.
//!
//! \return None.
//
//*****************************************************************************
void
ClassDPWMHandler(void)
{
    long lStep, lNibble, lDutyCycle;

    //
    // Clear the PWM interrupt.
    //
    PWMGenIntClear(PWM_BASE, PWM_GEN_1, PWM_INT_CNT_ZERO);

    //
    // See if the startup ramp is in progress.
    //
    if(HWREGBITW(&g_ulClassDFlags, CLASSD_FLAG_STARTUP))
    {
        //
        // Decrement the ramp count.
        //
        g_ulClassDLength--;

        //
        // Increase the pulse width of the two outputs by one clock.
        //
        PWMDeadBandEnable(PWM_BASE, PWM_GEN_1, 0, g_ulClassDLength);
        PWMPulseWidthSet(PWM_BASE, PWM_OUT_2,
                         (g_ulClassDPeriod - g_ulClassDLength) / 2);

        //
        // See if this was the last step of the ramp.
        //
        if(g_ulClassDLength == 0)
        {
            //
            // Indicate that the startup ramp has completed.
            //
            HWREGBITW(&g_ulClassDFlags, CLASSD_FLAG_STARTUP) = 0;
        }

        //
        // There is nothing further to be done.
        //
        return;
    }

    //
    // See if there is any audio playing.
    //
    if(g_ulClassDFlags == 0)
    {
        //
        // Set the duty cycle to 50%, producing silence.
        //
        PWMPulseWidthSet(PWM_BASE, PWM_OUT_2, g_ulClassDPeriod / 2);

        //
        // There is nothing further to be done.
        //
        return;
    }

    //
    // Compute the value of the PCM sample based on the blended average of the
    // previous and current samples.  It should be noted that linear
    // interpolation does not produce the best results with audio (it produces
    // a significant amount of harmonic aliasing) but it is fast.
    //
    lDutyCycle = (((g_pusClassDSamples[0] * (8 - (g_ulClassDStep & 7))) +
                   (g_pusClassDSamples[1] * (g_ulClassDStep & 7))) / 8);

    //
    // Adjust the magnitude of the sample based on the current volume.  Since a
    // multiplicative volume control is implemented, the volume value will
    // result in nearly linear volume adjustment if it is squared.
    //
    lDutyCycle = (((lDutyCycle - 32768) * g_lClassDVolume * g_lClassDVolume) /
                  65536) + 32768;

    //
    // Set the PWM duty cycle based on this PCM sample.
    //
    lDutyCycle = (g_ulClassDPeriod * lDutyCycle) / 65536;
    if(lDutyCycle > (g_ulClassDPeriod - 2))
    {
        lDutyCycle = g_ulClassDPeriod - 2;
    }
    if(lDutyCycle < 2)
    {
        lDutyCycle = 2;
    }
    PWMPulseWidthSet(PWM_BASE, PWM_OUT_2, lDutyCycle);

    //
    // Increment the audio step.
    //
    g_ulClassDStep++;

    //
    // See if the next sample has been reached.
    //
    if((g_ulClassDStep & 7) == 0)
    {
        //
        // Copy the current sample to the previous sample.
        //
        g_pusClassDSamples[0] = g_pusClassDSamples[1];

        //
        // See if there is more input data.
        //
        if(g_ulClassDLength == 0)
        {
            //
            // All input data has been played, so indicate that playback has
            // completed.
            //
            g_ulClassDFlags = 0;
        }

        //
        // See if an ADPCM stream is being played.
        //
        else if(HWREGBITW(&g_ulClassDFlags, CLASSD_FLAG_ADPCM))
        {
            //
            // See which nibble should be decoded.
            //
            if((g_ulClassDStep & 8) == 0)
            {
                //
                // Extract the lower nibble from the current byte, and skip to
                // the next byte.
                //
                lNibble = *g_pucClassDBuffer++;

                //
                // Decrement the count of bytes to be decoded.
                //
                g_ulClassDLength--;
            }
            else
            {
                //
                // Extract the upper nibble from the current byte.
                //
                lNibble = *g_pucClassDBuffer >> 4;
            }

            //
            // Compute the sample delta based on the current nibble and step
            // size.
            //
            lStep = ((((2 * (lNibble & 7)) + 1) *
                      g_pusADPCMStep[g_lClassDADPCMStepIndex]) / 16);

            //
            // Add or subtract the delta to the previous sample value, clipping
            // if necessary.
            //
            if(lNibble & 8)
            {
                lStep = g_pusClassDSamples[0] - lStep;
                if(lStep < 0)
                {
                    lStep = 0;
                }
            }
            else
            {
                lStep = g_pusClassDSamples[0] + lStep;
                if(lStep > 65535)
                {
                    lStep = 65535;
                }
            }

            //
            // Store the generated sample.
            //
            g_pusClassDSamples[1] = lStep;

            //
            // Adjust the step size index based on the current nibble, clipping
            // the value if required.
            //
            g_lClassDADPCMStepIndex += g_pcADPCMIndex[lNibble & 7];
            if(g_lClassDADPCMStepIndex < 0)
            {
                g_lClassDADPCMStepIndex = 0;
            }
            if(g_lClassDADPCMStepIndex > 88)
            {
                g_lClassDADPCMStepIndex = 88;
            }
        }

        //
        // See if a 8-bit PCM stream is being played.
        //
        else if(HWREGBITW(&g_ulClassDFlags, CLASSD_FLAG_PCM))
        {
            //
            // Read the next sample from the input stream.
            //
            g_pusClassDSamples[1] = *g_pucClassDBuffer++ * 256;

            //
            // Decrement the count of samples to be played.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本人妖一区二区| 日日夜夜一区二区| 国产亚洲欧美中文| 久久久精品国产99久久精品芒果 | 91麻豆精品国产91久久久久久 | 国产一区二区三区香蕉| 紧缚捆绑精品一区二区| 美女脱光内衣内裤视频久久网站 | 国产精品无码永久免费888| 久久精品在线观看| 国产精品看片你懂得| 综合激情成人伊人| 亚洲一区二区三区影院| 亚洲777理论| 日本在线观看不卡视频| 国内外成人在线视频| 国产不卡在线视频| 91视频在线看| 欧美一二三区在线| 亚洲国产精品二十页| 亚洲精品国产精品乱码不99| 午夜久久久久久久久| 精品一区免费av| av亚洲精华国产精华精华| 欧美日韩精品免费| 国产亚洲福利社区一区| 亚洲欧美日韩在线| 老司机精品视频在线| 成人黄色777网| 欧美久久久一区| 久久精品视频在线看| 亚洲午夜久久久久久久久电影网| 男女男精品视频网| 99综合影院在线| 欧美一级理论性理论a| 国产精品久久久久四虎| 琪琪一区二区三区| 91福利视频网站| 国产欧美一区二区精品性| 午夜av一区二区| 成人免费视频播放| 欧美大片免费久久精品三p| 亚洲女人小视频在线观看| 久久国产精品区| 欧美午夜理伦三级在线观看| 国产精品女同互慰在线看| 免费成人在线视频观看| 色嗨嗨av一区二区三区| 中文在线资源观看网站视频免费不卡| 舔着乳尖日韩一区| 色国产综合视频| 国产精品国产三级国产a| 蜜桃av一区二区在线观看| 欧美一a一片一级一片| 中文字幕一区免费在线观看| 国产美女在线观看一区| 日韩欧美国产麻豆| 亚洲成人中文在线| 日本久久精品电影| 亚洲欧美另类久久久精品2019| 国产成人午夜精品影院观看视频| 91精品国产综合久久国产大片| 亚洲免费观看视频| 91丨porny丨蝌蚪视频| 中文字幕在线不卡一区| 成人一级片网址| 日本一区二区久久| 成人黄色777网| 国产精品久久久久久久久免费樱桃 | 国产一二三精品| 精品国免费一区二区三区| 日韩高清欧美激情| 日韩一区二区三区在线视频| 日韩精品亚洲专区| 日韩欧美在线观看一区二区三区| 日韩在线观看一区二区| 欧美一级片在线看| 国内精品国产成人| 日本一区二区三区国色天香| 国产美女av一区二区三区| 国产日韩亚洲欧美综合| 成人免费av在线| 亚洲美女淫视频| 欧美日韩免费观看一区二区三区 | 麻豆91免费观看| 欧美精品一区二区久久久| 国产精品一线二线三线精华| 久久久久久久久免费| 成人av电影在线观看| 亚洲综合偷拍欧美一区色| 欧美三级电影在线看| 蜜桃视频第一区免费观看| 国产清纯白嫩初高生在线观看91| 成人国产精品免费网站| 一区二区三区国产| 欧美一区二区三区免费| 国产精品夜夜嗨| 一区二区三区在线高清| 欧美一区二区黄| 成人理论电影网| 亚洲成人黄色小说| 精品国产一区久久| 91美女精品福利| 精品中文av资源站在线观看| 中文字幕第一区| 欧美伦理电影网| 盗摄精品av一区二区三区| 亚洲一区国产视频| 欧美精品一区二区久久婷婷| 成人av网址在线观看| 奇米色一区二区| 亚洲精品视频观看| 久久精品视频免费| 91精品国产色综合久久不卡电影| 成人av网站在线| 另类的小说在线视频另类成人小视频在线| 国产精品欧美极品| 日韩欧美一级精品久久| 亚洲精品久久久蜜桃| 国产乱码精品一区二区三区av| 精品国产乱码久久久久久影片| 成人黄色软件下载| 久久超碰97中文字幕| 综合久久久久久久| 久久精品人人爽人人爽| 4438x成人网最大色成网站| 97se亚洲国产综合自在线不卡| 奇米在线7777在线精品| 亚洲精品乱码久久久久久久久| 欧美精品一区二| 欧美一区二区国产| 91麻豆精品一区二区三区| 国产黄色精品网站| 久久精品国产99久久6| 亚洲电影在线播放| 一区二区三区.www| 国产精品国产馆在线真实露脸| xnxx国产精品| 2023国产精华国产精品| 9191久久久久久久久久久| 91精品1区2区| 一本到三区不卡视频| 色哟哟欧美精品| 不卡视频在线看| 99久久婷婷国产综合精品电影| 国产mv日韩mv欧美| 国产电影精品久久禁18| 国产成人精品在线看| 成人深夜在线观看| 丁香婷婷综合五月| 波多野结衣中文一区| 91性感美女视频| 色婷婷亚洲精品| 欧美三级电影网| 欧美一区二区视频观看视频| 337p亚洲精品色噜噜噜| 678五月天丁香亚洲综合网| 在线观看91av| 欧美成人猛片aaaaaaa| 精品国产一区二区三区久久久蜜月| 欧美大片顶级少妇| 久久午夜电影网| 亚洲欧美日韩国产综合在线| 亚洲精品高清在线| 亚洲第一会所有码转帖| 欧美aⅴ一区二区三区视频| 久久se这里有精品| 成人免费视频网站在线观看| 色八戒一区二区三区| 91精品国产色综合久久不卡蜜臀 | 国产99久久久国产精品潘金 | 欧美一区二区三区在线观看视频| 欧美一级一区二区| 久久精品水蜜桃av综合天堂| 国产精品美女久久久久久2018| 亚洲精选免费视频| 久久91精品国产91久久小草| 丰满白嫩尤物一区二区| 欧洲精品在线观看| 日韩免费福利电影在线观看| 亚洲精品在线三区| 亚洲精品日产精品乱码不卡| 青青草伊人久久| 91在线观看地址| 欧美sm美女调教| 亚洲欧美二区三区| 麻豆国产精品一区二区三区 | 免费成人在线视频观看| 国产白丝精品91爽爽久久 | 2020国产精品| 亚洲在线一区二区三区| 狠狠色狠狠色综合日日91app| 成人h动漫精品一区二| 欧美精品在线一区二区三区| 中文字幕国产精品一区二区| 日本欧美韩国一区三区| 91视频国产资源| 26uuu国产在线精品一区二区| 亚洲一区二区三区四区在线| 粉嫩13p一区二区三区|