CMSIS-DSP: Preliminary support for VHT in SDF.

pull/19/head
Christophe Favergeon 4 years ago
parent 72483e7c3f
commit b984d738f4

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<package schemaVersion="1.3" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
<name>SDF</name>
<description>Synchronous Data Flow for CMSIS-DSP</description>
<vendor>ARM</vendor>
<!-- <license>license.txt</license> -->
<url>http://www.keil.com/pack/</url>
<releases>
<release version="0.2.0" date="2021-10-20">
Adding support for VHT platform
</release>
<release version="0.1.0" date="2021-08-02">
First version of Synchronous Data Flow
</release>
</releases>
<conditions>
<condition id="CMSIS-DSP">
<require Cclass="CMSIS" Cgroup="DSP"/>
</condition>
<condition id="SDF">
<require Cclass="Data Processing" Cgroup="Synchronous Data Flow" Csub="Core"/>
<require condition="CMSIS-DSP"/>
</condition>
<condition id="Ring Buffer">
<require Cclass="Data Processing" Cgroup="Synchronous Data Flow" Csub="Ring Buffer"/>
<require condition="SDF"/>
</condition>
</conditions>
<components>
<component Cclass="Data Processing" Cgroup="Synchronous Data Flow" Csub="Core" Cvariant="Source" Cversion="0.2.0-dev" isDefaultVariant="true" condition="CMSIS-DSP">
<description>SDFTools for CMSIS-DSP</description>
<files>
<file category="header" name="sdf/src/GenericNodes.h"/>
<file category="include" name="sdf/nodes/cpp/"/>
<file category="include" name="sdf/nodes/cpp/RingBuffer/"/>
<file category="include" name="sdf/src/"/>
</files>
</component>
<component Cclass="Data Processing" Cgroup="Synchronous Data Flow" Csub="AudioSource" Cvariant="VHT" Cversion="0.2.0-dev" isDefaultVariant="true" condition="Ring Buffer">
<description>AudioSource for VHT</description>
<files>
<file category="header" name="sdf/nodes/cpp/RingBuffer/VHT/Config/RingConfig.h" attr="config" version="1.0.0"/>
<file category="sourceCpp" name="sdf/nodes/cpp/RingBuffer/VHT/AudioInterrupt.cpp"/>
<file category="include" name="sdf/nodes/cpp/RingBuffer/VHT/"/>
<file category="other" name="sdf/nodes/cpp/RingBuffer/VHT/ring.scvd" />
</files>
</component>
<component Cclass="Data Processing" Cgroup="Synchronous Data Flow" Csub="Ring Buffer" Cvariant="Source" Cversion="0.2.0-dev" isDefaultVariant="true" condition="CMSIS-DSP">
<description>RingBuffer</description>
<files>
<file category="header" name="sdf/nodes/cpp/RingBuffer/RingBuffer/RingBuffer.h"/>
<file category="header" name="sdf/nodes/cpp/RingBuffer/RingBuffer/RingInit.h"/>
<file category="include" name="sdf/nodes/cpp/RingBuffer/RingBuffer/"/>
<file category="sourceCpp" name="sdf/nodes/cpp/RingBuffer/RingBuffer/RingBuffer.cpp"/>
<file category="sourceCpp" name="sdf/nodes/cpp/RingBuffer/RingBuffer/RingInit.cpp"/>
</files>
</component>
</components>
</package>

