A bare-metal single instance integration that uses interrupts.
A bare-metal single instance integration that uses interrupts.This example can achieve 1 block of latency in the audio path if the loaded layout matches the AWEInstance's fundamental blocksize If the blocksizes are not equal, there will be 2 blocks of latency. This is due to the fact that this example uses signalling for the pumps, and awe_audioPump is NOT called inline with the audio callback. Examples
#define USER_VER 20190801
#define NUM_CORES 1
#define CORE_ID 0
#define CORE_SPEED 216e6f
#define SAMPLE_SPEED 216e6f
#define HAS_FLOAT_SUPPORT 1
#define HAS_FLASH_FILESYSTEM 1
#define HAS_GPIO 1
#define NO_INPUT_PINS 1
#define NO_OUTPUT_PINS 1
#define IS_SMP 0
#define NUM_AUDIO_THREADS 2
#define AUDIO_SAMPLE_RATE 48000.0f
#define AUDIO_BLOCK_SIZE 32
#define IS_COMPLEX 0
#define SAMPLE_SIZE_IN_BYTES 4
#define MASTER_HEAP_SIZE (1024*31)
#define FASTB_HEAP_SIZE (1024*80)
#define SLOW_HEAP_SIZE (1024*2048)
#define MAX_COMMAND_BUFFER_LEN 264
#include "ModuleList.h"
static IOPinDescriptor s_InputPin = { 0 };
static IOPinDescriptor s_OutputPin = { 0 };
UINT32 g_MasterHeap[MASTER_HEAP_SIZE] @ ".DTCMRAM_Section";
UINT32 g_FastbHeap[FASTB_HEAP_SIZE];
__no_init UINT32 g_SlowHeap[SLOW_HEAP_SIZE] @ ".SDRAM_Section";
const void * g_module_descriptor_table[] =
{
(void *)LISTOFCLASSOBJECTS
};
UINT32 g_module_descriptor_table_size = sizeof(g_module_descriptor_table) / sizeof(g_module_descriptor_table[0]);
void AWEInstanceInit()
{
g_AWEInstance.
pName =
"ST32F769";
g_AWEInstance.
numModules = g_module_descriptor_table_size;
}
void BSP_AUDIO_IN_DMA_Handler(void)
{
int nSamplesAvail;
INT16 * pUSBSamples;
INT32 layoutMask;
INT32 bAudioIsStarted;
INT32 bLayoutValid;
pUSBSamples = USB_Playback_ASRCSamples;
if (!bAudioIsStarted)
{
memset(AudioBufferOut, 0, sizeof(AudioBufferOut) );
}
else
{
if (!bLayoutValid)
{
memcpy(&AudioBufferOut[nOutWriteNdx], &AudioBufferIn[nInReadNdx], STEREO_BLOCK_SIZE_IN_SAMPLES * PCM_SIZE_IN_BYTES);
}
else
{
if (layoutMask > 0)
{
if (layoutMask & 1)
{
if (!g_bAudioPump1Active)
{
NVIC_SetPendingIRQ(AudioWeaverPump_IRQ1);
}
}
if (layoutMask & 2)
{
if (!g_bAudioPump2Active)
{
NVIC_SetPendingIRQ(AudioWeaverPump_IRQ2);
}
}
}
}
}
nInReadNdx = (nInReadNdx + STEREO_BLOCK_SIZE_IN_SAMPLES) % INPUT_AUDIO_BUFFER_SIZE;
nMicReadBufferNdx = (nMicReadBufferNdx + NEW_MIC_BUFFER_SAMPLES) % MIC_BUFF_SIZE;
nOutWriteNdx = (nOutWriteNdx + STEREO_BLOCK_SIZE_IN_SAMPLES) % OUTPUT_AUDIO_BUFFER_SIZE;
}
void AudioWeaverPump_IRQHandler1(void)
{
g_bAudioPump1Active = TRUE;
NVIC_ClearPendingIRQ(AudioWeaverPump_IRQ1);
g_bDeferredProcessingRequired |=
awe_audioPump(&g_AWEInstance, 0);
g_bAudioPump1Active = FALSE;
}
void AudioWeaverPump_IRQHandler2(void)
{
g_bAudioPump2Active = TRUE;
NVIC_ClearPendingIRQ(AudioWeaverPump_IRQ2);
g_bDeferredProcessingRequired |=
awe_audioPump(&g_AWEInstance, 1);
g_bAudioPump2Active = FALSE;
}
void AWEIdleLoop(void)
{
BOOL bMoreProcessingRequired = FALSE;
while(TRUE)
{
if (g_bPacketReceived)
{
g_bPacketReceived = FALSE;
USBSendReply(&g_AWEInstance);
}
{
UINT32 classID;
INT32 nValue;
if (g_bDeferredProcessingRequired || bMoreProcessingRequired)
{
g_bDeferredProcessingRequired = FALSE;
}
{
if (classID == AWE_SinkInt1_classID)
{
}
}
{
if (classID == AWE_DC1_classID)
{
}
}
}
}
}
int main(void)
{
targetInit();
AWEIdleLoop();
}
INT32 awe_initPin(IOPinDescriptor *pPin, UINT32 channels, const char *name)
Initialize an input or output pin.
INT32 awe_ctrlSetValue(const AWEInstance *pAWE, UINT32 handle, const void *value, INT32 arrayOffset, UINT32 length)
Set a scalar or array value of a module variable by handle.
INT32 awe_deferredSetCall(AWEInstance *pAWE)
Perform deferred awe set on a module.
INT32 awe_audioPump(AWEInstance *pAWE, UINT32 layoutIndex)
Audio pump function.
INT32 awe_audioImportSamples(const AWEInstance *pAWE, const void *inSamples, INT32 inStride, INT32 channel, SampleType inType)
Import samples from a user buffer to a channel.
INT32 awe_layoutIsValid(const AWEInstance *pAWE)
Determines if a layout is loaded and valid.
INT32 awe_ctrlGetValue(const AWEInstance *pAWE, UINT32 handle, void *value, INT32 arrayOffset, UINT32 length)
Get a scalar or array value of a module variable by handle.
INT32 awe_audioExportSamples(const AWEInstance *pAWE, void *outSamples, INT32 outStride, INT32 channel, SampleType outType)
Export samples to a user buffer from a channel.
INT32 awe_audioGetPumpMask(AWEInstance *pAWE)
Test if AWE is ready to run.
INT32 awe_packetProcess(AWEInstance *pAWE)
Process an AWEInstance's newly received tuning packet.
INT32 awe_init(AWEInstance *pAWE)
Initialize the instance.
INT32 awe_ctrlGetModuleClass(const AWEInstance *pAWE, UINT32 handle, UINT32 *pClassID)
Get an object class from its handle.
INT32 awe_audioIsStarted(const AWEInstance *pAWE)
Check if this instance is running.
@ Sample16bit
Data is 16 bit PCM.
Definition: StandardDefs.h:222
The AWE instance.
Definition: AWEInstance.h:82
IOPinDescriptor * pInputPin
A BSP author must define/allocate an input pin in their BSP and assign it to this member NOTE: AudioW...
Definition: AWEInstance.h:146
const char * pName
The name of the AWE Instance that will be displayed in Server.
Definition: AWEInstance.h:215
float profileSpeed
Profiling clock speed in Hz.
Definition: AWEInstance.h:207
UINT32 * pReplyBuffer
Reply buffer pointer.
Definition: AWEInstance.h:189
UINT32 * pFastHeapB
The second fast heap, B .
Definition: AWEInstance.h:94
UINT32 numThreads
Number of threads supported for multithreaded systems(1-4).
Definition: AWEInstance.h:219
IOPinDescriptor * pOutputPin
A BSP author must define/allocate an output pin in their BSP and assign it to this member NOTE: Audio...
Definition: AWEInstance.h:152
UINT32 * pPacketBuffer
The Packet buffer pointer.
Definition: AWEInstance.h:180
UINT32 slowHeapSize
The slow heap size.
Definition: AWEInstance.h:108
UINT32 fundamentalBlockSize
Base frame size of this instance.
Definition: AWEInstance.h:226
UINT32 * pSlowHeap
The slow heap.
Definition: AWEInstance.h:97
UINT32 userVersion
User Version word.
Definition: AWEInstance.h:201
float sampleRate
Default sample rate of this instance.
Definition: AWEInstance.h:222
UINT32 packetBufferSize
Packet buffer size.
Definition: AWEInstance.h:196
UINT32 fastHeapBSize
The fast heap B size.
Definition: AWEInstance.h:105
float coreSpeed
A BSP author will set this to the speed of the CPU they are integrating into.
Definition: AWEInstance.h:204
UINT32 instanceId
The ID of this instance.
Definition: AWEInstance.h:87
UINT32 numModules
Number of modules in module table.
Definition: AWEInstance.h:162
const ModClassModule ** pModuleDescriptorTable
Pointer to module table.
Definition: AWEInstance.h:170
UINT32 fastHeapASize
The fast heap A size in 32-bit words.
Definition: AWEInstance.h:102
UINT32 * pFastHeapA
Fast heap A.
Definition: AWEInstance.h:91