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

📄 amf_ledcontrol_21369.c

📁 ADI SHARC DSP 音频算法标准模块库
💻 C
字号:
// Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
// This software is proprietary and confidential to Analog Devices, Inc. and its licensors.

// File    : $Id: //depot/Development/VisualAudio/Modules/Packs/ButtonsAndLEDs_EZKit/2.5.0/SHARC/Source/AMF_LEDControl_21369.c#2 $ 
// Part of : VisualAudio ButtonsAndLEDs_EZKit V2.0.1 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $



#include "AMF_LEDControl_21369.h"
#include <math.h>
#include <sysreg.h>
#include "processor.h"


#if __VERSIONNUM__ >= 0x07010000  //VDSP++4.0
#if defined(__ADSP21367__) || defined(__ADSP21368__) || defined(__ADSP21369__)
#include <sru21369.h>
#include <cdef21364.h>
#else
#error "Wrong processor."
#endif
#endif

#if __VERSIONNUM__ >= 0x07000000 && __VERSIONNUM__ < 0x07010000 // VDSP++ 3.5 
#include <sru.h> 
#endif


/** Read a named integer port. */
#define RDPORT(name)    (*(const int*)(name))

SEG_MOD_FAST_CODE  void AMF_LEDControl_Render_21369(AMF_LEDControl_21369 * restrict instance,float * restrict * buffers,int tickSize) 
{
/***
    Design spec:
        The LED state is scanned every time the render function is called.
        The first 2 LEDs are connected to the flag pins and the rest of
        2 LEDs are hookup to the processor via the digital interface
        LED8 can not be used if the SDRAM is enabled which is true by default
        in the VA platforms. Hence, this module does not support LED 8.
***/    
    
    
    int i;
    float *pLED1Input = buffers[0];
    float *pLED2Input = buffers[1];
    float *pLED3Input = buffers[2];
    float *pLED4Input = buffers[3];
    float *pLED5Input = buffers[4];
    float *pLED6Input = buffers[5];
    float *pLED7Input = buffers[6];
    int ledValue = 0;

    //The initialization is required only once
    if (!instance->initialized)
    {
          //Dynamically configure the digital interface

        //Setting up the SRU to route Flag signals to DPI pin buffers.
        //Use Flags 4 to 15 only. Flags 0 to 3 are not available on the DPI.

        SRU(FLAG4_O,DPI_PB06_I);    //Drive DPI Pin 6 with Flag 4 (LED 1)
        SRU(FLAG5_O,DPI_PB07_I);    //Drive DPI Pin 7 with Flag 5 (LED 2)
        SRU(FLAG6_O,DPI_PB08_I);    //Drive DPI Pin 8 with Flag 6 (LED 3)
        SRU(FLAG7_O,DPI_PB13_I);    //Drive DPI Pin 13 with Flag 7 (LED 4)
        SRU(FLAG8_O,DPI_PB14_I);    //Drive DPI Pin 14 with Flag 8 (LED 5)

        //LED's 6 & 7 are on DAI pins. No Flag signals are available on the DAI.
        //To use the DAI pins as a flag pin, we can manipulate the logic level of the DAI pin buffer
        //directly. We set the value of these pins to LOW at startup.
        SRU(LOW,DAI_PB15_I);        //DAI => We can't use flags. Value has to be set low or high.
        SRU(LOW,DAI_PB16_I);        //DAI => We can't use flags. Value has to be set low or high.

        //Enabling the Buffer direction for DAI and DPI pins using the following sequence:
        //High -> Output, Low -> Input
        SRU(HIGH,DPI_PBEN06_I);
        SRU(HIGH,DPI_PBEN07_I);
        SRU(HIGH,DPI_PBEN08_I);
        SRU(HIGH,DPI_PBEN13_I);
        SRU(HIGH,DPI_PBEN14_I);
        SRU(HIGH,PBEN15_I);
        SRU(HIGH,PBEN16_I);

        //Setting flag pins
        sysreg_bit_set(sysreg_FLAGS, FLG3O|FLG4O|FLG5O|FLG6O|FLG7O|FLG8O);
        //turn off LED 1 - 5 and 8
        sysreg_bit_clr(sysreg_FLAGS,FLG3|FLG4|FLG5|FLG6|FLG7|FLG8);
        instance->initialized = 1;     
        return;
    }

    if (*pLED1Input)
        sysreg_bit_set(sysreg_FLAGS, FLG4);
    else
        sysreg_bit_clr(sysreg_FLAGS, FLG4);
    if (*pLED2Input)
        sysreg_bit_set(sysreg_FLAGS, FLG5);
    else 
        sysreg_bit_clr(sysreg_FLAGS, FLG5);
    if (*pLED3Input)
        sysreg_bit_set(sysreg_FLAGS, FLG6);
    else
        sysreg_bit_clr(sysreg_FLAGS, FLG6);
    if (*pLED4Input)
        sysreg_bit_set(sysreg_FLAGS, FLG7);
    else
        sysreg_bit_clr(sysreg_FLAGS, FLG7);
    if (*pLED5Input)
        sysreg_bit_set(sysreg_FLAGS, FLG8);
    else
        sysreg_bit_clr(sysreg_FLAGS, FLG8);
    if (*pLED6Input) {
        SRU(HIGH,DAI_PB15_I);
    }
    else {
        SRU(LOW,DAI_PB15_I);
    }
    if (*pLED7Input) {
        SRU(HIGH,DAI_PB16_I);
    }
    else {
        SRU(LOW,DAI_PB16_I);
    }
}

SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassLEDControl_21369 = {
    
    /* Flags */
    0,
     
    /* Render function */
    (AMF_RenderFunction)AMF_LEDControl_Render_21369,

    /* Default bypass */
    (void *)0,
    
    /* Input descriptor - no inputs. */
    7, AMF_ControlPin(0)|AMF_ControlPin(1)|AMF_ControlPin(2)|AMF_ControlPin(3)|AMF_ControlPin(4)|AMF_ControlPin(5)|AMF_ControlPin(6),

    /* Output descriptor - 0 outputs */
    0, 0,
};


⌨️ 快捷键说明

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