@ -0,0 +1,159 @@
#include <stddef.h>
#include "audio_drv.h"
#include "arm_vsi.h"
#ifdef _RTE_
#include "RTE_Components.h"
#endif
#include CMSIS_device_header
#include "cmsis_os2.h"
#include "RingBuffer.h"
#include "arm_math.h"
#include "SchedEvents.h"
#include "RingConfig.h"
#include "RingInit.h"
#define AudioIn_IRQn ((IRQn_Type)ARM_VSI0_IRQn) /* Audio Input Interrupt number */
extern osThreadId_t gAudioThreadID;
// Number of bytes read by DMA
#define AUDIO_BLOCK_NUM (4)
// Number of DMA blocks
#define AUDIO_DMA_NB_BLOCKS (RING_BUFSIZE >> 2)
extern int32_t AudioDrv_Setup(void);
#if RX_ENABLED
extern ring_config_t ringConfigRX;
#ifdef __FVP_PY
__attribute__((section(".ARM.__at_0x90000000")))
#endif
__ALIGNED(16) static uint8_t audio_bufferRX[RING_BUFSIZE];
static uint8_t *reservedBufRX=NULL;
#endif
#if TX_ENABLED
extern ring_config_t ringConfigTX;
#ifdef __FVP_PY
__attribute__((section(".ARM.__at_0x9FFF0000")))
#endif
__ALIGNED(16) static uint8_t audio_bufferTX[RING_BUFSIZE];
static uint8_t *reservedBufTX=NULL;
#endif
static void AudioEvent (uint32_t event) {
#if RX_ENABLED
if (event & AUDIO_DRV_EVENT_RX_DATA)
{
if (reservedBufRX != NULL)
{
memcpy(reservedBufRX,audio_bufferRX,RING_BUFSIZE);
ringInterruptReleaseBuffer(&ringConfigRX,(void *)gAudioThreadID);
int reservedRX=ringInterruptReserveBuffer(&ringConfigRX);
reservedBufRX=ringGetBufferAddress(&ringConfigRX,reservedRX);
}
}
#endif
#if TX_ENABLED
if (event & AUDIO_DRV_EVENT_TX_DATA)
{
if (reservedBufTX != NULL)
{
memcpy(audio_bufferTX,reservedBufTX,RING_BUFSIZE);
}
ringInterruptReleaseBuffer(&ringConfigTX,(void *)gAudioThreadID);
int reservedTX=ringInterruptReserveBuffer(&ringConfigTX);
reservedBufTX=ringGetBufferAddress(&ringConfigTX,reservedTX);
}
#endif
}
int32_t AudioDrv_Setup(void) {
int32_t ret;
ret = AudioDrv_Initialize(AudioEvent);
if (ret != 0) {
return ret;
}
#if RX_ENABLED
ret = AudioDrv_Configure(AUDIO_DRV_INTERFACE_RX,
AUDIO_NBCHANNELS, /* single channel */
8U * AUDIO_CHANNEL_ENCODING, /* 16 sample bits */
static_cast<uint32_t>(AUDIO_SAMPLINGFREQUENCY));
if (ret != 0) {
return ret;
}
/* Work because user process not started yet
*/
int reservedRX=ringInterruptReserveBuffer(&ringConfigRX);
reservedBufRX=ringGetBufferAddress(&ringConfigRX,reservedRX);
ret = AudioDrv_SetBuf(AUDIO_DRV_INTERFACE_RX,
audio_bufferRX, AUDIO_BLOCK_NUM, AUDIO_DMA_NB_BLOCKS);
if (ret != 0) {
return ret;
}
ret = AudioDrv_Control(AUDIO_DRV_CONTROL_RX_ENABLE);
if (ret != 0) {
return ret;
}
#endif
#if TX_ENABLED
ret = AudioDrv_Configure(AUDIO_DRV_INTERFACE_TX,
AUDIO_NBCHANNELS, /* single channel */
8U * AUDIO_CHANNEL_ENCODING, /* 16 sample bits */
static_cast<uint32_t>(AUDIO_SAMPLINGFREQUENCY));
if (ret != 0) {
return ret;
}
/* Work because user process not started yet
*/
/* dataflow must be one packet ahead of the TX */
ringUserReserveBuffer(&ringConfigTX);
ringUserReleaseBuffer(&ringConfigTX);
int reservedTX=ringInterruptReserveBuffer(&ringConfigTX);
reservedBufTX=ringGetBufferAddress(&ringConfigTX,reservedTX);
ret = AudioDrv_SetBuf(AUDIO_DRV_INTERFACE_TX,
audio_bufferTX, AUDIO_BLOCK_NUM, AUDIO_DMA_NB_BLOCKS);
if (ret != 0) {
return ret;
}
ret = AudioDrv_Control(AUDIO_DRV_CONTROL_TX_ENABLE);
if (ret != 0) {
return ret;
}
#endif
return 0;
}

