📄 amf_ledcontrol_21364_21262.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_21364_21262.c#2 $
// Part of : VisualAudio ButtonsAndLEDs_EZKit V2.0.1
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
#include "AMF_LEDControl_21364_21262.h"
#include <math.h>
#include <sysreg.h>
#include "processor.h"
#if __VERSIONNUM__ >= 0x07010000 //VDSP++4.0
#if defined(__ADSP21364__) || defined(__ADSP21365__) || defined(__ADSP21366__)
#include <sru21365.h>
#include <cdef21364.h>
#else
#if defined(__ADSP21262__) || defined(__ADSP21266__) || defined(__ADSP21267__)
#include <sru21262.h>
#include <cdef21262.h>
#else
#error "Wrong processor."
#endif
#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))
void AMF_LEDControl_Render_21364_21262(AMF_LEDControl_21364_21262 * restrict instance,float * restrict * buffers,int tickSize);
#define LED1 0x1
#define LED2 0x2
#define LED3 0x4
#define LED4 0x8
#define LED5 0x10
#define LED6 0x20
#define LED7 0x40
#define LED8 0x80
SEG_MOD_FAST_CODE void handle_LED(int led_value){
*pPPCTL=0;
*pIIPP=(int) &led_value;
*pIMPP=1;
*pICPP=1;
*pEMPP=1;
*pECPP=1;
*pEIPP=0x400000;
*pPPCTL=PPTRAN|PPBHC|PPDUR20|PPDEN|PPEN;
}
SEG_MOD_FAST_CODE void AMF_LEDControl_Render_21364_21262(AMF_LEDControl_21364_21262 * restrict instance,float * restrict * buffers,int tickSize)
{
/***
Design spec:
The LED state is scanned every time the render function is called.
***/
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];
float *pLED8Input = buffers[7];
int ledValue = 0;
//The initialization is required only once
if (!instance->initialized)
{
handle_LED(0);
asm("nop;nop;nop;nop;nop;");
instance->initialized = 1;
return;
}
if (*pLED1Input)
ledValue |= LED1;
else
ledValue &= ~LED1;
if (*pLED2Input)
ledValue |= LED2;
else
ledValue &= ~LED2;
if (*pLED3Input)
ledValue |= LED3;
else
ledValue &= ~LED3;
if (*pLED4Input)
ledValue |= LED4;
else
ledValue &= ~LED4;
if (*pLED5Input)
ledValue |= LED5;
else
ledValue &= ~LED5;
if (*pLED6Input)
ledValue |= LED6;
else
ledValue &= ~LED6;
if (*pLED7Input)
ledValue |= LED7;
else
ledValue &= ~LED7;
if (*pLED8Input)
ledValue |= LED8;
else
ledValue &= ~LED8;
handle_LED(ledValue);
}
SEG_MOD_SLOW_CONST const AMF_ModuleClass AMFClassLEDControl_21364_21262 = {
/* Flags */
0,
/* Render function */
(AMF_RenderFunction)AMF_LEDControl_Render_21364_21262,
/* Default bypass */
(void *)0,
/* Input descriptor - no inputs. */
8, AMF_ControlPin(0)|AMF_ControlPin(1)|AMF_ControlPin(2)|AMF_ControlPin(3)|AMF_ControlPin(4)|AMF_ControlPin(5)|AMF_ControlPin(6)|AMF_ControlPin(7),
/* Output descriptor - 0 outputs */
0, 0,
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -