Skip to content

Commit

Permalink
Initial commit for the CMSIS DSP sample code (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannis-karachalios authored Aug 12, 2024
1 parent 2618459 commit 3187759
Show file tree
Hide file tree
Showing 12 changed files with 11,270 additions and 0 deletions.
347 changes: 347 additions & 0 deletions features/cmsis_dsp_sample_code/.cproject

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions features/cmsis_dsp_sample_code/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cmsis_dsp_sample_code</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>sdk</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>startup</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/startup</locationURI>
</link>
<link>
<name>sdk/FreeRTOS</name>
<type>2</type>
<locationURI>SDKROOT/sdk/free_rtos</locationURI>
</link>
<link>
<name>sdk/adapters</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/adapters</locationURI>
</link>
<link>
<name>sdk/bsp_include</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/include</locationURI>
</link>
<link>
<name>sdk/config</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/config</locationURI>
</link>
<link>
<name>sdk/ldscripts</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/ldscripts/non_ble_projects</locationURI>
</link>
<link>
<name>sdk/memory</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/memory</locationURI>
</link>
<link>
<name>sdk/middleware_config</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/config</locationURI>
</link>
<link>
<name>sdk/osal</name>
<type>2</type>
<locationURI>SDKROOT/sdk/middleware/osal</locationURI>
</link>
<link>
<name>sdk/peripherals</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/peripherals</locationURI>
</link>
<link>
<name>sdk/sys_man</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/system/sys_man</locationURI>
</link>
<link>
<name>sdk/util</name>
<type>2</type>
<locationURI>SDKROOT/sdk/bsp/util</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>SDKROOT</name>
<value>$%7BWORKSPACE_LOC%7D</value>
</variable>
</variableList>
</projectDescription>
39 changes: 39 additions & 0 deletions features/cmsis_dsp_sample_code/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# CMSIS DSP Demonstration Example

This example runs the ARM CMSIS DSP library on the DA1459x family of devices. One of the example from the CMSIS library has been extracted and used as a sanity check.

## HW and SW Configuration

- **Hardware Configuration**
- This example runs on the DA1459x family of devices.
- A [Pro Development Kit](https://www.renesas.com/us/en/products/wireless-connectivity/bluetooth-low-energy/da14592-016fdevkt-p-smartbond-da14592-bluetooth-low-energy-52-soc-development-kit-pro) (DevKit) is needed for this example.
- **Software Configuration**
- Download the latest [SDK](https://www.renesas.com/us/en/products/wireless-connectivity/bluetooth-low-energy/da14592-smartbond-multi-core-bluetooth-le-52-soc-embedded-flash?gad_source=1) version for the target family of devices.

- SEGGER J-Link tools are normally downloaded and installed as part of the [e2 Studio](https://www.renesas.com/us/en/software-tool/smartbond-development-tools) installation.

## How to run the example

### Initial Setup

- Download the source code from [GitHub](https://github.com/dialog-semiconductor/BLE_SDK10_DA1459x_examples).

- Import the project into your workspace (there should be no path dependencies). If you are not familiar with these processes it's advised that you first familiarize yourself with the [Getting Started](https://lpccs-docs.renesas.com/um-b-166-da1459x_getting_started/index.html) guide.

- Connect the target device to your host PC via USB1. The mentioned port is used to power the device and to support serial and JTAG interfaces. These two interfaces can be used both for flashing and debugging purposes.

- Compile the source code (either in Release or Debug mode) and flash it into the chip. Please note that the debug flavor should be used merely for debugging purposes since it should increase the generated binary file, significantly. In addition, the source code is built to work with the embedded flash Working with external flash memory devices is out of the scope of this demonstration example.

- Open a serial terminal (115200/8-N-1).

- Once the application image is flashed, press the RESET button on the daughter board to start executing the application.

- The terminal should display that the test vector has run successfully (or not). The `#` should also be printed every second as the sample code is built on top of the `freertos_retarget` SDK sample code.

```
arm_sin_cos_example_f32 test success
```

## Known Limitations

There should be no known limitations for this example.
165 changes: 165 additions & 0 deletions features/cmsis_dsp_sample_code/arm_sin_cos_example_f32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/* ----------------------------------------------------------------------
* Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* $Date: 12. March 2014
* $Revision: V1.4.3
*
* Project: CMSIS DSP Library
* Title: arm_sin_cos_example_f32.c
*
* Description: Example code demonstrating sin and cos calculation of input signal.
*
* Target Processor: Cortex-M4/Cortex-M3
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* - Neither the name of ARM LIMITED nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* -------------------------------------------------------------------- */

/**
* @ingroup groupExamples
*/

/**
* @defgroup SinCosExample SineCosine Example
*
* \par Description:
* \par
* Demonstrates the Pythagorean trignometric identity with the use of Cosine, Sine, Vector
* Multiplication, and Vector Addition functions.
*
* \par Algorithm:
* \par
* Mathematically, the Pythagorean trignometric identity is defined by the following equation:
* <pre>sin(x) * sin(x) + cos(x) * cos(x) = 1</pre>
* where \c x is the angle in radians.
*
* \par Block Diagram:
* \par
* \image html sinCos.gif
*
* \par Variables Description:
* \par
* \li \c testInput_f32 array of input angle in radians
* \li \c testOutput stores sum of the squares of sine and cosine values of input angle
*
* \par CMSIS DSP Software Library Functions Used:
* \par
* - arm_cos_f32()
* - arm_sin_f32()
* - arm_mult_f32()
* - arm_add_f32()
*
* <b> Refer </b>
* \link arm_sin_cos_example_f32.c \endlink
*
*/


/** \example arm_sin_cos_example_f32.c
*/

#define __FPU_PRESENT 1
#define __DSP_PRESENT 1

#include <stdint.h>
#include <math.h>
#include "arm_math.h"

/* ----------------------------------------------------------------------
* Defines each of the tests performed
* ------------------------------------------------------------------- */
#define MAX_BLOCKSIZE 32
#define DELTA (0.0001f)


/* ----------------------------------------------------------------------
* Test input data for Floating point sin_cos example for 32-blockSize
* Generated by the MATLAB randn() function
* ------------------------------------------------------------------- */

const float32_t testInput_f32[MAX_BLOCKSIZE] =
{
-1.244916875853235400, -4.793533929171324800, 0.360705030233248850, 0.827929644170887320, -3.299532218312426900, 3.427441903227623800, 3.422401784294607700, -0.108308165334010680,
0.941943896490312180, 0.502609575000365850, -0.537345278736373500, 2.088817392965764500, -1.693168684143455700, 6.283185307179590700, -0.392545884746175080, 0.327893095115825040,
3.070147440456292300, 0.170611405884662230, -0.275275082396073010, -2.395492805446796300, 0.847311163536506600, -3.845517018083148800, 2.055818378415868300, 4.672594161978930800,
-1.990923030266425800, 2.469305197656249500, 3.609002606064021000, -4.586736582331667500, -4.147080139136136300, 1.643756718868359500, -1.150866392366494800, 1.985805026477433800


};

const float32_t testRefOutput_f32 = 1.000000000;

/* ----------------------------------------------------------------------
* Declare Global variables
* ------------------------------------------------------------------- */
uint32_t blockSize = 32;
float32_t testOutput;
float32_t cosOutput;
float32_t sinOutput;
float32_t cosSquareOutput;
float32_t sinSquareOutput;

/* ----------------------------------------------------------------------
* Max magnitude FFT Bin test
* ------------------------------------------------------------------- */

arm_status status;

int32_t arm_sin_cos_example_f32(void)
{
float32_t diff;
uint32_t i;

for(i=0; i< blockSize; i++)
{
cosOutput = arm_cos_f32(testInput_f32[i]);
sinOutput = arm_sin_f32(testInput_f32[i]);

arm_mult_f32(&cosOutput, &cosOutput, &cosSquareOutput, 1);
arm_mult_f32(&sinOutput, &sinOutput, &sinSquareOutput, 1);

arm_add_f32(&cosSquareOutput, &sinSquareOutput, &testOutput, 1);

/* absolute value of difference between ref and test */
diff = fabsf(testRefOutput_f32 - testOutput);

/* Comparison of sin_cos value with reference */
if (diff > DELTA)
{
status = ARM_MATH_TEST_FAILURE;
}

if ( status == ARM_MATH_TEST_FAILURE)
{
return (0);
}

}

return(1); /* main function does not return */
}

/** \endlink */
66 changes: 66 additions & 0 deletions features/cmsis_dsp_sample_code/config/custom_config_eflash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
****************************************************************************************
*
* @file custom_config_eflash.h
*
* @brief Board Support Package. User Configuration file for cached eFLASH mode.
*
* Copyright (C) 2020-2023 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/

#ifndef CUSTOM_CONFIG_EFLASH_H_
#define CUSTOM_CONFIG_EFLASH_H_

#include "bsp_definitions.h"

#define CONFIG_RETARGET

#define dg_configEXEC_MODE MODE_IS_CACHED
#define dg_configCODE_LOCATION NON_VOLATILE_IS_EMBEDDED_FLASH

#define dg_configUSE_WDOG ( 1 )

#define dg_configUSE_SW_CURSOR ( 1 )

/*************************************************************************************************\
* FreeRTOS specific config
*/
#define OS_FREERTOS /* Define this to use FreeRTOS */
#define configTOTAL_HEAP_SIZE 14000 /* This is the FreeRTOS Total Heap Size */

/*************************************************************************************************\
* Peripheral specific config
*/
#define dg_configFLASH_ADAPTER ( 0 )
#define dg_configNVMS_ADAPTER ( 0 )
#define dg_configNVMS_VES ( 0 )

/* Include bsp default values */
#include "bsp_defaults.h"
/* Include middleware default values */
#include "middleware_defaults.h"

#endif /* CUSTOM_CONFIG_EFLASH_H_ */
Loading

0 comments on commit 3187759

Please sign in to comment.