@ -0,0 +1,48 @@
#ifndef _RINGCONFIG_H_
#define _RINGCONFIG_H_
// <<< Use Configuration Wizard in Context Menu >>>
// <h>Audio Configuration
// <o>Sampling Frequency <8000=> 8000 kHz <16000=> 16000 kHz
// <44100=> 44100 kHz <48000=> 48000 kHz
#ifndef AUDIO_SAMPLINGFREQUENCY
#define AUDIO_SAMPLINGFREQUENCY 16000
#endif
// <o>Number of samples <100-3000>
// <i> Must be consistent with the settings of the Audio source
#ifndef AUDIO_NBSAMPLES
#define AUDIO_NBSAMPLES 1600
#endif
// <o>Number of channels <1=> Mono <2=> Stereo
#ifndef AUDIO_NBCHANNELS
#define AUDIO_NBCHANNELS 1U
#endif
// <o>Channel encoding <2=> 16 Bits
#ifndef AUDIO_CHANNEL_ENCODING
#define AUDIO_CHANNEL_ENCODING 2U
#endif
// <q> RX_ENABLED: Enable RX
#define RX_ENABLED 1
// <q> TX_ENABLED: Enable TX
#define TX_ENABLED 1
// </h>
// <h>Ring Buffer Configuration
// <o>Number of buffers <2-32>
#ifndef RING_NBBUFS
#define RING_NBBUFS 2
#endif
// </h>
// <<< end of configuration section >>>
#define RING_BUFSIZE (AUDIO_NBSAMPLES * AUDIO_NBCHANNELS * AUDIO_CHANNEL_ENCODING)
#endif

@ -0,0 +1,80 @@
/* ----------------------------------------------------------------------
* Project: CMSIS DSP Library
* Title: RingPrivate.h
* Description: Implementation for RTX + Keil MDK
*
* $Date: 30 July 2021
* $Revision: V1.10.0
*
* Target Processor: Cortex-M and Cortex-A cores
* -------------------------------------------------------------------- */
/*
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _RINGPRIVATE_H_
#define _RINGPRIVATE_H_
/*
Implementation for RTX + Keil MDK Event logger
*/
#include <stddef.h>
#include "audio_drv.h"
#include "arm_vsi.h"
#ifdef _RTE_
#include "RTE_Components.h"
#endif
#include CMSIS_device_header
#include "cmsis_os2.h"
#ifndef AudioIn_IRQn
#define AudioIn_IRQn ((IRQn_Type)0) /* Audio Input Interrupt number */
#endif
#include "SchedEvents.h"
/*
RTX dependent definition
*/
#define RING_BEGINCRITICALSECTION() NVIC_DisableIRQ (AudioIn_IRQn)
#define RING_ENDCRITICALSECTION() NVIC_EnableIRQ (AudioIn_IRQn)
#define RING_WAIT_BUFFER(TIMEOUT) osThreadFlagsWait(1,osFlagsWaitAny,(TIMEOUT))
#define RING_HASWAITERROR(F) (F < 0)
#define RING_RELEASE_BUFFER(THREADID) osThreadFlagsSet((osThreadId_t)(THREADID),1)
/* Debug trace using Event Recorder */
#define RING_DBG_USER_RESERVE_BUFFER(ID) EventRecord2 (Evt_UsrReserve, (ID), 0)
#define RING_DBG_USER_RELEASE_BUFFER(ID) EventRecord2 (Evt_UsrRelease, (ID), 0)
#define RING_DBG_USER_WAIT_BUFFER(ID) EventRecord2 (Evt_UsrWait, (ID), 0)
#define RING_DBG_USER_BUFFER_RELEASED(ID) EventRecord2 (Evt_UsrFree, (ID), 0)
#define RING_DBG_USER_STATUS(SA,SB) EventRecord2 (Evt_UsrStatus, config->SA,config->SB)
#define RING_DBG_INT_RESERVE_BUFFER(ID) EventRecord2 (Evt_IntReserve, (ID), 0)
#define RING_DBG_INT_RELEASE_BUFFER(ID) EventRecord2 (Evt_IntRelease, (ID), 0)
#define RING_DBG_INT_RELEASE_USER() EventRecord2 (Evt_IntReleaseUser, 0, 0)
#define RING_DBG_INT_STATUS(SA,SB) EventRecord2 (Evt_IntStatus, config->SA,config->SB)
#define RING_DBG_ERROR(ERROR) EventRecord2 (Evt_Error, (ERROR), 0)
#endif

@ -0,0 +1,68 @@
/* ----------------------------------------------------------------------
* Project: CMSIS DSP Library
* Title: SchedEvents.h
* Description: Definition of the events for the Keil MDK Event logger
*
* $Date: 30 July 2021
* $Revision: V1.10.0
*
* Target Processor: Cortex-M and Cortex-A cores
* -------------------------------------------------------------------- */
/*
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SCHEDEVT_H
#define _SCHEDEVT_H
/*
Definition of Event IDs for Keil MDK EventRecorder
*/
#include "EventRecorder.h"
#define EvtNodes 0x00
#define EvtRing_User 0x01
#define EvtRing_Int 0x02
#define EvtRing_All 0x03
/* Node events */
#define Evt_Sink EventID (EventLevelAPI, EvtNodes, 0x00)
#define Evt_Source EventID (EventLevelAPI, EvtNodes, 0x01)
/* User Ring Events */
#define Evt_UsrReserve EventID (EventLevelAPI, EvtRing_User, 0x00)
#define Evt_UsrRelease EventID (EventLevelAPI, EvtRing_User, 0x01)
#define Evt_UsrWait EventID (EventLevelAPI, EvtRing_User, 0x02)
#define Evt_UsrFree EventID (EventLevelAPI, EvtRing_User, 0x03)
#define Evt_UsrStatus EventID (EventLevelAPI, EvtRing_User, 0x04)
/* Interrupt Ring Events */
#define Evt_IntReserve EventID (EventLevelAPI, EvtRing_Int, 0x00)
#define Evt_IntRelease EventID (EventLevelAPI, EvtRing_Int, 0x01)
#define Evt_IntReleaseUser EventID (EventLevelAPI, EvtRing_Int, 0x02)
#define Evt_IntStatus EventID (EventLevelAPI, EvtRing_Int, 0x03)
/* Other Ring Events */
#define Evt_Error EventID (EventLevelError, EvtRing_All, 0x00)
#endif

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Project: CMSIS DSP Library
Title: ring.SCVD
Description: Event definitions for use in Keil MDK
$Date: 30 July 2021
$Revision: V1.10.0
Target Processor: Cortex-M and Cortex-A cores
Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the License); you may
not use this file except in compliance with the License.
You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an AS IS BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
<component name="SDFTools" version="1.0.0"/> <!-- name and version of the component -->
<events>
<group name="SDF Tools">
<component name="Node" brief="NODE" no="0x00" prefix="EvrNodeMM_" info="Application nodes"/>
<component name="Ring USR" brief="USR" no="0x01" prefix="EvrRingUSRMM_" info="Ring buffer USR"/>
<component name="Ring INT" brief="INT" no="0x02" prefix="EvrRingINTMM_" info="Ring buffer INT"/>
<component name="Ring All" brief="ALL" no="0x03" prefix="EvrRingAllMM_" info="Ring All"/>
</group>
<event id="0" level="API" property="Sink Executed" info="Audio Sink" />
<event id="1" level="Op" property="Sink Value" value="nbSink=%x[val1]" info="Sink value" />
<event id="2" level="API" property="Source Executed" />
<event id="0x100" level="Op" property="Reserve" value="ID=%d[val1]" info="Reserve buffer" />
<event id="0x101" level="Op" property="Release" value="ID=%d[val1]" info="Release buffer" />
<event id="0x102" level="Op" property="Wait" value="ID=%d[val1]" info="Wait buffer" />
<event id="0x103" level="Op" property="Unblocked" value="ID=%d[val1]" info="Free buffer" />
<event id="0x104" level="Op" property="Status" value="USR=%x[val1] INT=%x[val2]" info="Reservation status" />
<event id="0x200" level="Op" property="Reserve" value="ID=%d[val1]" info="Reserve buffer" />
<event id="0x201" level="Op" property="Release" value="ID=%d[val1]" info="Release buffer" />
<event id="0x202" level="Op" property="Release USR" info="Release user" />
<event id="0x203" level="Op" property="Status" value="USR=%x[val1] INT=%x[val2]" info="Reservation status" />
<event id="0x300" level="Error" property="Error" value="err=%d[val1]" info="Release buffer" />
</events>
</component_viewer>

@ -270,10 +270,11 @@ protected:
};
#if !defined(CHECKERROR)
#define CHECKERROR if (sdfError < 0) \
{\
break;\
}
#endif
#endif

Loading…
Cancel
Save