📄 preset.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/Platforms/EZKit_BF533_Basic/2.5.0/preset.c#2 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
/*
* Name: Preset.c
* Description: Load the preset from the flash
*
* Owner: Analog Devices
*
* Revision:
*
* M. Guo 05 Jan 2005 Initial Revision
*/
#include <stdlib.h>
#include "Basic.h" // Has definition for PRESETS_IN_FLASH
#include "VALayout1Presets.h"
#if (Layout1_COMPILED_PRESET_COUNT==0)
// Dummy function
int SYS_ApplyPreset(unsigned int nPresetOffset) {
return 0;
}
#else
#define NEXT_ADDRESS(_addr) (_addr) += 4
#define PRESET_BASE_ADDRESS ((unsigned int)(&Layout1_Presets[0]))
#if PRESETS_IN_FLASH
// Presets in flash
#ifndef NO_OPTIMIZE
#pragma optimize_for_space
#endif
static int getPresetElement(int *nAddress,int *pResult,void *pContext)
{
// temp holder
int nValue = 0x0;
int nAddr = *nAddress;
// get the address from the start of flash and put it in a P register
asm ("r3 = %0;": : "d" (nAddr) );
asm ("p2 = r3;");
// now place it into memory
asm ("SSYNC;");
asm ("%0 = [p2];": "=d" (nValue) : );
asm ("SSYNC;");
NEXT_ADDRESS(nAddr);
*nAddress = nAddr;
// put the value at the location passed in
*pResult = nValue;
// ok
return E_NO_ERROR;
}
#else
#ifndef NO_OPTIMIZE
#pragma optimize_for_space
#endif
static int getPresetElement(int *nAddress,int *pResult,void *pContext)
{
int addr = *nAddress;
*pResult = *(int*)addr;
NEXT_ADDRESS(addr);
*nAddress = addr;
return E_NO_ERROR;
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////
// SYS_ApplyPreset
//
// Description:
// Read preset and apply it to the specified destination
//
//Arguments:
// nPresetOffset - Offset value into preset, in words (not bytes). This is a linear address.
//
// Returns:
// Error code.
////////////////////////////////////////////////////////////////////////////////////////////
#ifndef NO_OPTIMIZE
#pragma optimize_for_space
#endif
int SYS_ApplyPreset(unsigned int nPresetOffset)
{
int addr = 0;
// If the high bit of nPresetOffset is set, it will cause interrupts to be masked while the preset is applied.
// Otherwise, interrupts will not be masked.
bool bAtomic = ((nPresetOffset & AMFStructuredSetting_ATOMIC) != 0);
// get the flash address
// Mask the high bit of nPresetOffset to get actual offset
addr = (4*(nPresetOffset & ~AMFStructuredSetting_ATOMIC)) + PRESET_BASE_ADDRESS;
return AMF_ApplyPreset(addr, (AMF_GetPresetElementFunc)getPresetElement, NULL, bAtomic);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -