├── .github ├── ISSUE_TEMPLATE │ ├── 01_other_issue.yml │ ├── 02_bug.yml │ ├── 03_feature_request.yml │ └── config.yml └── workflows │ ├── issue_comment.yml │ ├── new_issues.yml │ ├── new_prs.yml │ └── upload_component.yml ├── .gitignore ├── .gitlab-ci.yml ├── .pre-commit-config.yaml ├── CHANGELOG.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── Kconfig ├── LICENSE ├── README.md ├── applications ├── README.md ├── azure_board_apps │ ├── .gitignore │ ├── README.md │ ├── apps │ │ ├── 3d_graphics │ │ │ ├── 3d_graphics.gif │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ └── main │ │ │ │ ├── 3d_graphics_demo.cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Kconfig.projbuild │ │ │ │ └── idf_component.yml │ │ └── kalman_filter │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── kalman_filter.gif │ │ │ └── main │ │ │ ├── CMakeLists.txt │ │ │ ├── Kconfig.projbuild │ │ │ ├── idf_component.yml │ │ │ └── kalman_filter_demo.cpp │ └── graphics │ │ ├── .gitignore │ │ ├── 3d_matrix │ │ ├── 3d_matrix_data │ │ │ ├── cube_matrix.h │ │ │ ├── esp_logo.c │ │ │ ├── esp_logo.h │ │ │ ├── esp_text.c │ │ │ ├── esp_text.h │ │ │ ├── image_to_3d_matrix.c │ │ │ └── image_to_3d_matrix.h │ │ └── 3d_matrix_src │ │ │ ├── graphics_support.cpp │ │ │ └── graphics_support.h │ │ └── img_to_3d_matrix │ │ ├── ImgTo3D.py │ │ ├── example │ │ ├── README.md │ │ ├── converted_image │ │ │ ├── cpu_logo_conv.png │ │ │ └── cpu_logo_invert_conv.png │ │ └── image │ │ │ └── cpu_logo.png │ │ └── templates │ │ ├── template_img_to_3d.c │ │ └── template_img_to_3d.h ├── lyrat_board_app │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── audio_amp_main.c │ │ └── idf_component.yml │ ├── partitions.csv │ ├── sdkconfig.defaults │ └── spiffs │ │ └── 16bit_mono_44_1_khz.wav ├── m5stack_core_s3 │ └── apps │ │ ├── 3d_graphics │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── main │ │ │ ├── 3d_graphics_demo.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── idf_component.yml │ │ │ └── init_display.c │ │ └── sdkconfig.defaults │ │ └── kalman_filter │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── main │ │ ├── 3d_kalman_demo.cpp │ │ ├── CMakeLists.txt │ │ ├── bmi270_context.c │ │ └── idf_component.yml │ │ └── sdkconfig.defaults └── spectrum_box_lite │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ ├── CMakeLists.txt │ ├── idf_component.yml │ └── main.c │ └── sdkconfig.defaults ├── build_all.sh ├── component.mk ├── docs ├── Doxyfile ├── _static │ ├── 404-page__en.svg │ └── esp-dsp_docs_versions.js ├── build_bm_table.py ├── conf_common.py ├── en │ ├── conf.py │ ├── esp-dsp-apis.rst │ ├── esp-dsp-applications.rst │ ├── esp-dsp-benchmarks.rst │ ├── esp-dsp-examples.rst │ ├── esp-dsp-library.rst │ └── index.rst ├── esp-dsp-benchmarks_template.rst ├── esp_bm_results.csv ├── issue_template.md ├── requirements.txt └── utils.sh ├── examples ├── README.md ├── basic_math │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_math_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── conv2d │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── conv2d_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── dotprod │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_dotproduct_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── fft │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_fft_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── fft4real │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_fft4real_main.c │ │ ├── idf_component.yml │ │ └── linker.ld │ └── sdkconfig.defaults ├── fft_window │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_window_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── fir │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_fir_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── iir │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── dsps_iir_main.c │ │ └── idf_component.yml │ └── sdkconfig.defaults ├── kalman │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ ├── ekf_imu13states_main.cpp │ │ └── idf_component.yml │ └── sdkconfig.defaults └── matrix │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── main │ ├── CMakeLists.txt │ ├── component.mk │ ├── dspm_matrix_main.cpp │ └── idf_component.yml │ └── sdkconfig.defaults ├── idf_component.yml ├── modules ├── common │ ├── include │ │ ├── dsp_common.h │ │ ├── dsp_err.h │ │ ├── dsp_err_codes.h │ │ ├── dsp_platform.h │ │ ├── dsp_tests.h │ │ ├── dsp_types.h │ │ └── esp_dsp.h │ ├── include_sim │ │ ├── esp_attr.h │ │ ├── esp_err.h │ │ ├── esp_log.h │ │ └── sdkconfig.h │ └── misc │ │ ├── aes3_tie_log.c │ │ └── dsps_pwroftwo.cpp ├── conv │ ├── float │ │ ├── dspi_conv_f32_ansi.c │ │ ├── dsps_ccorr_f32_ae32.S │ │ ├── dsps_ccorr_f32_ansi.c │ │ ├── dsps_conv_f32_ae32.S │ │ ├── dsps_conv_f32_ansi.c │ │ ├── dsps_conv_f32_m_ae32.S │ │ ├── dsps_corr_f32_ae32.S │ │ └── dsps_corr_f32_ansi.c │ ├── include │ │ ├── dspi_conv.h │ │ ├── dsps_ccorr.h │ │ ├── dsps_conv.h │ │ ├── dsps_conv_platform.h │ │ └── dsps_corr.h │ └── test │ │ ├── test_dspi_conv_f32_ansi.c │ │ ├── test_dsps_ccorr_f32_ae32.c │ │ ├── test_dsps_ccorr_f32_ansi.c │ │ ├── test_dsps_conv_f32_ae32.c │ │ ├── test_dsps_conv_f32_ansi.c │ │ ├── test_dsps_corr_f32_ae32.c │ │ └── test_dsps_corr_f32_ansi.c ├── dct │ ├── float │ │ ├── dsps_dct_f32.c │ │ ├── dsps_dctiv_f32.c │ │ └── dsps_dstiv_f32.c │ ├── include │ │ └── dsps_dct.h │ └── test │ │ └── test_dsps_dct_f32.c ├── dotprod │ ├── fixed │ │ ├── dspi_dotprod_off_s16_aes3.S │ │ ├── dspi_dotprod_off_s16_ansi.c │ │ ├── dspi_dotprod_off_s16_arp4.S │ │ ├── dspi_dotprod_off_s8_aes3.S │ │ ├── dspi_dotprod_off_s8_ansi.c │ │ ├── dspi_dotprod_off_s8_arp4.S │ │ ├── dspi_dotprod_off_u16_aes3.S │ │ ├── dspi_dotprod_off_u16_ansi.c │ │ ├── dspi_dotprod_off_u16_arp4.S │ │ ├── dspi_dotprod_off_u8_aes3.S │ │ ├── dspi_dotprod_off_u8_ansi.c │ │ ├── dspi_dotprod_off_u8_arp4.S │ │ ├── dspi_dotprod_s16_aes3.S │ │ ├── dspi_dotprod_s16_ansi.c │ │ ├── dspi_dotprod_s16_arp4.S │ │ ├── dspi_dotprod_s8_aes3.S │ │ ├── dspi_dotprod_s8_ansi.c │ │ ├── dspi_dotprod_s8_arp4.S │ │ ├── dspi_dotprod_u16_aes3.S │ │ ├── dspi_dotprod_u16_ansi.c │ │ ├── dspi_dotprod_u16_arp4.S │ │ ├── dspi_dotprod_u8_aes3.S │ │ ├── dspi_dotprod_u8_ansi.c │ │ ├── dspi_dotprod_u8_arp4.S │ │ ├── dsps_dotprod_s16_ae32.S │ │ ├── dsps_dotprod_s16_ansi.c │ │ ├── dsps_dotprod_s16_arp4.S │ │ └── dsps_dotprod_s16_m_ae32.S │ ├── float │ │ ├── dspi_dotprod_f32_ansi.c │ │ ├── dspi_dotprod_off_f32_ansi.c │ │ ├── dsps_dotprod_f32_ae32.S │ │ ├── dsps_dotprod_f32_aes3.S │ │ ├── dsps_dotprod_f32_ansi.c │ │ ├── dsps_dotprod_f32_arp4.S │ │ ├── dsps_dotprod_f32_m_ae32.S │ │ ├── dsps_dotprode_f32_ae32.S │ │ ├── dsps_dotprode_f32_ansi.c │ │ ├── dsps_dotprode_f32_arp4.S │ │ └── dsps_dotprode_f32_m_ae32.S │ ├── include │ │ ├── dspi_dotprod.h │ │ ├── dspi_dotprod_platform.h │ │ ├── dsps_dotprod.h │ │ └── dsps_dotprod_platform.h │ └── test │ │ ├── test_dotprod_f32.c │ │ ├── test_dotprod_s16.c │ │ ├── test_dotprode_f32.c │ │ ├── test_dspi_dotprod_f32_ansi.c │ │ ├── test_dspi_dotprod_off_f32_ansi.c │ │ ├── test_dspi_dotprod_off_s16_aes3.c │ │ ├── test_dspi_dotprod_off_s16_ansi.c │ │ ├── test_dspi_dotprod_off_s8_aes3.c │ │ ├── test_dspi_dotprod_off_s8_ansi.c │ │ ├── test_dspi_dotprod_off_u16_aes3.c │ │ ├── test_dspi_dotprod_off_u16_ansi.c │ │ ├── test_dspi_dotprod_off_u8_aes3.c │ │ ├── test_dspi_dotprod_off_u8_ansi.c │ │ ├── test_dspi_dotprod_s16_aes3.c │ │ ├── test_dspi_dotprod_s16_ansi.c │ │ ├── test_dspi_dotprod_s8_aes3.c │ │ ├── test_dspi_dotprod_s8_ansi.c │ │ ├── test_dspi_dotprod_u16_aes3.c │ │ ├── test_dspi_dotprod_u16_ansi.c │ │ ├── test_dspi_dotprod_u8_aes3.c │ │ └── test_dspi_dotprod_u8_ansi.c ├── fft │ ├── fixed │ │ ├── dsps_fft2r_sc16_ae32.S │ │ ├── dsps_fft2r_sc16_aes3.S │ │ ├── dsps_fft2r_sc16_ansi.c │ │ └── dsps_fft2r_sc16_arp4.S │ ├── float │ │ ├── dsps_bit_rev_lookup_fc32_aes3.S │ │ ├── dsps_fft2r_bitrev_tables_fc32.c │ │ ├── dsps_fft2r_fc32_ae32.c │ │ ├── dsps_fft2r_fc32_ae32_.S │ │ ├── dsps_fft2r_fc32_aes3_.S │ │ ├── dsps_fft2r_fc32_ansi.c │ │ ├── dsps_fft2r_fc32_arp4.S │ │ ├── dsps_fft4r_bitrev_tables_fc32.c │ │ ├── dsps_fft4r_fc32_ae32.c │ │ ├── dsps_fft4r_fc32_ae32_.S │ │ ├── dsps_fft4r_fc32_aes3_.S │ │ ├── dsps_fft4r_fc32_ansi.c │ │ └── dsps_fft4r_fc32_arp4.S │ ├── include │ │ ├── dsps_fft2r.h │ │ ├── dsps_fft2r_platform.h │ │ ├── dsps_fft4r.h │ │ ├── dsps_fft4r_platform.h │ │ └── dsps_fft_tables.h │ ├── test │ │ ├── test_dsps_fft2r_fc32_ae32.c │ │ ├── test_dsps_fft2r_fc32_ansi.c │ │ ├── test_dsps_fft2r_sc16_ae32.c │ │ ├── test_dsps_fft2r_sc16_ansi.c │ │ ├── test_dsps_fft4r_fc32_ae32.c │ │ └── test_dsps_fft4r_fc32_ansi.c │ └── test_sim │ │ ├── Makefile │ │ ├── main.c │ │ └── test_fft2r.c ├── fir │ ├── fixed │ │ ├── dsps_fir_s16_m_ae32.S │ │ ├── dsps_fird_init_s16.c │ │ ├── dsps_fird_s16_ae32.S │ │ ├── dsps_fird_s16_aes3.S │ │ ├── dsps_fird_s16_ansi.c │ │ └── dsps_fird_s16_arp4.S │ ├── float │ │ ├── dsps_fir_f32_ae32.S │ │ ├── dsps_fir_f32_aes3.S │ │ ├── dsps_fir_f32_ansi.c │ │ ├── dsps_fir_init_f32.c │ │ ├── dsps_fird_f32_ae32.S │ │ ├── dsps_fird_f32_aes3.S │ │ ├── dsps_fird_f32_ansi.c │ │ ├── dsps_fird_f32_arp4.S │ │ └── dsps_fird_init_f32.c │ ├── include │ │ ├── dsps_fir.h │ │ └── dsps_fir_platform.h │ ├── test │ │ ├── test_dsps_fir_f32_ae32.c │ │ ├── test_dsps_fir_f32_ansi.c │ │ ├── test_dsps_fird_f32_ae32.c │ │ ├── test_dsps_fird_f32_ansi.c │ │ ├── test_dsps_fird_s16_ae32.c │ │ └── test_dsps_fird_s16_ansi.c │ └── test_sim │ │ ├── Makefile │ │ ├── main.c │ │ └── test_fir.c ├── iir │ ├── biquad │ │ ├── dsps_biquad_f32_ae32.S │ │ ├── dsps_biquad_f32_aes3.S │ │ ├── dsps_biquad_f32_ansi.c │ │ ├── dsps_biquad_f32_arp4.S │ │ ├── dsps_biquad_gen_f32.c │ │ ├── dsps_biquad_sf32_ae32.S │ │ ├── dsps_biquad_sf32_ansi.c │ │ └── dsps_biquad_sf32_arp4.S │ ├── include │ │ ├── dsps_biquad.h │ │ ├── dsps_biquad_gen.h │ │ └── dsps_biquad_platform.h │ ├── test │ │ ├── test_bq_f32_ae32.c │ │ ├── test_bq_f32_ansi.c │ │ ├── test_bq_sf32_ae32.c │ │ └── test_bq_sf32_ansi.c │ └── test_sim │ │ ├── Makefile │ │ ├── main.c │ │ └── test_iir_biquad.c ├── kalman │ ├── ekf │ │ ├── CMakeLists.txt │ │ ├── common │ │ │ └── ekf.cpp │ │ └── include │ │ │ └── ekf.h │ └── ekf_imu13states │ │ ├── docs │ │ └── README.md │ │ ├── ekf_imu13states.cpp │ │ ├── include │ │ └── ekf_imu13states.h │ │ └── test │ │ └── test_ekf_imu13states.cpp ├── math │ ├── add │ │ ├── fixed │ │ │ ├── dsps_add_s16_ae32.S │ │ │ ├── dsps_add_s16_aes3.S │ │ │ ├── dsps_add_s16_ansi.c │ │ │ ├── dsps_add_s8_aes3.S │ │ │ └── dsps_add_s8_ansi.c │ │ ├── float │ │ │ ├── dsps_add_f32_ae32.S │ │ │ └── dsps_add_f32_ansi.c │ │ ├── include │ │ │ ├── dsps_add.h │ │ │ └── dsps_add_platform.h │ │ └── test │ │ │ ├── test_dsps_add_f32_ansi.c │ │ │ ├── test_dsps_add_s16_ae32.c │ │ │ ├── test_dsps_add_s16_aes3.c │ │ │ ├── test_dsps_add_s16_ansi.c │ │ │ ├── test_dsps_add_s8_aes3.c │ │ │ └── test_dsps_add_s8_ansi.c │ ├── addc │ │ ├── float │ │ │ ├── dsps_addc_f32_ae32.S │ │ │ └── dsps_addc_f32_ansi.c │ │ ├── include │ │ │ ├── dsps_addc.h │ │ │ └── dsps_addc_platform.h │ │ └── test │ │ │ └── test_dsps_addc_f32_ansi.c │ ├── include │ │ └── dsps_math.h │ ├── mul │ │ ├── fixed │ │ │ ├── dsps_mul_s16_ae32.S │ │ │ ├── dsps_mul_s16_aes3.S │ │ │ ├── dsps_mul_s16_ansi.c │ │ │ ├── dsps_mul_s8_aes3.S │ │ │ └── dsps_mul_s8_ansi.c │ │ ├── float │ │ │ ├── dsps_mul_f32_ae32.S │ │ │ └── dsps_mul_f32_ansi.c │ │ ├── include │ │ │ ├── dsps_mul.h │ │ │ └── dsps_mul_platform.h │ │ └── test │ │ │ ├── test_dsps_mul_f32_ansi.c │ │ │ ├── test_dsps_mul_s16_ae32.c │ │ │ ├── test_dsps_mul_s16_aes3.c │ │ │ ├── test_dsps_mul_s16_ansi.c │ │ │ ├── test_dsps_mul_s8_aes3.c │ │ │ └── test_dsps_mul_s8_ansi.c │ ├── mulc │ │ ├── fixed │ │ │ ├── dsps_mulc_s16_ae32.S │ │ │ └── dsps_mulc_s16_ansi.c │ │ ├── float │ │ │ ├── dsps_mulc_f32_ae32.S │ │ │ └── dsps_mulc_f32_ansi.c │ │ ├── include │ │ │ ├── dsps_mulc.h │ │ │ └── dsps_mulc_platform.h │ │ └── test │ │ │ ├── test_dsps_mulc_f32_ansi.c │ │ │ ├── test_dsps_mulc_s16_ae32.c │ │ │ └── test_dsps_mulc_s16_ansi.c │ ├── sqrt │ │ ├── float │ │ │ └── dsps_sqrt_f32_ansi.c │ │ ├── include │ │ │ └── dsps_sqrt.h │ │ └── test │ │ │ └── test_dsps_sqrt_f32_ansi.c │ └── sub │ │ ├── fixed │ │ ├── dsps_sub_s16_ae32.S │ │ ├── dsps_sub_s16_aes3.S │ │ ├── dsps_sub_s16_ansi.c │ │ ├── dsps_sub_s8_aes3.S │ │ └── dsps_sub_s8_ansi.c │ │ ├── float │ │ ├── dsps_sub_f32_ae32.S │ │ └── dsps_sub_f32_ansi.c │ │ ├── include │ │ ├── dsps_sub.h │ │ └── dsps_sub_platform.h │ │ └── test │ │ ├── test_dsps_sub_f32_ansi.c │ │ ├── test_dsps_sub_s16_ae32.c │ │ ├── test_dsps_sub_s16_aes3.c │ │ ├── test_dsps_sub_s16_ansi.c │ │ ├── test_dsps_sub_s8_aes3.c │ │ └── test_dsps_sub_s8_ansi.c ├── matrix │ ├── add │ │ ├── float │ │ │ ├── dspm_add_f32_ae32.S │ │ │ └── dspm_add_f32_ansi.c │ │ ├── include │ │ │ ├── dspm_add.h │ │ │ └── dspm_add_platform.h │ │ └── test │ │ │ ├── test_dspm_add_f32_ae32.cpp │ │ │ └── test_dspm_add_f32_ansi.cpp │ ├── addc │ │ ├── float │ │ │ ├── dspm_addc_f32_ae32.S │ │ │ └── dspm_addc_f32_ansi.c │ │ ├── include │ │ │ ├── dspm_addc.h │ │ │ └── dspm_addc_platform.h │ │ └── test │ │ │ └── test_dspm_addc_f32_ansi.cpp │ ├── include │ │ ├── dspm_matrix.h │ │ └── mat.h │ ├── mat │ │ └── mat.cpp │ ├── mul │ │ ├── fixed │ │ │ ├── dspm_mult_s16_ae32.S │ │ │ ├── dspm_mult_s16_aes3.S │ │ │ ├── dspm_mult_s16_ansi.c │ │ │ ├── dspm_mult_s16_arp4.S │ │ │ ├── dspm_mult_s16_m_ae32.S │ │ │ └── dspm_mult_s16_m_ae32_vector.S │ │ ├── float │ │ │ ├── dspm_mult_3x3x1_f32_ae32.S │ │ │ ├── dspm_mult_3x3x3_f32_ae32.S │ │ │ ├── dspm_mult_4x4x1_f32_ae32.S │ │ │ ├── dspm_mult_4x4x4_f32_ae32.S │ │ │ ├── dspm_mult_ex_f32_ae32.S │ │ │ ├── dspm_mult_ex_f32_aes3.S │ │ │ ├── dspm_mult_ex_f32_ansi.c │ │ │ ├── dspm_mult_ex_f32_arp4.S │ │ │ ├── dspm_mult_f32_ae32.S │ │ │ ├── dspm_mult_f32_aes3.S │ │ │ ├── dspm_mult_f32_ansi.c │ │ │ └── dspm_mult_f32_arp4.S │ │ ├── include │ │ │ ├── dspm_mult.h │ │ │ └── dspm_mult_platform.h │ │ ├── test │ │ │ ├── include │ │ │ │ └── test_mat_common.h │ │ │ ├── test_mat_common.cpp │ │ │ ├── test_mat_f32.cpp │ │ │ ├── test_mat_sub_f32.cpp │ │ │ ├── test_mmult_3x3xx_f32_ae32.c │ │ │ ├── test_mmult_4x4xx_f32_ae32.c │ │ │ ├── test_mmult_ex_f32_aexx.cpp │ │ │ ├── test_mmult_ex_f32_ansi.cpp │ │ │ ├── test_mmult_f32_ae32.c │ │ │ ├── test_mmult_f32_ansi.c │ │ │ ├── test_mmult_s16_ae32.c │ │ │ └── test_mmult_s16_ansi.c │ │ └── test_sim │ │ │ ├── Makefile │ │ │ ├── main.c │ │ │ └── test_mmult.c │ ├── mulc │ │ ├── float │ │ │ ├── dspm_mulc_f32_ae32.S │ │ │ └── dspm_mulc_f32_ansi.c │ │ ├── include │ │ │ ├── dspm_mulc.h │ │ │ └── dspm_mulc_platform.h │ │ └── test │ │ │ └── test_dspm_mulc_f32_ansi.cpp │ └── sub │ │ ├── float │ │ ├── dspm_sub_f32_ae32.S │ │ └── dspm_sub_f32_ansi.c │ │ ├── include │ │ ├── dspm_sub.h │ │ └── dspm_sub_platform.h │ │ └── test │ │ └── test_dspm_sub_f32_ansi.cpp ├── support │ ├── cplx_gen │ │ ├── dsps_cplx_gen.S │ │ ├── dsps_cplx_gen.c │ │ ├── dsps_cplx_gen_init.c │ │ └── test │ │ │ └── test_cplx_gen.c │ ├── include │ │ ├── dsps_cplx_gen.h │ │ ├── dsps_cplx_gen_platform.h │ │ ├── dsps_d_gen.h │ │ ├── dsps_h_gen.h │ │ ├── dsps_sfdr.h │ │ ├── dsps_snr.h │ │ ├── dsps_tone_gen.h │ │ └── dsps_view.h │ ├── mem │ │ ├── esp32s3 │ │ │ ├── dsps_memcpy_aes3.S │ │ │ └── dsps_memset_aes3.S │ │ ├── include │ │ │ ├── dsps_mem.h │ │ │ └── dsps_mem_platform.h │ │ └── test │ │ │ └── test_dsps_memcpy_memset.c │ ├── misc │ │ ├── dsps_d_gen.c │ │ ├── dsps_h_gen.c │ │ └── dsps_tone_gen.c │ ├── sfdr │ │ ├── float │ │ │ └── dsps_sfdr_f32.cpp │ │ └── test │ │ │ └── test_dsps_sfdr_f32.c │ ├── snr │ │ ├── float │ │ │ └── dsps_snr_f32.cpp │ │ └── test │ │ │ └── test_dsps_snr_f32.c │ └── view │ │ ├── dsps_view.cpp │ │ └── test │ │ └── test_dsps_view.c └── windows │ ├── blackman │ ├── float │ │ └── dsps_wind_blackman_f32.c │ └── include │ │ └── dsps_wind_blackman.h │ ├── blackman_harris │ ├── float │ │ └── dsps_wind_blackman_harris_f32.c │ └── include │ │ └── dsps_wind_blackman_harris.h │ ├── blackman_nuttall │ ├── float │ │ └── dsps_wind_blackman_nuttall_f32.c │ └── include │ │ └── dsps_wind_blackman_nuttall.h │ ├── flat_top │ ├── float │ │ └── dsps_wind_flat_top_f32.c │ └── include │ │ └── dsps_wind_flat_top.h │ ├── hann │ ├── float │ │ └── dsps_wind_hann_f32.c │ └── include │ │ └── dsps_wind_hann.h │ ├── include │ └── dsps_wind.h │ ├── nuttall │ ├── float │ │ └── dsps_wind_nuttall_f32.c │ └── include │ │ └── dsps_wind_nuttall.h │ └── test │ └── test_wind_f32.c ├── test ├── CMakeLists.txt ├── component.mk ├── linker.lf ├── prepare_csv_benchmarks.c ├── report.inc └── test_dsp.c └── test_app ├── CMakeLists.txt ├── Makefile ├── main ├── CMakeLists.txt ├── component.mk └── test_app_main.c ├── pytest.ini ├── pytest_esp-dsp_unity_tests.py └── sdkconfig.defaults /.github/ISSUE_TEMPLATE/01_other_issue.yml: -------------------------------------------------------------------------------- 1 | name: General issue report 2 | description: File an issue report 3 | body: 4 | - type: checkboxes 5 | id: checklist 6 | attributes: 7 | label: Answers checklist. 8 | description: Before submitting a new issue, please follow the checklist and try to find the answer. 9 | options: 10 | - label: I have read the [ESP-DSP documentation](https://docs.espressif.com/projects/esp-dsp/en/latest/esp-dsp-library.html/) and the issue is not addressed there. 11 | required: true 12 | - label: I have read the documentation [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/) and the issue is not addressed there. 13 | required: true 14 | - label: I have updated my ESP-DSP branch (master or release) to the latest version and checked that the issue is present there. 15 | required: true 16 | - label: I have searched the issue tracker for a similar issue and not found a similar issue. 17 | required: true 18 | - type: textarea 19 | id: issue 20 | attributes: 21 | label: General issue report 22 | description: Your issue report goes here. 23 | placeholder: ex. How do I run... 24 | validations: 25 | required: true 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/03_feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for this project. 3 | labels: ["Type: Feature Request"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | * We welcome any ideas or feature requests! It’s helpful if you can explain exactly why the feature would be useful. 9 | * There are usually some outstanding feature requests in the [existing issues list](https://github.com/espressif/esp-dsp/labels/Type%3A%20Feature%20Request), feel free to add comments to them. 10 | * If you would like to contribute, please read the [contributions guide](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/contribute/index.html). 11 | - type: textarea 12 | id: problem-related 13 | attributes: 14 | label: Is your feature request related to a problem? 15 | description: Please provide a clear and concise description of what the problem is. 16 | placeholder: ex. I'm always frustrated when ... 17 | - type: textarea 18 | id: solution 19 | attributes: 20 | label: Describe the solution you'd like. 21 | description: Please provide a clear and concise description of what you want to happen. 22 | placeholder: ex. When connecting to an Espressif chip ... 23 | - type: textarea 24 | id: alternatives 25 | attributes: 26 | label: Describe alternatives you've considered. 27 | description: Please provide a clear and concise description of any alternative solutions or features you've considered. 28 | placeholder: ex. Choosing other approach wouldn't work, because ... 29 | - type: textarea 30 | id: context 31 | attributes: 32 | label: Additional context. 33 | description: Please add any other context or screenshots about the feature request here. 34 | placeholder: ex. This would work only when ... 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: ESP-DSP Documentation 4 | url: https://docs.espressif.com/projects/esp-dsp/en/latest/esp32/esp-dsp-library.html 5 | about: Documentation for ESP-DSP 6 | - name: ESP-IDF Programming Guide 7 | url: https://docs.espressif.com/projects/esp-idf/en/latest/ 8 | about: Documentation for configuring and using ESP-IDF 9 | - name: Espressif documentation page 10 | url: https://www.espressif.com/en/support/download/documents 11 | about: Hardware documentation (datasheets, Technical Reference Manual, etc) 12 | - name: Forum 13 | url: https://esp32.com 14 | about: For questions about using ESP-IDF and/or ESP32 series chips. Please submit all questions starting "How do I..." here. 15 | - name: Hardware-related services 16 | url: https://www.espressif.com/en/products/hardware-services 17 | about: Espressif service providing hardware design and certification support 18 | -------------------------------------------------------------------------------- /.github/workflows/issue_comment.yml: -------------------------------------------------------------------------------- 1 | name: Sync issue comments to JIRA 2 | 3 | # This workflow will be triggered when new issue comment is created (including PR comments) 4 | on: issue_comment 5 | 6 | jobs: 7 | sync_issue_comments_to_jira: 8 | name: Sync Issue Comments to Jira 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: Sync issue comments to JIRA 13 | uses: espressif/github-actions/sync_issues_to_jira@master 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | JIRA_PASS: ${{ secrets.JIRA_PASS }} 17 | JIRA_PROJECT: DSP 18 | JIRA_COMPONENT: GitHub 19 | JIRA_URL: ${{ secrets.JIRA_URL }} 20 | JIRA_USER: ${{ secrets.JIRA_USER }} 21 | -------------------------------------------------------------------------------- /.github/workflows/new_issues.yml: -------------------------------------------------------------------------------- 1 | name: Sync issues to Jira 2 | 3 | # This workflow will be triggered when a new issue is opened 4 | on: issues 5 | 6 | jobs: 7 | sync_issues_to_jira: 8 | name: Sync issues to Jira 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: Sync GitHub issues to Jira project 13 | uses: espressif/github-actions/sync_issues_to_jira@master 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | JIRA_PASS: ${{ secrets.JIRA_PASS }} 17 | JIRA_PROJECT: DSP 18 | JIRA_COMPONENT: GitHub 19 | JIRA_URL: ${{ secrets.JIRA_URL }} 20 | JIRA_USER: ${{ secrets.JIRA_USER }} -------------------------------------------------------------------------------- /.github/workflows/new_prs.yml: -------------------------------------------------------------------------------- 1 | name: Sync remain PRs to Jira 2 | 3 | # This workflow will be triggered every hour, to sync remaining PRs (i.e. PRs with zero comment) to Jira project 4 | # Note that, PRs can also get synced when new PR comment is created 5 | on: 6 | schedule: 7 | - cron: '0 * * * *' 8 | 9 | jobs: 10 | sync_prs_to_jira: 11 | name: Sync PRs to Jira 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@master 15 | - name: Sync PRs to Jira project 16 | uses: espressif/github-actions/sync_issues_to_jira@master 17 | with: 18 | cron_job: true 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | JIRA_PASS: ${{ secrets.JIRA_PASS }} 22 | JIRA_PROJECT: DSP 23 | JIRA_COMPONENT: GitHub 24 | JIRA_URL: ${{ secrets.JIRA_URL }} 25 | JIRA_USER: ${{ secrets.JIRA_USER }} 26 | -------------------------------------------------------------------------------- /.github/workflows/upload_component.yml: -------------------------------------------------------------------------------- 1 | name: Push component to https://components.espressif.com 2 | on: 3 | push: 4 | tags: 5 | - v* 6 | jobs: 7 | upload_components: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | with: 12 | submodules: "recursive" 13 | - name: Upload component to the component registry 14 | uses: espressif/upload-components-ci-action@v1 15 | with: 16 | name: "esp-dsp" 17 | version: ${{ github.ref_name }} 18 | namespace: "espressif" 19 | api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .config 2 | *.o 3 | *.pyc 4 | 5 | # gtags 6 | GTAGS 7 | GRTAGS 8 | GPATH 9 | 10 | # emacs 11 | .dir-locals.el 12 | 13 | # emacs temp file suffixes 14 | *~ 15 | .#* 16 | \#*# 17 | 18 | # eclipse setting 19 | .settings 20 | 21 | # MacOS directory files 22 | .DS_Store 23 | 24 | # Example project files 25 | examples/**/sdkconfig 26 | examples/**/sdkconfig.old 27 | examples/**/build 28 | examples/**/dependencies.lock 29 | exmaples/**/managed_components 30 | 31 | # Test app files 32 | test_app/build 33 | test_app/sdkconfig 34 | test_app/sdkconfig.old 35 | test_app/dependencies.lock 36 | 37 | # Doc build artifacts 38 | docs/_build/ 39 | docs/doxygen-warning-log.txt 40 | docs/sphinx-warning-log.txt 41 | docs/sphinx-warning-log-sanitized.txt 42 | docs/xml/ 43 | docs/xml_in/ 44 | docs/man/ 45 | docs/doxygen_sqlite3.db 46 | 47 | TEST_LOGS 48 | 49 | 50 | # gcov coverage reports 51 | *.gcda 52 | *.gcno 53 | coverage.info 54 | coverage_report/ 55 | 56 | # VS Code Settings 57 | .vscode/ 58 | 59 | # incorrect build locations 60 | build/ 61 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/espressif/astyle_py 3 | rev: v1.0.5 4 | hooks: 5 | - id: astyle_py 6 | args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper'] 7 | 8 | - repo: https://github.com/pre-commit/pre-commit-hooks 9 | rev: v4.3.0 10 | hooks: 11 | - id: trailing-whitespace 12 | types_or: [c, c++] 13 | - id: end-of-file-fixer 14 | types_or: [c, c++] 15 | - id: check-merge-conflict 16 | - id: mixed-line-ending 17 | types_or: [c, c++] 18 | args: ['--fix=lf'] 19 | description: Forces to replace line ending by the UNIX 'lf' character 20 | -------------------------------------------------------------------------------- /Kconfig: -------------------------------------------------------------------------------- 1 | menu "DSP Library" 2 | 3 | 4 | config DSP_OPTIMIZATIONS_SUPPORTED 5 | bool 6 | default y 7 | depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32P4 8 | 9 | choice DSP_OPTIMIZATION 10 | bool "DSP Optimization" 11 | default DSP_OPTIMIZED if DSP_OPTIMIZATIONS_SUPPORTED 12 | default DSP_ANSI 13 | help 14 | An ANSI C version could be used for verification and debug purpose, 15 | or for chips where an optimized version is not available. 16 | 17 | config DSP_ANSI 18 | bool "ANSI C" 19 | config DSP_OPTIMIZED 20 | bool "Optimized" 21 | depends on DSP_OPTIMIZATIONS_SUPPORTED 22 | endchoice 23 | 24 | config DSP_OPTIMIZATION 25 | int 26 | default 0 if DSP_ANSI 27 | default 1 if DSP_OPTIMIZED 28 | 29 | choice DSP_MAX_FFT_SIZE 30 | bool "Maximum FFT length" 31 | default DSP_MAX_FFT_SIZE_4096 32 | help 33 | This is default FFT size for internal usage. 34 | 35 | config DSP_MAX_FFT_SIZE_512 36 | bool "512" 37 | config DSP_MAX_FFT_SIZE_1024 38 | bool "1024" 39 | config DSP_MAX_FFT_SIZE_2048 40 | bool "2048" 41 | config DSP_MAX_FFT_SIZE_4096 42 | bool "4096" 43 | config DSP_MAX_FFT_SIZE_8192 44 | bool "8192" 45 | config DSP_MAX_FFT_SIZE_16384 46 | bool "16384" 47 | config DSP_MAX_FFT_SIZE_32768 48 | bool "32768" 49 | endchoice 50 | 51 | config DSP_MAX_FFT_SIZE 52 | int 53 | default 512 if DSP_MAX_FFT_SIZE_512 54 | default 1024 if DSP_MAX_FFT_SIZE_1024 55 | default 2048 if DSP_MAX_FFT_SIZE_2048 56 | default 4096 if DSP_MAX_FFT_SIZE_4096 57 | default 8192 if DSP_MAX_FFT_SIZE_8192 58 | default 16384 if DSP_MAX_FFT_SIZE_16384 59 | default 32768 if DSP_MAX_FFT_SIZE_32768 60 | 61 | endmenu 62 | -------------------------------------------------------------------------------- /applications/README.md: -------------------------------------------------------------------------------- 1 | # ESP-DSP Applications 2 | 3 | This directory contains a range of applications for ESP-DSP library. 4 | 5 | These applications are intended to demonstrate part of ESP-DSP functionality (e.g. initialization, execution) and to provide examples of fully working projects built using ESP-DSP component 6 | 7 | See the [README.md](../README.md) file in the upper level directory for more information about ESP-DSP. 8 | 9 | # Applications Layout 10 | 11 | The applications are grouped into subdirectories by category. Each category directory contains one or more projects: 12 | 13 | * [ESP32-Azure IoT kit](./azure_board_apps/README.md) applications 14 | * [3d graphics](./azure_board_apps/apps/3d_graphics/README.md) application 15 | * [Kalman filter](./azure_board_apps/apps/kalman_filter/README.md) application 16 | 17 | * [LyraT Board](./lyrat_board_app/README.md) application 18 | * [ESP32-S3-BOX-Lite](./spectrum_box_lite/README.md) application 19 | 20 | 21 | -------------------------------------------------------------------------------- /applications/azure_board_apps/.gitignore: -------------------------------------------------------------------------------- 1 | **/build/ 2 | **/sdkconfig 3 | **/sdkconfig.old 4 | **/dependencies.lock 5 | **/managed_components/** 6 | -------------------------------------------------------------------------------- /applications/azure_board_apps/README.md: -------------------------------------------------------------------------------- 1 | # ESP-DSP ESP32-Azure IoT kit demo applications 2 | 3 | The demo applications are developed for ESP32-Azure IoT kit development board and are demonstrating usage of matrices with ESP-DPS Mat class, Kalman filter and basic 4 | 3D projection with matrices 5 | 6 | ### [3D Graphics demo](apps/3d_graphics) 7 | * a simple rotation of a selected 3D objects is shown on the display 8 | * demonstrating usage the Mat class, matrices and operations with matrices 9 | 10 |
11 | 12 |
13 | 14 | ### [Kalman filter demo](apps/kalman_filter/) 15 | * a selected 3D object is following movements of the development board with IMU sensors 16 | * the sensors outputs are processed by the Kalman filter 17 | * demonstrating usage the Mat class, matrices, operations with matrices and Kalman filter 18 | 19 |
20 | 21 |
22 | 23 | ### [3D graphics](graphics/img_to_3d_matrix/example/) 24 | 25 | Simple 3D graphics is used in the both demos, to display the 3D on the monochromatic display. The Graphics is using transformation matrices to rotate, scale and translate (move) 3D objects, to show the matrix calculation capabilities of the ESP-DSP repository. 26 | 27 | ## Used components 28 | * [ESP-DSP](https://github.com/espressif/esp-dsp): matrices, Mat class, Kalman filter 29 | * [ESP-BSP](https://github.com/espressif/esp-bsp): ESP32-Azure IoT kit -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/3d_graphics/3d_graphics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/applications/azure_board_apps/apps/3d_graphics/3d_graphics.gif -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/3d_graphics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.5) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | add_compile_options("-Wno-format") 8 | project(esp-dsp-azure-board-app-3d-graphics) 9 | -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/3d_graphics/README.md: -------------------------------------------------------------------------------- 1 | # ESP-DSP ESP32-Azure IoT kit 3d graphics demo application 2 | 3 | The demo is developed for [ESP32-Azure IoT kit](https://github.com/espressif/esp-bsp/tree/master/esp32_azure_iot_kit) development board and is demonstrating the usage of matrices with `ESP-DSP` `Mat` class, Kalman filter and basic 3D graphics. 4 | 5 | The 3D Graphics demo displays a 2D graphics, converted to 3D as a 3D rotating object, on the development board's display. Button press changes the rotation direction of the 3D object. Run the menuconfig using the following command: 6 | 7 | idf.py mencuonfig 8 | 9 | In the menuconfig's menu item `Demo user configuration` select which 3D object to display. It's either a 3D cube, or ESP logo, or a user-defined graphics. Getting the user-defined graphics is described in an [example](../../graphics/img_to_3d_matrix/example/) 10 | 11 | ## Running the demo 12 | 13 | To start the demo, run the following command: 14 | 15 | idf.py build flash monitor 16 | 17 | The expected output is the following: 18 | 19 | I (570) 3D image demo: Selected 3D image - ESP Logo 20 | I (570) 3D image demo: Showing ESP text 21 | I (6730) 3D image demo: Showing 3D image 22 | 23 | Note, that the first line `Selected 3D image` from the expected output depends on the user's Kconfing menu selection 24 | 25 |
26 | 27 |
28 | -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/3d_graphics/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "3d_graphics_demo.cpp" 2 | "../../../graphics/3d_matrix/3d_matrix_data/esp_logo.c" 3 | "../../../graphics/3d_matrix/3d_matrix_data/esp_text.c" 4 | "../../../graphics/3d_matrix/3d_matrix_data/image_to_3d_matrix.c" 5 | "../../../graphics/3d_matrix/3d_matrix_src/graphics_support.cpp" 6 | INCLUDE_DIRS "." 7 | "../../../graphics/3d_matrix/3d_matrix_data" 8 | "../../../graphics/3d_matrix/3d_matrix_src") 9 | -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/3d_graphics/main/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "Demo user configuration" 2 | choice 3 | prompt "Select 3D object" 4 | config 3D_OBJECT_CUBE 5 | bool "3D cube" 6 | help 7 | 3D graphics to be displayed is cube 8 | 9 | config 3D_OBJECT_ESP_LOGO 10 | bool "3D ESP Logo" 11 | help 12 | 3D graphics to be displayed is ESP Logo 13 | 14 | config 3D_OBJECT_CUSTOM 15 | bool "User-defined graphics" 16 | help 17 | 3D graphics to be displayed is a user-defined graphics 18 | endchoice 19 | endmenu -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/3d_graphics/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | description: ESP-DSP azure board application 3d graphics 3 | dependencies: 4 | espressif/esp32_azure_iot_kit: "*" 5 | espressif/esp-dsp: 6 | version: "*" 7 | override_path: "../../../../../../esp-dsp" 8 | 9 | -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/kalman_filter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.5) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | add_compile_options("-Wno-format") 8 | project(esp-dsp-azure-board-app-kalman-filter) 9 | -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/kalman_filter/kalman_filter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/applications/azure_board_apps/apps/kalman_filter/kalman_filter.gif -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/kalman_filter/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "kalman_filter_demo.cpp" 2 | "../../../graphics/3d_matrix/3d_matrix_data/esp_logo.c" 3 | "../../../graphics/3d_matrix/3d_matrix_data/image_to_3d_matrix.c" 4 | "../../../graphics/3d_matrix/3d_matrix_src/graphics_support.cpp" 5 | INCLUDE_DIRS "." 6 | "../../../graphics/3d_matrix/3d_matrix_data" 7 | "../../../graphics/3d_matrix/3d_matrix_src") 8 | -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/kalman_filter/main/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "Demo user configuration" 2 | choice 3 | prompt "Select 3D object" 4 | config 3D_OBJECT_CUBE 5 | bool "3D cube" 6 | help 7 | 3D graphics to be displayed is cube 8 | 9 | config 3D_OBJECT_ESP_LOGO 10 | bool "3D ESP Logo" 11 | help 12 | 3D graphics to be displayed is ESP Logo 13 | 14 | config 3D_OBJECT_CUSTOM 15 | bool "User-defined graphics" 16 | help 17 | 3D graphics to be displayed is a user-defined graphics 18 | endchoice 19 | endmenu -------------------------------------------------------------------------------- /applications/azure_board_apps/apps/kalman_filter/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | description: ESP-DSP azure board application Kalman filter 3 | dependencies: 4 | espressif/esp32_azure_iot_kit: "*" 5 | espressif/esp-dsp: 6 | version: "*" 7 | override_path: "../../../../../../esp-dsp" 8 | 9 | -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/.gitignore: -------------------------------------------------------------------------------- 1 | img_to_3d_matrix/converted_image/** 2 | img_to_3d_matrix/example/*.c 3 | img_to_3d_matrix/example/*.h -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/3d_matrix/3d_matrix_data/esp_logo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | extern const uint8_t image_bmp_array_esp_logo[512]; 17 | extern const float image_3d_matrix_esp_logo[1427][4]; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/3d_matrix/3d_matrix_data/esp_text.h: -------------------------------------------------------------------------------- 1 | // File generated by image_to_3d_array.py 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | extern const uint8_t image_bmp_array_esp_text[384]; 12 | extern const float image_3d_array_esp_text[1271][4]; 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/3d_matrix/3d_matrix_data/image_to_3d_matrix.h: -------------------------------------------------------------------------------- 1 | // File generated by ImgTo3D.py 2 | // Image file converted to 3D matrix: cpu_logo.png 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "sdkconfig.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | extern const uint8_t image_to_bmp_array_custom[512]; 14 | extern const float image_to_3d_matrix_custom[1732][4]; 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/img_to_3d_matrix/example/converted_image/cpu_logo_conv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/applications/azure_board_apps/graphics/img_to_3d_matrix/example/converted_image/cpu_logo_conv.png -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/img_to_3d_matrix/example/converted_image/cpu_logo_invert_conv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/applications/azure_board_apps/graphics/img_to_3d_matrix/example/converted_image/cpu_logo_invert_conv.png -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/img_to_3d_matrix/example/image/cpu_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/applications/azure_board_apps/graphics/img_to_3d_matrix/example/image/cpu_logo.png -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/img_to_3d_matrix/templates/template_img_to_3d.c: -------------------------------------------------------------------------------- 1 | // template file - template_img_to_3d.c 2 | // arrays declarations will be modified by python script ImgTo3D.py 3 | 4 | #include "image_to_3d_matrix.h" 5 | 6 | #ifdef CONFIG_3D_OBJECT_CUSTOM 7 | 8 | const uint8_t TEMPLATE_ARRAY_BMP_IMAGE[NUM_OF_BYTES] = {}; 9 | const float TEMPLATE_ARRAY_IMAGE_TO_3D_MATRIX[NUM_OF_POINTS][4] = {}; 10 | 11 | #endif // CONFIG_3D_OBJECT_CUSTOM 12 | -------------------------------------------------------------------------------- /applications/azure_board_apps/graphics/img_to_3d_matrix/templates/template_img_to_3d.h: -------------------------------------------------------------------------------- 1 | // template file - template_img_to_3d.h 2 | // arrays declarations will be modified by python script ImgTo3D.py 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "sdkconfig.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | extern const uint8_t TEMPLATE_ARRAY_BMP_IMAGE[NUM_OF_BYTES]; 14 | extern const float TEMPLATE_ARRAY_IMAGE_TO_3D_MATRIX[NUM_OF_POINTS][4]; 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /applications/lyrat_board_app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(audio-lyraT) 7 | spiffs_create_partition_image(storage spiffs FLASH_IN_PROJECT) 8 | -------------------------------------------------------------------------------- /applications/lyrat_board_app/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "audio_amp_main.c") 2 | -------------------------------------------------------------------------------- /applications/lyrat_board_app/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp32_lyrat: "^1.0.0" 3 | espressif/esp-dsp: 4 | version: '*' 5 | override_path: "../../../../esp-dsp" 6 | -------------------------------------------------------------------------------- /applications/lyrat_board_app/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 1M, 6 | storage, data, spiffs, , 0x2f0000, 7 | -------------------------------------------------------------------------------- /applications/lyrat_board_app/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration 3 | # 4 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 5 | CONFIG_PARTITION_TABLE_CUSTOM=y 6 | CONFIG_SPIRAM=y 7 | CONFIG_SPIRAM_USE_MEMMAP=y 8 | CONFIG_SPIFFS_PAGE_SIZE=1024 9 | -------------------------------------------------------------------------------- /applications/lyrat_board_app/spiffs/16bit_mono_44_1_khz.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/applications/lyrat_board_app/spiffs/16bit_mono_44_1_khz.wav -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/3d_graphics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.5) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | add_compile_options("-Wno-format") 8 | project(esp-dsp-m5stack-3d-graphics) 9 | -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/3d_graphics/README.md: -------------------------------------------------------------------------------- 1 | # ESP-DSP M5Stack Core s3 board 3d graphics demo application 2 | 3 | The demo is developed for [M5Stack Core S3 board](https://docs.m5stack.com/en/core/CoreS3) development board and is demonstrating the usage of matrices with `ESP-DSP` `Mat` class, Kalman filter and basic 3D graphics. 4 | 5 | The 3D Graphics demo displays a 2D graphics, converted to 3D as a 3D rotating object, on the development board's display. 6 | 7 | ## Running the demo 8 | 9 | To start the demo, run the following command: 10 | 11 | idf.py build flash monitor 12 | 13 | The expected output is the following: 14 | 15 | I (2103) gpio: GPIO[35]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 16 | I (2103) ili9341: LCD panel create success, version: 1.2.0 17 | I (3263) 3D image demo: Showing 3D image 18 | 19 | -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/3d_graphics/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "3d_graphics_demo.cpp" 2 | "init_display.c" 3 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data/esp_logo.c" 4 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data/esp_text.c" 5 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data/image_to_3d_matrix.c" 6 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_src/graphics_support.cpp" 7 | INCLUDE_DIRS "." 8 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data" 9 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_src") 10 | 11 | # We add this definition to be compatible with demo 12 | add_compile_definitions(CONFIG_3D_OBJECT_ESP_LOGO=y) -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/3d_graphics/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | description: ESP-DSP azure board application 3d graphics 3 | dependencies: 4 | espressif/esp-dsp: 5 | version: '*' 6 | override_path: ../../../../../../esp-dsp 7 | 8 | espressif/m5stack_core_s3: '*' 9 | -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/kalman_filter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.5) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | add_compile_options("-Wno-format") 8 | project(esp-dsp-m5stack-3d-kalman) 9 | -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/kalman_filter/README.md: -------------------------------------------------------------------------------- 1 | # ESP-DSP M5Stack Code S3 3d graphics demo application 2 | 3 | The demo is developed for [M5Stack Core S3 board](https://docs.m5stack.com/en/core/CoreS3) development board and is demonstrating the usage of matrices with `ESP-DSP` `Mat` class, Kalman filter and basic 3D graphics. 4 | The demo is showing the basic use case of bmi270 and bmm150 sensors with esp-idf. 5 | 6 | The 3D Graphics demo displays a 2D graphics, converted to 3D as a 3D rotating object, on the development board's display. 7 | 8 | ## Running the demo 9 | 10 | To start the demo, run the following command: 11 | 12 | idf.py build flash monitor 13 | 14 | The expected output is the following: 15 | 16 | I (2097) ili9341: LCD panel create success, version: 1.2.0 17 | I (2367) 3d-kalman: bmi270 ChipID = 0x24 (should be 0x24), err = 00 18 | I (2377) 3d-kalman: bmm150 chip ID = 0x32 (should be 0x32), err = 00 19 | I (2387) 3d-kalman: bmi270 status = 01 20 | I (3267) 3d-kalman: bmi270 status = 01 21 | I (3277) 3d-kalman: bmi270 initialization is done 22 | I (4277) 3d-kalman: Showing 3D image 23 | I (4277) main_task: Returned from app_main() 24 | 25 | Note, that the first line `Selected 3D image` from the expected output depends on the user's Kconfing menu selection 26 | -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/kalman_filter/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "3d_kalman_demo.cpp" 2 | "bmi270_context.c" 3 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data/esp_logo.c" 4 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data/esp_text.c" 5 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data/image_to_3d_matrix.c" 6 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_src/graphics_support.cpp" 7 | INCLUDE_DIRS "." 8 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_data" 9 | "../../../../azure_board_apps/graphics/3d_matrix/3d_matrix_src") 10 | 11 | add_compile_definitions(CONFIG_3D_OBJECT_CUBE=y) -------------------------------------------------------------------------------- /applications/m5stack_core_s3/apps/kalman_filter/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | description: ESP-DSP azure board application 3d graphics 3 | dependencies: 4 | espressif/esp-dsp: 5 | version: '*' 6 | override_path: ../../../../../../esp-dsp 7 | 8 | espressif/m5stack_core_s3: '*' 9 | -------------------------------------------------------------------------------- /applications/spectrum_box_lite/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.16) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(spectrum_box_lite) 9 | -------------------------------------------------------------------------------- /applications/spectrum_box_lite/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "main.c" 2 | INCLUDE_DIRS ".") 3 | -------------------------------------------------------------------------------- /applications/spectrum_box_lite/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-box-lite: "^2.0.3" 3 | lvgl/lvgl: "^8.3.10" 4 | espressif/esp-dsp: 5 | version: '*' 6 | override_path: "../../../../esp-dsp" 7 | -------------------------------------------------------------------------------- /docs/_static/esp-dsp_docs_versions.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_VERSIONS = { 2 | DEFAULTS: { has_targets: false, 3 | supported_targets: [ "esp32" ] 4 | }, 5 | VERSIONS: [ 6 | { name: "latest" }, 7 | { name: "v1.4.2", old:false }, 8 | { name: "v1.2.1", old:true }, 9 | { name: "v1.1.0", old:true } 10 | ], 11 | IDF_TARGETS: [ 12 | { text: "all targets", value: "esp32"}, 13 | ] 14 | }; 15 | -------------------------------------------------------------------------------- /docs/conf_common.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Common (non-language-specific) configuration for Sphinx 4 | # 5 | 6 | # type: ignore 7 | # pylint: disable=wildcard-import 8 | # pylint: disable=undefined-variable 9 | 10 | from __future__ import print_function, unicode_literals 11 | 12 | from esp_docs.conf_docs import * # noqa: F403,F401 13 | 14 | extensions += ['sphinx_copybutton', 15 | # Needed as a trigger for running doxygen 16 | 'esp_docs.esp_extensions.dummy_build_system', 17 | 'esp_docs.esp_extensions.run_doxygen' 18 | ] 19 | 20 | # link roles config 21 | github_repo = 'espressif/esp-dsp' 22 | 23 | # context used by sphinx_idf_theme 24 | html_context['github_user'] = 'espressif' 25 | html_context['github_repo'] = 'esp-dsp' 26 | html_static_path = ['../_static'] 27 | 28 | # Extra options required by sphinx_idf_theme 29 | project_slug = 'esp-dsp' 30 | versions_url = './_static/esp-dsp_docs_versions.js' 31 | 32 | idf_targets = ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4', 'esp32c5'] 33 | languages = ['en'] 34 | -------------------------------------------------------------------------------- /docs/en/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # English Language RTD & Sphinx config file 4 | # 5 | # Uses ../conf_common.py for most non-language-specific settings. 6 | 7 | # Importing conf_common adds all the non-language-specific 8 | # parts to this conf module 9 | try: 10 | from conf_common import * # noqa: F403,F401 11 | except ImportError: 12 | import os 13 | import sys 14 | sys.path.insert(0, os.path.abspath('../')) 15 | from conf_common import * # noqa: F403,F401 16 | 17 | import datetime 18 | 19 | current_year = datetime.datetime.now().year 20 | 21 | # General information about the project. 22 | project = u'Espressif DSP Library' 23 | copyright = u'2019 - {}, Espressif Systems (Shanghai) Co., Ltd'.format(current_year) 24 | 25 | # The language for content autogenerated by Sphinx. Refer to documentation 26 | # for a list of supported languages. 27 | language = 'en' 28 | -------------------------------------------------------------------------------- /docs/en/esp-dsp-applications.rst: -------------------------------------------------------------------------------- 1 | ESP-DSP Applications 2 | ==================== 3 | 4 | This directory contains a range of applications for ESP-DSP library. 5 | 6 | These applications are intended to demonstrate part of ESP-DSP functionality (e.g. initialization, execution) and to provide examples of fully working projects built using ESP-DSP component 7 | 8 | See the [:project_file:`README.md`] file in the upper level directory for more information about ESP-DSP. 9 | 10 | Applications Layout 11 | +++++++++++++++++++ 12 | 13 | 14 | The applications are grouped into subdirectories by category. Each category directory contains one or more projects: 15 | 16 | * ESP32-Azure IoT kit applications (:project_file:`applications/azure_board_apps/README.md` for more details) 17 | * 3D graphics (:project_file:`applications/azure_board_apps/apps/3d_graphics/README.md` for more details) 18 | * Kalman filter (:project_file:`applications/azure_board_apps/apps/kalman_filter/README.md` for more details) 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/en/index.rst: -------------------------------------------------------------------------------- 1 | ESP-DSP Library 2 | *************** 3 | The ESP-DSP it’s a C/C++ library that contains functions and classes for high performance calculations related applications. It includes implementations for different functionality, like: matrix multiplication, FFTs, filters, vector math operations and support functions for DSP applications development. 4 | 5 | The library also includes examples of how to use the library. 6 | 7 | The ESP-DSP it’s the official DSP library for the Espressif chips. It contains optimized versions for ESP32 and ESP32-S3 chips, and will contain optimized versions for the new chips. 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | 12 | Introduction 13 | Benchmarks 14 | Examples 15 | Applications 16 | API Reference 17 | -------------------------------------------------------------------------------- /docs/esp-dsp-benchmarks_template.rst: -------------------------------------------------------------------------------- 1 | Espressif DSP Library Benchmarks 2 | ================================ 3 | 4 | The table bellow contains benchmarks of functions provided by ESP-DSP library. The values are CPU cycle counts taken to execute each of the functions. 5 | The Values in the column "O2" are made with compiler optimization for speed, and in the column "Os" column are made with compiler optimization for size. 6 | The values in "ESP32", "ESP32S3" and "ESP32P4" columns are for the optimized (assembly) implementation, values in "ANSI" column are for the non-optimized implementation. 7 | 8 | MAIN_TABLE 9 | 10 | The benchmark test could be reproduced by executing test cases found in :project_file:`/test/test_dsp.c`. 11 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # This is a list of python packages used to generate documentation. This file is used with pip: 2 | # pip install --user -r requirements.txt 3 | # 4 | esp-docs==0.2.4 -------------------------------------------------------------------------------- /docs/utils.sh: -------------------------------------------------------------------------------- 1 | # Bash helper functions for adding SSH keys 2 | 3 | function add_ssh_keys() { 4 | local key_string="${1}" 5 | mkdir -p ~/.ssh 6 | chmod 700 ~/.ssh 7 | echo -n "${key_string}" >~/.ssh/id_rsa_base64 8 | base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 >~/.ssh/id_rsa 9 | chmod 600 ~/.ssh/id_rsa 10 | } 11 | 12 | function add_doc_server_ssh_keys() { 13 | local key_string="${1}" 14 | local server_url="${2}" 15 | local server_user="${3}" 16 | add_ssh_keys "${key_string}" 17 | echo -e "Host ${server_url}\n\tStrictHostKeyChecking no\n\tUser ${server_user}\n" >>~/.ssh/config 18 | } 19 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # ESP-DSP Examples 2 | 3 | This directory contains a range of examples for ESP-DSP library. 4 | 5 | These examples are intended to demonstrate part of ESP-DSP functionality (e.g. initialization, execution) and to provide code that you can copy and adapt into your own projects. 6 | 7 | See the [README.md](../README.md) file in the upper level directory for more information about ESP-DSP. 8 | 9 | # Example Layout 10 | 11 | The examples are grouped into subdirectories by category. Each category directory contains one or more example projects: 12 | 13 | * [Dot Product Calculation](./dotprod/README.md) Example 14 | * [Basic Math Operations](./basic_math/README.md) Example 15 | * [FFT](./fft/README.md) Example 16 | * [Matrix](./matrix/README.md) Example 17 | * [FFT Window](./fft_window/README.md) Example 18 | * [IIR Filter](./iir/README.md) Example 19 | * [Kalman Filter](./kalman/README.md) Example 20 | * [FIR Filter](.fir/README.md) Example 21 | * [2D Convolution](./conv2d//README.md) Example 22 | -------------------------------------------------------------------------------- /examples/basic_math/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(basic_math) 7 | -------------------------------------------------------------------------------- /examples/basic_math/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := basic_math 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/basic_math/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_math_main.c") 2 | -------------------------------------------------------------------------------- /examples/basic_math/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/basic_math/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/basic_math/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/conv2d/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following five lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.16) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(conv2d) 7 | -------------------------------------------------------------------------------- /examples/conv2d/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := conv2d 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/conv2d/README.md: -------------------------------------------------------------------------------- 1 | # 2D convolution Example 2 | 3 | (See the README.md file in the upper level 'examples' directory for more information about examples.) 4 | 5 | This example demonstrates how to use 2D convolution dspi_conv_f32 from esp-dsp library. Example does the following steps: 6 | 7 | 1. Initialize the input arrays 8 | 2. Calculate 2D convolution of two images 9 | 10 | The example reproduce the Matlab code: 11 | 12 | ``` 13 | A = ones(8); 14 | B = ones(4); 15 | Csame = conv2(A,B, "same") 16 | 17 | ``` 18 | 19 | 20 | ## How to use example 21 | 22 | ### Hardware required 23 | 24 | This example does not require any special hardware, and can be run on any common development board. 25 | 26 | ### Configure the project 27 | 28 | Under Component Config ---> DSP Library ---> DSP Optimization, it's possible to choose either the optimized or ANSI implementation, to compare them. 29 | 30 | ### Build and flash 31 | 32 | Build the project and flash it to the board, then run monitor tool to view serial output (replace PORT with serial port name): 33 | 34 | ``` 35 | idf.py -p PORT flash monitor 36 | ``` 37 | 38 | (To exit the serial monitor, type ``Ctrl-]``.) 39 | 40 | See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 41 | 42 | ## Example output 43 | 44 | Here is an typical example console output. 45 | 46 | ``` 47 | I (305) main: Start Example. 48 | I (305) main: 2D Convolution reuslt. 49 | [ 0 .. 8, 0]: 9, 12, 12, 12, 12, 12, 9, 6, 50 | [ 0 .. 8, 1]: 12, 16, 16, 16, 16, 16, 12, 8, 51 | [ 0 .. 8, 2]: 12, 16, 16, 16, 16, 16, 12, 8, 52 | [ 0 .. 8, 3]: 12, 16, 16, 16, 16, 16, 12, 8, 53 | [ 0 .. 8, 4]: 12, 16, 16, 16, 16, 16, 12, 8, 54 | [ 0 .. 8, 5]: 12, 16, 16, 16, 16, 16, 12, 8, 55 | [ 0 .. 8, 6]: 9, 12, 12, 12, 12, 12, 9, 6, 56 | [ 0 .. 8, 7]: 6, 8, 8, 8, 8, 8, 6, 4, 57 | ``` 58 | -------------------------------------------------------------------------------- /examples/conv2d/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "conv2d_main.c" 2 | INCLUDE_DIRS ".") 3 | -------------------------------------------------------------------------------- /examples/conv2d/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/conv2d/main/conv2d_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "esp_dsp.h" 4 | #include "dsp_tests.h" 5 | 6 | static const char *TAG = "main"; 7 | 8 | void app_main(void) 9 | { 10 | ESP_LOGI(TAG, "Start Example."); 11 | 12 | int max_N = 100; 13 | 14 | float *data1 = (float *)memalign(16, max_N * sizeof(float)); 15 | float *data2 = (float *)memalign(16, max_N * sizeof(float)); 16 | float *data3 = (float *)memalign(16, max_N * sizeof(float)); 17 | 18 | image2d_t image1 = {data1, 1, 1, 8, 8, 8, 8}; // Image 8x8 19 | image2d_t image2 = {data2, 1, 1, 4, 4, 4, 4}; // Image 4x4 20 | image2d_t image3 = {data3, 1, 1, 10, 10, 0, 0}; // Image 10x10 21 | 22 | for (int i = 0 ; i < max_N ; i++) { 23 | data1[i] = 0; 24 | data2[i] = 0; 25 | data3[i] = 0; 26 | } 27 | 28 | for (int y = 0 ; y < image1.stride_y / image1.step_y ; y++) { 29 | for (int x = 0 ; x < image1.stride_x / image1.step_x ; x++) { 30 | data1[y * image1.stride_x * image1.step_y + x * image1.step_x] = 1; 31 | } 32 | } 33 | for (int y = 0 ; y < image2.stride_y / image2.step_y ; y++) { 34 | for (int x = 0 ; x < image2.stride_x / image2.step_x ; x++) { 35 | data2[y * image2.stride_x * image2.step_y + x * image2.step_x] = 1; 36 | } 37 | } 38 | 39 | dspi_conv_f32(&image1, &image2, &image3); 40 | 41 | ESP_LOGI(TAG, "2D Convolution reuslt."); 42 | 43 | for (int y = 0 ; y < image3.size_y; y++) { 44 | printf("[%2i .. %2i, %2i]: ", 0, image3.size_x, y); 45 | for (int x = 0 ; x < image3.size_x; x++) { 46 | printf("%2.0f, ", data3[y * image3.stride_x * image3.step_y + x * image3.step_x]); 47 | } 48 | printf("\n"); 49 | } 50 | 51 | free(data1); 52 | free(data2); 53 | free(data3); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /examples/conv2d/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/conv2d/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # This file was generated using idf.py save-defconfig. It can be edited manually. 2 | # Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration 3 | # 4 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/dotprod/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(dotprod) 7 | -------------------------------------------------------------------------------- /examples/dotprod/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := dotprod 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/dotprod/README.md: -------------------------------------------------------------------------------- 1 | # Dot Product Calculation Example 2 | 3 | (See the README.md file in the upper level 'examples' directory for more information about examples.) 4 | 5 | This example demonstrates how to use dotprod dsps_dotprod_f32 from esp-dsp library. Example does the following steps: 6 | 7 | 1. Initialize the input arrays 8 | 2. Calculate dot product of two arrays 9 | 3. Compare results and calculate execution time in cycles. 10 | 11 | ## How to use example 12 | 13 | ### Hardware required 14 | 15 | This example does not require any special hardware, and can be run on any common development board. 16 | 17 | ### Configure the project 18 | 19 | Under Component Config ---> DSP Library ---> DSP Optimization, it's possible to choose either the optimized or ANSI implementation, to compare them. 20 | 21 | ### Build and flash 22 | 23 | Build the project and flash it to the board, then run monitor tool to view serial output (replace PORT with serial port name): 24 | 25 | ``` 26 | idf.py -p PORT flash monitor 27 | ``` 28 | 29 | (To exit the serial monitor, type ``Ctrl-]``.) 30 | 31 | See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 32 | 33 | ## Example output 34 | 35 | Here is an typical example console output. 36 | 37 | ``` 38 | I (55) main: Start Example. 39 | I (55) main: The sum of 101 elements from 0..100 = 5050.000000 40 | I (55) main: Operation for 101 samples took 1381 cycles 41 | I (65) main: End Example. 42 | ``` 43 | -------------------------------------------------------------------------------- /examples/dotprod/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_dotproduct_main.c") 2 | -------------------------------------------------------------------------------- /examples/dotprod/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/dotprod/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/dotprod/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/fft/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(fft2r) 7 | -------------------------------------------------------------------------------- /examples/fft/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := fft2r 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/fft/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_fft_main.c") 2 | -------------------------------------------------------------------------------- /examples/fft/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/fft/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/fft/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/fft4real/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(fft4real) 7 | -------------------------------------------------------------------------------- /examples/fft4real/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := fft4real 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/fft4real/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_fft4real_main.c") 2 | -------------------------------------------------------------------------------- /examples/fft4real/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/fft4real/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/fft4real/main/linker.ld: -------------------------------------------------------------------------------- 1 | [mapping:dsp] 2 | archive: libdsp.a 3 | entries: 4 | * (noflash) 5 | 6 | [mapping:esp-dsp] 7 | archive: libesp-dsp.a 8 | entries: 9 | * (noflash) 10 | -------------------------------------------------------------------------------- /examples/fft4real/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/fft_window/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(fft_window) 7 | -------------------------------------------------------------------------------- /examples/fft_window/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := fft_window 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/fft_window/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_window_main.c") 2 | -------------------------------------------------------------------------------- /examples/fft_window/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/fft_window/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/fft_window/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/fir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(fir) 7 | -------------------------------------------------------------------------------- /examples/fir/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := fir 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/fir/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_fir_main.c") 2 | -------------------------------------------------------------------------------- /examples/fir/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/fir/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/fir/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/iir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(iir) 7 | -------------------------------------------------------------------------------- /examples/iir/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := iir 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/iir/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dsps_iir_main.c") 2 | -------------------------------------------------------------------------------- /examples/iir/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/iir/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/iir/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /examples/kalman/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(ekf13states) 7 | -------------------------------------------------------------------------------- /examples/kalman/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := kalman 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/kalman/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "ekf_imu13states_main.cpp") 2 | -------------------------------------------------------------------------------- /examples/kalman/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/kalman/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/kalman/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # 2 | # DSP Library 3 | # 4 | # CONFIG_DSP_ANSI is not set 5 | CONFIG_DSP_OPTIMIZED=y 6 | # CONFIG_DSP_MAX_FFT_SIZE_512 is not set 7 | # CONFIG_DSP_MAX_FFT_SIZE_1024 is not set 8 | # CONFIG_DSP_MAX_FFT_SIZE_2048 is not set 9 | CONFIG_DSP_MAX_FFT_SIZE_4096=y 10 | # CONFIG_DSP_MAX_FFT_SIZE_8192 is not set 11 | # CONFIG_DSP_MAX_FFT_SIZE_16384 is not set 12 | # CONFIG_DSP_MAX_FFT_SIZE_32768 is not set 13 | CONFIG_DSP_MAX_FFT_SIZE=4096 14 | # end of DSP Library 15 | 16 | # 17 | # ESP System Settings 18 | # 19 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 20 | CONFIG_ESP_INT_WDT=n 21 | CONFIG_ESP_TASK_WDT=n 22 | # end of ESP System Settings 23 | -------------------------------------------------------------------------------- /examples/matrix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(matrix) 7 | -------------------------------------------------------------------------------- /examples/matrix/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := matrix 7 | 8 | # This line has to be included into the make file 9 | # to include components that are located somewhere 10 | # but not in "component" directory 11 | 12 | EXTRA_COMPONENT_DIRS := $(realpath ../..) 13 | EXCLUDE_COMPONENTS := test 14 | 15 | include $(IDF_PATH)/make/project.mk 16 | 17 | -------------------------------------------------------------------------------- /examples/matrix/README.md: -------------------------------------------------------------------------------- 1 | # Matrix Operations Example 2 | 3 | (See the README.md file in the upper level 'examples' directory for more information about examples.) 4 | 5 | This example demonstrates how to use Mat class functionality from esp-dsp library. Example does the following steps: 6 | 7 | 1. Initialize a matrix A and matirx x 8 | 2. Calculate matrix b: b = A*x 9 | 3. Find roots x1_: A*x1_ = b, with different methods 10 | 4. Print result 11 | 12 | ## How to use example 13 | 14 | ### Hardware required 15 | 16 | This example does not require any special hardware, and can be run on any common development board. 17 | 18 | ### Configure the project 19 | 20 | Under Component Config ---> DSP Library ---> DSP Optimization, it's possible to choose either the optimized or ANSI implementation, to compare them. 21 | 22 | ### Build and flash 23 | 24 | Build the project and flash it to the board, then run monitor tool to view serial output (replace PORT with serial port name): 25 | 26 | ``` 27 | idf.py -p PORT flash monitor 28 | ``` 29 | 30 | (To exit the serial monitor, type ``Ctrl-]``.) 31 | 32 | See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 33 | 34 | ## Example output 35 | 36 | Here is an typical example console output. 37 | 38 | ``` 39 | I (215) main: Start Example. 40 | I (215) main: Original vector x: 41 | 0 42 | 1 43 | 2 44 | I (215) main: Solve result: 45 | 0 46 | 1 47 | 2 48 | I (215) main: Roots result: 49 | 0 50 | 1 51 | 2 52 | I (215) main: End Example. 53 | 54 | ``` 55 | -------------------------------------------------------------------------------- /examples/matrix/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "dspm_matrix_main.cpp") 2 | -------------------------------------------------------------------------------- /examples/matrix/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Main component makefile. 3 | # 4 | # This Makefile can be left empty. By default, it will take the sources in the 5 | # src/ directory, compile them and link them into lib(subdirectory_name).a 6 | # in the build directory. This behaviour is entirely configurable, 7 | # please read the ESP-IDF documents if you need to do this. 8 | # 9 | -------------------------------------------------------------------------------- /examples/matrix/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp-dsp: 3 | override_path: "../../../" 4 | version: "*" 5 | -------------------------------------------------------------------------------- /examples/matrix/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 -------------------------------------------------------------------------------- /idf_component.yml: -------------------------------------------------------------------------------- 1 | description: ESP-DSP is the official DSP library for Espressif SoCs. 2 | url: https://github.com/espressif/esp-dsp 3 | repository: https://github.com/espressif/esp-dsp.git 4 | documentation: https://docs.espressif.com/projects/esp-dsp/en/latest/index.html 5 | issues: https://github.com/espressif/esp-dsp/issues 6 | 7 | examples: 8 | - path: ./applications 9 | - path: ./applications/azure_board_apps 10 | - path: ./applications/azure_board_apps/apps 11 | - path: ./applications/lyrat_board_app 12 | 13 | files: 14 | exclude: 15 | - "**/Makefile" 16 | - "**/component.mk" 17 | - "docs/**/*" 18 | - "test/**/*" 19 | - "test_app/**/*" 20 | 21 | dependencies: 22 | # Required IDF version 23 | idf: ">=4.2" 24 | -------------------------------------------------------------------------------- /modules/common/include/dsp_err.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _DSP_ERR_H_ 17 | #define _DSP_ERR_H_ 18 | 19 | #include "stdint.h" 20 | #include "esp_err.h" 21 | #include "dsp_err_codes.h" 22 | 23 | #endif // _DSP_ERR_H_ 24 | -------------------------------------------------------------------------------- /modules/common/include/dsp_err_codes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2022 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dsp_error_codes_H_ 16 | #define _dsp_error_codes_H_ 17 | 18 | #define DSP_OK 0 // For internal use only. Please use ESP_OK instead 19 | #define ESP_ERR_DSP_BASE 0x70000 20 | #define ESP_ERR_DSP_INVALID_LENGTH (ESP_ERR_DSP_BASE + 1) 21 | #define ESP_ERR_DSP_INVALID_PARAM (ESP_ERR_DSP_BASE + 2) 22 | #define ESP_ERR_DSP_PARAM_OUTOFRANGE (ESP_ERR_DSP_BASE + 3) 23 | #define ESP_ERR_DSP_UNINITIALIZED (ESP_ERR_DSP_BASE + 4) 24 | #define ESP_ERR_DSP_REINITIALIZED (ESP_ERR_DSP_BASE + 5) 25 | #define ESP_ERR_DSP_ARRAY_NOT_ALIGNED (ESP_ERR_DSP_BASE + 6) 26 | 27 | 28 | #endif // _dsp_error_codes_H_ 29 | -------------------------------------------------------------------------------- /modules/common/include/dsp_platform.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef dsp_platform_h_ 17 | #define dsp_platform_h_ 18 | #include "esp_idf_version.h" 19 | 20 | #if defined(__XTENSA__) || defined(__riscv) 21 | #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0) 22 | #include "esp_cpu.h" 23 | #else 24 | #include "soc/cpu.h" 25 | #endif 26 | #endif 27 | 28 | #include "freertos/FreeRTOS.h" 29 | #include "freertos/portable.h" 30 | #include "freertos/task.h" 31 | #include "freertos/semphr.h" 32 | 33 | #endif // dsp_platform_h_ 34 | -------------------------------------------------------------------------------- /modules/common/include/dsp_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _DSP_TESTS_H_ 16 | #define _DSP_TESTS_H_ 17 | 18 | #include 19 | #include "esp_idf_version.h" 20 | #include "esp_dsp.h" 21 | 22 | #define TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, actual) \ 23 | if (actual >= max_exec) { \ 24 | ESP_LOGE("", "Time error. Expected max: %i, reached: %i", (int)max_exec, (int)actual);\ 25 | TEST_ASSERT_MESSAGE (false, "Exec time takes more than expected! ");\ 26 | }\ 27 | if (actual < min_exec) {\ 28 | ESP_LOGE("", "Time error. Expected min: %i, reached: %i", (int)min_exec, (int)actual);\ 29 | TEST_ASSERT_MESSAGE (false, "Exec time takes less then expected!");\ 30 | } 31 | 32 | 33 | // memalign function is implemented in IDF 4.3 and later 34 | #if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(4, 3, 0) 35 | #define memalign(align_, size_) malloc(size_) 36 | #endif 37 | 38 | #endif // _DSP_TESTS_H_ 39 | -------------------------------------------------------------------------------- /modules/common/include/dsp_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsp_types_H_ 2 | #define _dsp_types_H_ 3 | #include 4 | #include 5 | #include 6 | 7 | // union to simplify access to the 16 bit data 8 | typedef union sc16_u { 9 | struct { 10 | int16_t re; 11 | int16_t im; 12 | }; 13 | uint32_t data; 14 | } sc16_t; 15 | 16 | typedef union fc32_u { 17 | struct { 18 | float re; 19 | float im; 20 | }; 21 | uint64_t data; 22 | } fc32_t; 23 | 24 | typedef struct image2d_s { 25 | void *data; // could be int8_t, unt8_t, int16_t, unt16_t, float 26 | int step_x; // step of elements by X 27 | int step_y; // step of elements by Y, usually is 1 28 | int stride_x; // stride width: size of the elements in X axis * by step_x + padding 29 | int stride_y; // stride height: size of the elements in Y axis * by step_y + padding 30 | // Point[x,y] = data[width*y*step_y + x*step_x]; 31 | // Full data size = width*height 32 | int size_x; // image width 33 | int size_y; // image height 34 | } image2d_t; 35 | 36 | #endif // _dsp_types_H_ 37 | -------------------------------------------------------------------------------- /modules/common/include/esp_dsp.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2023 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _esp_dsp_H_ 16 | #define _esp_dsp_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | // Common includes 24 | #include "dsp_common.h" 25 | #include "dsp_types.h" 26 | 27 | // Signal processing 28 | #include "dsps_dotprod.h" 29 | #include "dsps_math.h" 30 | #include "dsps_fir.h" 31 | #include "dsps_biquad.h" 32 | #include "dsps_biquad_gen.h" 33 | #include "dsps_wind.h" 34 | #include "dsps_conv.h" 35 | #include "dsps_corr.h" 36 | 37 | #include "dsps_d_gen.h" 38 | #include "dsps_h_gen.h" 39 | #include "dsps_tone_gen.h" 40 | #include "dsps_snr.h" 41 | #include "dsps_sfdr.h" 42 | 43 | #include "dsps_fft2r.h" 44 | #include "dsps_fft4r.h" 45 | #include "dsps_dct.h" 46 | 47 | // Matrix operations 48 | #include "dspm_matrix.h" 49 | 50 | // Support functions 51 | #include "dsps_view.h" 52 | 53 | // Image processing functions: 54 | #include "dspi_dotprod.h" 55 | #include "dspi_conv.h" 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #ifdef __cplusplus 62 | #include "mat.h" 63 | #endif 64 | 65 | #endif // _esp_dsp_H_ 66 | -------------------------------------------------------------------------------- /modules/common/include_sim/esp_attr.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2020 spressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This file include defenitions that are emulate esp-idf error codes 16 | 17 | #ifndef _esp_attr_h_ 18 | #define _esp_attr_h_ 19 | 20 | 21 | #endif // _esp_attr_h_ 22 | -------------------------------------------------------------------------------- /modules/common/include_sim/esp_err.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2020 spressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This file include defenitions that are emulate esp-idf error codes 16 | 17 | #ifndef _esp_err_h_ 18 | #define _esp_err_h_ 19 | 20 | #include 21 | typedef int esp_err_t; 22 | 23 | #define ESP_OK 0 24 | 25 | #ifndef M_PI 26 | #define M_PI 3.14159265358979323846 27 | #endif // M_PI 28 | 29 | #endif // _esp_err_h_ 30 | -------------------------------------------------------------------------------- /modules/common/include_sim/esp_log.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2020 spressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This file include defenitions that are emulate esp-idf error codes 16 | 17 | #ifndef _esp_log_h_ 18 | #define _esp_log_h_ 19 | 20 | #include 21 | 22 | #define ESP_LOGD 23 | 24 | #endif // _esp_log_h_ 25 | -------------------------------------------------------------------------------- /modules/common/include_sim/sdkconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef _sdkconfig_h_ 2 | #define _sdkconfig_h_ 3 | 4 | #endif // _sdkconfig_h_ 5 | -------------------------------------------------------------------------------- /modules/common/misc/dsps_pwroftwo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsp_common.h" 16 | 17 | bool dsp_is_power_of_two(int x) 18 | { 19 | return (x != 0) && ((x & (x - 1)) == 0); 20 | } 21 | 22 | int dsp_power_of_two(int x) 23 | { 24 | for (size_t i = 0; i < 32; i++) { 25 | x = x >> 1; 26 | if (0 == x) { 27 | return i; 28 | } 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /modules/conv/float/dsps_conv_f32_m_ae32.S: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | .macro conv_f32_ae32 x1 x2 count step1 step2 name 17 | // This macro calculates floating point dot product for count float samples 18 | // x1, x2 - input arrays 19 | // count - amount of samples 20 | // step1 - start step 21 | //,step2 - A register for array step increment. (should be divided by 4) 22 | // f1 - contains initial value 23 | // 24 | // result in f1 25 | // 26 | // Macros body: 27 | // f1 += x1[]*x2[]; i: 0..counter-1 28 | // affected: f0, f1, f2 29 | // Example: conv_f32_ae32 a2 a3 a5 a8 a9 30 | // a8 == 4, step is 4 bytes 31 | // a5 == 32, length of array is 32 32 | // 33 | lsxp f0, \x2, \step2 34 | loopnez \count, loop_mac_end_m_ae32\name 35 | lsxp f2, \x1, \step1 36 | madd.s f1, f2, f0 37 | lsxp f0, \x2, \step2 38 | loop_mac_end_m_ae32\name: 39 | .endm 40 | -------------------------------------------------------------------------------- /modules/conv/float/dsps_corr_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_corr.h" 16 | 17 | esp_err_t dsps_corr_f32_ansi(const float *Signal, const int siglen, const float *Pattern, const int patlen, float *dest) 18 | { 19 | if (NULL == Signal) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == Pattern) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | if (NULL == dest) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | if (siglen < patlen) { 29 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 30 | } 31 | 32 | for (size_t n = 0; n <= (siglen - patlen); n++) { 33 | float k_corr = 0; 34 | for (size_t m = 0; m < patlen; m++) { 35 | k_corr += Signal[n + m] * Pattern[m]; 36 | } 37 | dest[n] = k_corr; 38 | } 39 | return ESP_OK; 40 | } 41 | -------------------------------------------------------------------------------- /modules/conv/include/dspi_conv.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dspi_conv_H_ 16 | #define _dspi_conv_H_ 17 | #include "dsp_err.h" 18 | 19 | #include "dsps_conv_platform.h" 20 | #include "dsp_types.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" 24 | { 25 | #endif 26 | 27 | /**@{*/ 28 | /** 29 | * @brief 2D Convolution 30 | * 31 | * The function convolve Signal image with Kernel (filter) image. 32 | * The implementation use ANSI C and could be compiled and run on any platform 33 | * 34 | * @param[in] in_image: input image 35 | * @param[in] filter: input array with convolution kernel 36 | * @param[out] out_image: output image. The stride and step parameters must be set. 37 | * 38 | * @return 39 | * - ESP_OK on success 40 | * - One of the error codes from DSP library 41 | */ 42 | esp_err_t dspi_conv_f32_ansi(const image2d_t *in_image, const image2d_t *filter, image2d_t *out_image); 43 | /**@}*/ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #ifdef CONFIG_DSP_OPTIMIZED 50 | #define dspi_conv_f32 dspi_conv_f32_ansi 51 | #else 52 | #define dspi_conv_f32 dspi_conv_f32_ansi 53 | #endif // CONFIG_DSP_OPTIMIZED 54 | 55 | #endif // _dspi_conv_H_ 56 | -------------------------------------------------------------------------------- /modules/conv/include/dsps_conv_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_conv_platform_H_ 2 | #define _dsps_conv_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_conv_f32_ae32_enabled 1 14 | #define dsps_ccorr_f32_ae32_enabled 1 15 | #define dsps_corr_f32_ae32_enabled 1 16 | 17 | #endif 18 | #endif // __XTENSA__ 19 | 20 | #endif // _dsps_conv_platform_H_ 21 | -------------------------------------------------------------------------------- /modules/dotprod/fixed/dsps_dotprod_s16_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_dotprod.h" 16 | 17 | esp_err_t dsps_dotprod_s16_ansi(const int16_t *src1, const int16_t *src2, int16_t *dest, int len, int8_t shift) 18 | { 19 | // To make correct round operation we have to shift round value 20 | long long acc = 0x7fff >> shift; 21 | 22 | for (int i = 0 ; i < len ; i++) { 23 | acc += (int32_t)src1[i] * (int32_t)src2[i]; 24 | } 25 | 26 | int final_shift = shift - 15; 27 | if (final_shift > 0) { 28 | *dest = (acc << final_shift); 29 | } else { 30 | *dest = (acc >> (-final_shift)); 31 | } 32 | return ESP_OK; 33 | } 34 | -------------------------------------------------------------------------------- /modules/dotprod/float/dsps_dotprod_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_dotprod.h" 16 | 17 | esp_err_t dsps_dotprod_f32_ansi(const float *src1, const float *src2, float *dest, int len) 18 | { 19 | float acc = 0; 20 | for (int i = 0 ; i < len ; i++) { 21 | acc += src1[i] * src2[i]; 22 | } 23 | *dest = acc; 24 | return ESP_OK; 25 | } 26 | -------------------------------------------------------------------------------- /modules/dotprod/float/dsps_dotprod_f32_m_ae32.S: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | .macro dotprod_f32_ae32 x1 x2 count step1 step2 17 | // This macro calculates floating point dot product for count float samples 18 | // x1, x2 - input arrays 19 | // count - amount of samples 20 | // step1 - start step 21 | //,step2 - A register for array step increment. (should be divided by 4) 22 | // f1 - contains initial value 23 | // 24 | // result in f1 25 | // 26 | // Macros body: 27 | // f1 += x1[i*step1]*x2[i*step2]; i: 0..counter-1 28 | // affected: f0, f1, f2 29 | // Example: dotprod_f32_ae32 a2 a3 a5 a8 a9 30 | // a8 == 4, step is 4 bytes 31 | // a5 == 32, length of array is 32 32 | // 33 | // mov \step1, \step2 34 | lsx f0, \x2, \step1 35 | // sub \x1, \x1, \step1 // To compensate first increment 36 | loopnez \count, .loop_mac_end_m_ae32 37 | lsx f2, \x1, \step1 38 | madd.s f1, f2, f0 39 | add.n \step1, \step1, \step2 40 | lsx f0, \x2, \step1 41 | .loop_mac_end_m_ae32: 42 | .endm 43 | -------------------------------------------------------------------------------- /modules/dotprod/float/dsps_dotprode_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_dotprod.h" 16 | 17 | esp_err_t dsps_dotprode_f32_ansi(const float *src1, const float *src2, float *dest, int len, int step1, int step2) 18 | { 19 | float acc = 0; 20 | for (int i = 0 ; i < len ; i++) { 21 | acc += src1[i * step1] * src2[i * step2]; 22 | } 23 | *dest = acc; 24 | return ESP_OK; 25 | } 26 | -------------------------------------------------------------------------------- /modules/dotprod/float/dsps_dotprode_f32_m_ae32.S: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | .macro dotprode_f32_ae32 x1 x2 count step1 step2 17 | // This macro calculates floating point dot product for count float samples 18 | // x1, x2 - input arrays 19 | // count - amount of samples 20 | // step1,step2 - A register for array step. (should be divided by 4) 21 | // f1 - contains initial value 22 | // 23 | // result in f1 24 | // 25 | // Macros body: 26 | // f1 += x1[i*step1]*x2[i*step2]; i: 0..counter-1 27 | // affected: f0, f1, f2 28 | // Example: dotprod_f32_ae32 a2 a3 a5 a8 a9 29 | // a8 == 4, step is 4 bytes 30 | // a5 == 32, length of array is 32 31 | // 32 | lsi f0, \x2, 0 33 | sub \x1, \x1, \step1 // To compensate first increment 34 | loopnez \count, .loop_mace_end_m_ae32 35 | add.n \x1, \x1, \step1 36 | lsi f2, \x1, 0 37 | madd.s f1, f2, f0 38 | add.n \x2, \x2, \step2 39 | lsi f0, \x2, 0 40 | .loop_mace_end_m_ae32: 41 | .endm 42 | -------------------------------------------------------------------------------- /modules/dotprod/include/dspi_dotprod_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dspi_dotprod_platform_H_ 2 | #define _dspi_dotprod_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if CONFIG_IDF_TARGET_ESP32S3 12 | #define dspi_dotprod_aes3_enabled 1 13 | #endif 14 | #endif // __XTENSA__ 15 | 16 | #if CONFIG_IDF_TARGET_ESP32P4 17 | #ifdef CONFIG_DSP_OPTIMIZED 18 | #define dspi_dotprod_arp4_enabled 1 19 | #else 20 | #define dspi_dotprod_arp4_enabled 0 21 | #endif 22 | #endif 23 | 24 | #endif // _dspi_dotprod_platform_H_ 25 | -------------------------------------------------------------------------------- /modules/dotprod/include/dsps_dotprod_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_dotprod_platform_H_ 2 | #define _dsps_dotprod_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dotprod_f32_ae32_enabled 1 14 | #define dotprode_f32_ae32_enabled 1 15 | 16 | #endif // 17 | 18 | #if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1)) 19 | 20 | #define dsps_dotprod_s16_ae32_enabled 1 21 | 22 | #endif // 23 | #endif // __XTENSA__ 24 | 25 | 26 | #if CONFIG_IDF_TARGET_ESP32S3 27 | #define dsps_dotprod_s16_aes3_enabled 1 28 | #define dsps_dotprod_f32_aes3_enabled 1 29 | #endif 30 | 31 | #if CONFIG_IDF_TARGET_ESP32P4 32 | #ifdef CONFIG_DSP_OPTIMIZED 33 | #define dsps_dotprod_s16_arp4_enabled 1 34 | #define dsps_dotprod_f32_arp4_enabled 1 35 | #else 36 | #define dsps_dotprod_s16_arp4_enabled 0 37 | #define dsps_dotprod_f32_arp4_enabled 0 38 | #endif // CONFIG_DSP_OPTIMIZED 39 | #endif 40 | 41 | 42 | #endif // _dsps_dotprod_platform_H_ 43 | -------------------------------------------------------------------------------- /modules/fft/include/dsps_fft2r_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_fft2r_platform_H_ 2 | #define _dsps_fft2r_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_fft2r_fc32_ae32_enabled 1 14 | 15 | #endif // 16 | 17 | #if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1)) 18 | 19 | #define dsps_fft2r_sc16_ae32_enabled 1 20 | 21 | #endif // 22 | 23 | #if (XCHAL_HAVE_LOOPS == 1) 24 | 25 | #define dsps_bit_rev_lookup_fc32_ae32_enabled 1 26 | 27 | #endif // 28 | #endif // __XTENSA__ 29 | 30 | #if CONFIG_IDF_TARGET_ESP32S3 31 | #define dsps_fft2r_fc32_aes3_enabled 1 32 | #define dsps_fft2r_sc16_aes3_enabled 1 33 | #endif 34 | #if CONFIG_IDF_TARGET_ESP32P4 35 | #ifdef CONFIG_DSP_OPTIMIZED 36 | #define dsps_fft2r_fc32_arp4_enabled 1 37 | #define dsps_fft2r_sc16_arp4_enabled 1 38 | #else 39 | #define dsps_fft2r_fc32_arp4_enabled 0 40 | #define dsps_fft2r_sc16_arp4_enabled 0 41 | #endif // CONFIG_DSP_OPTIMIZED 42 | #endif 43 | 44 | #endif // _dsps_fft2r_platform_H_ 45 | -------------------------------------------------------------------------------- /modules/fft/include/dsps_fft4r_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_fft4r_platform_H_ 2 | #define _dsps_fft4r_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_cplx2real_fc32_ae32_enabled 1 14 | 15 | #endif // 16 | 17 | 18 | #if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1)) 19 | 20 | #define dsps_fft2r_sc16_ae32_enabled 1 21 | 22 | #endif // 23 | 24 | #if (XCHAL_HAVE_LOOPS == 1) 25 | 26 | #define dsps_bit_rev_lookup_fc32_ae32_enabled 1 27 | 28 | #endif // 29 | #endif // __XTENSA__ 30 | 31 | #if CONFIG_IDF_TARGET_ESP32P4 32 | #ifdef CONFIG_DSP_OPTIMIZED 33 | #define dsps_fft4r_fc32_arp4_enabled 1 34 | #else // CONFIG_DSP_OPTIMIZED 35 | #define dsps_fft4r_fc32_arp4_enabled 0 36 | #endif // CONFIG_DSP_OPTIMIZED 37 | #endif 38 | 39 | #if CONFIG_IDF_TARGET_ESP32 40 | #ifdef CONFIG_DSP_OPTIMIZED 41 | #define dsps_fft4r_fc32_ae32_enabled 1 42 | #else // CONFIG_DSP_OPTIMIZED 43 | #define dsps_fft4r_fc32_ae32_enabled 0 44 | #endif // CONFIG_DSP_OPTIMIZED 45 | #endif 46 | 47 | #if CONFIG_IDF_TARGET_ESP32S3 48 | #ifdef CONFIG_DSP_OPTIMIZED 49 | #define dsps_fft4r_fc32_aes3_enabled 1 50 | #else // CONFIG_DSP_OPTIMIZED 51 | #define dsps_fft4r_fc32_aes3_enabled 0 52 | #endif // CONFIG_DSP_OPTIMIZED 53 | #endif 54 | 55 | #endif // _dsps_fft4r_platform_H_ 56 | -------------------------------------------------------------------------------- /modules/fft/test_sim/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void test_fft2r(); 5 | 6 | int main(void) 7 | { 8 | printf("main starts!\n"); 9 | // xt_iss_profile_enable(); 10 | test_fft2r(); 11 | // xt_iss_profile_disable(); 12 | 13 | printf("Test done\n"); 14 | } 15 | -------------------------------------------------------------------------------- /modules/fir/fixed/dsps_fird_s16_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dsps_fir.h" 8 | 9 | int32_t dsps_fird_s16_ansi(fir_s16_t *fir, const int16_t *input, int16_t *output, int32_t len) 10 | { 11 | int32_t result = 0; 12 | int32_t input_pos = 0; 13 | long long rounding = 0; 14 | const int32_t final_shift = fir->shift - 15; 15 | 16 | rounding = (long long)(fir->rounding_val); 17 | 18 | if (fir->shift >= 0) { 19 | rounding = (rounding >> fir->shift) & 0xFFFFFFFFFF; // 40-bit mask 20 | } else { 21 | rounding = (rounding << (-fir->shift)) & 0xFFFFFFFFFF; // 40-bit mask 22 | } 23 | 24 | // len is already a length of the *output array, calculated as (length of the input array / decimation) 25 | for (int i = 0; i < len; i++) { 26 | 27 | for (int j = 0; j < fir->decim - fir->d_pos; j++) { 28 | 29 | if (fir->pos >= fir->coeffs_len) { 30 | fir->pos = 0; 31 | } 32 | fir->delay[fir->pos++] = input[input_pos++]; 33 | } 34 | fir->d_pos = 0; 35 | 36 | long long acc = rounding; 37 | int16_t coeff_pos = fir->coeffs_len - 1; 38 | 39 | for (int n = fir->pos; n < fir->coeffs_len ; n++) { 40 | acc += (int32_t)fir->coeffs[coeff_pos--] * (int32_t)fir->delay[n]; 41 | } 42 | for (int n = 0; n < fir->pos ; n++) { 43 | acc += (int32_t)fir->coeffs[coeff_pos--] * (int32_t)fir->delay[n]; 44 | } 45 | 46 | if (final_shift > 0) { 47 | output[result++] = (int16_t)(acc << final_shift); 48 | } else { 49 | output[result++] = (int16_t)(acc >> (-final_shift)); 50 | } 51 | 52 | } 53 | return result; 54 | } 55 | -------------------------------------------------------------------------------- /modules/fir/float/dsps_fir_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_fir.h" 16 | 17 | esp_err_t dsps_fir_f32_ansi(fir_f32_t *fir, const float *input, float *output, int len) 18 | { 19 | for (int i = 0 ; i < len ; i++) { 20 | float acc = 0; 21 | int coeff_pos = 0; 22 | fir->delay[fir->pos] = input[i]; 23 | fir->pos++; 24 | if (fir->pos >= fir->N) { 25 | fir->pos = 0; 26 | } 27 | for (int n = fir->pos; n < fir->N ; n++) { 28 | acc += fir->coeffs[coeff_pos++] * fir->delay[n]; 29 | } 30 | for (int n = 0; n < fir->pos ; n++) { 31 | acc += fir->coeffs[coeff_pos++] * fir->delay[n]; 32 | } 33 | output[i] = acc; 34 | } 35 | return ESP_OK; 36 | } 37 | -------------------------------------------------------------------------------- /modules/fir/float/dsps_fird_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_fir.h" 16 | 17 | int dsps_fird_f32_ansi(fir_f32_t *fir, const float *input, float *output, int len) 18 | { 19 | int result = 0; 20 | for (int i = 0; i < len ; i++) { 21 | for (int k = 0 ; k < fir->decim ; k++) { 22 | fir->delay[fir->pos++] = *input++; 23 | if (fir->pos >= fir->N) { 24 | fir->pos = 0; 25 | } 26 | } 27 | float acc = 0; 28 | int coeff_pos = 0; 29 | for (int n = fir->pos; n < fir->N ; n++) { 30 | acc += fir->coeffs[coeff_pos++] * fir->delay[n]; 31 | } 32 | for (int n = 0; n < fir->pos ; n++) { 33 | acc += fir->coeffs[coeff_pos++] * fir->delay[n]; 34 | } 35 | output[result++] = acc; 36 | } 37 | return result; 38 | } 39 | -------------------------------------------------------------------------------- /modules/fir/float/dsps_fird_init_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_fir.h" 16 | 17 | 18 | esp_err_t dsps_fird_init_f32(fir_f32_t *fir, float *coeffs, float *delay, int N, int decim) 19 | { 20 | fir->coeffs = coeffs; 21 | fir->delay = delay; 22 | fir->N = N; 23 | fir->pos = 0; 24 | fir->decim = decim; 25 | 26 | #ifdef CONFIG_IDF_TARGET_ESP32S3 27 | // The amount of coefficients should be divided to 4, 28 | // if not, add zero coefficients to round length to 0 29 | if (fir->N % 4 != 0) { 30 | return ESP_ERR_DSP_INVALID_LENGTH; 31 | } 32 | // The coeffs array should be aligned to 16 33 | if (((uint32_t)coeffs) & 0x0f) { 34 | return ESP_ERR_DSP_ARRAY_NOT_ALIGNED; 35 | } 36 | // The delay array should be aligned to 16 37 | if (((uint32_t)delay) & 0x0f) { 38 | return ESP_ERR_DSP_ARRAY_NOT_ALIGNED; 39 | } 40 | #endif // CONFIG_IDF_TARGET_ESP32S3 41 | 42 | for (int i = 0 ; i < N; i++) { 43 | fir->delay[i] = 0; 44 | } 45 | return ESP_OK; 46 | } 47 | -------------------------------------------------------------------------------- /modules/fir/include/dsps_fir_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_fir_platform_H_ 2 | #define _dsps_fir_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #if CONFIG_IDF_TARGET_ESP32S3 14 | #define dsps_fird_f32_aes3_enabled 1 15 | #define dsps_fird_f32_ae32_enabled 1 16 | #define dsps_fird_s16_aes3_enabled 1 17 | #define dsps_fird_s16_ae32_enabled 0 18 | #define dsps_fir_f32_aes3_enabled 1 19 | #define dsps_fir_f32_ae32_enabled 0 20 | #else 21 | #define dsps_fird_f32_ae32_enabled 1 22 | #define dsps_fird_s16_aes3_enabled 0 23 | #define dsps_fird_s16_ae32_enabled 1 24 | #define dsps_fir_f32_aes3_enabled 0 25 | #define dsps_fir_f32_ae32_enabled 1 26 | #endif 27 | 28 | #endif // 29 | #endif // __XTENSA__ 30 | 31 | #ifdef CONFIG_IDF_TARGET_ESP32P4 32 | #ifdef CONFIG_DSP_OPTIMIZED 33 | #define dsps_fird_f32_arp4_enabled 1 34 | #define dsps_fird_s16_arp4_enabled 1 35 | #else 36 | #define dsps_fird_f32_arp4_enabled 0 37 | #define dsps_fird_s16_arp4_enabled 0 38 | #endif // CONFIG_DSP_OPTIMIZED 39 | #endif 40 | #endif // _dsps_fir_platform_H_ 41 | -------------------------------------------------------------------------------- /modules/fir/test_sim/main.c: -------------------------------------------------------------------------------- 1 | 2 | void test_fir(); 3 | 4 | int main(void) 5 | { 6 | printf("main starts!\n"); 7 | // xt_iss_profile_enable(); 8 | test_fir(); 9 | // xt_iss_profile_disable(); 10 | 11 | printf("Test done\n"); 12 | } 13 | -------------------------------------------------------------------------------- /modules/fir/test_sim/test_fir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "dsp_common.h" 7 | 8 | #include "dsps_fir.h" 9 | 10 | float x[1024]; 11 | float y[1024]; 12 | float y_compare[1024]; 13 | 14 | float coeffs[256]; 15 | float delay[256]; 16 | float delay_compare[256]; 17 | 18 | 19 | void test_fir() 20 | { 21 | int len = sizeof(x) / sizeof(float); 22 | int fir_len = sizeof(coeffs) / sizeof(float); 23 | 24 | fir_f32_t fir1; 25 | fir_f32_t fir2; 26 | for (int i = 0 ; i < fir_len ; i++) { 27 | coeffs[i] = i; 28 | } 29 | 30 | for (int i = 0 ; i < len ; i++) { 31 | x[i] = 0; 32 | } 33 | x[0] = 1; 34 | 35 | for (int i = 0 ; i < fir_len ; i++) { 36 | coeffs[i] = i; 37 | } 38 | 39 | for (int i = 0 ; i < len ; i++) { 40 | x[i] = i; 41 | } 42 | x[0] = 1; 43 | dsps_fir_init_f32(&fir1, coeffs, delay, fir_len / 4); 44 | dsps_fir_init_f32(&fir2, coeffs, delay_compare, fir_len); 45 | 46 | xt_iss_profile_enable(); 47 | dsps_fir_f32_aes3(&fir1, x, y, len); 48 | dsps_fir_f32_ansi(&fir2, x, y_compare, len); 49 | xt_iss_profile_disable(); 50 | 51 | printf("Test Pass!\n"); 52 | } 53 | -------------------------------------------------------------------------------- /modules/iir/biquad/dsps_biquad_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #include "dsps_biquad.h" 17 | 18 | 19 | esp_err_t dsps_biquad_f32_ansi(const float *input, float *output, int len, float *coef, float *w) 20 | { 21 | for (int i = 0 ; i < len ; i++) { 22 | float d0 = input[i] - coef[3] * w[0] - coef[4] * w[1]; 23 | output[i] = coef[0] * d0 + coef[1] * w[0] + coef[2] * w[1]; 24 | w[1] = w[0]; 25 | w[0] = d0; 26 | } 27 | return ESP_OK; 28 | } 29 | -------------------------------------------------------------------------------- /modules/iir/biquad/dsps_biquad_sf32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #include "dsps_biquad.h" 17 | 18 | 19 | esp_err_t dsps_biquad_sf32_ansi(const float *input, float *output, int len, float *coef, float *w) 20 | { 21 | for (int i = 0 ; i < len ; i++) { 22 | float d0 = input[i * 2 + 0] - coef[3] * w[0] - coef[4] * w[1]; 23 | output[i * 2 + 0] = coef[0] * d0 + coef[1] * w[0] + coef[2] * w[1]; 24 | w[1] = w[0]; 25 | w[0] = d0; 26 | 27 | d0 = input[i * 2 + 1] - coef[3] * w[2] - coef[4] * w[3]; 28 | output[i * 2 + 1] = coef[0] * d0 + coef[1] * w[2] + coef[2] * w[3]; 29 | w[3] = w[2]; 30 | w[2] = d0; 31 | } 32 | return ESP_OK; 33 | } 34 | -------------------------------------------------------------------------------- /modules/iir/include/dsps_biquad_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_biquad_platform_H_ 2 | #define _dsps_biquad_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 11 | 12 | #define dsps_biquad_f32_ae32_enabled 1 13 | 14 | #endif 15 | 16 | #if CONFIG_IDF_TARGET_ESP32S3 17 | #define dsps_biquad_f32_aes3_enabled 1 18 | #else 19 | #define dsps_biquad_f32_aes3_enabled 0 20 | #endif 21 | 22 | #endif // __XTENSA__ 23 | 24 | #ifdef CONFIG_IDF_TARGET_ESP32P4 25 | #ifdef CONFIG_DSP_OPTIMIZED 26 | #define dsps_biquad_f32_arp4_enabled 1 27 | #else 28 | #define dsps_biquad_f32_arp4_enabled 0 29 | #endif // CONFIG_DSP_OPTIMIZED 30 | #else 31 | #define dsps_biquad_f32_arp4_enabled 0 32 | #endif 33 | 34 | #endif // _dsps_biquad_platform_H_ 35 | -------------------------------------------------------------------------------- /modules/iir/test_sim/Makefile: -------------------------------------------------------------------------------- 1 | TEST_PROG=test_prog 2 | 3 | CC = xt-xcc 4 | AS = xt-as 5 | LD = xt-ld 6 | 7 | OBJECTS=main.o \ 8 | test_iir_biquad.o \ 9 | ../biquad/dsps_biquad_f32_ansi.o \ 10 | ../biquad/dsps_biquad_f32_aes3.o 11 | 12 | CFLAGS = -std=c99 -g -O2 -mlongcalls -D__BSD_VISIBLE \ 13 | -I../../common/include \ 14 | -I../../common/include_sim \ 15 | -I../../common/private_include \ 16 | -I../../dotprod/include \ 17 | -I../../dotprod/float \ 18 | -I../../dotprod/fixed \ 19 | -I../../matrix/include \ 20 | -I../../fft/include \ 21 | -I../../iir/include \ 22 | -I../../fir/include 23 | 24 | 25 | PROFILE_OUTPUT=$(TEST_PROG)_prof_out 26 | 27 | CPPFLAGS= $(CFLAGS) 28 | ASFLAGS = $(CFLAGS) 29 | 30 | LIBS += -lm -lc -lgcc 31 | 32 | all: $(TEST_PROG) 33 | 34 | $(TEST_PROG): $(OBJECTS) 35 | $(CC) -o $@ $^ 36 | 37 | run: $(TEST_PROG) 38 | xt-run $(TEST_PROG) 39 | 40 | debug: $(TEST_PROG) 41 | xt-gdb $(TEST_PROG) -ex "b main" -ex "run" 42 | 43 | profile: $(TEST_PROG) 44 | xt-run --client_commands="profile --disable --all $(PROFILE_OUTPUT)" $(TEST_PROG) 45 | 46 | # Generate GPROF targets: show-insn, show-cyc, show-bdelay, show-interlock 47 | GPROF_TYPES := cyc bdelay interlock insn 48 | GPROF_OUTPUTS := $(sort $(addprefix $(PROFILE_OUTPUT).,$(GPROF_TYPES)) $(addsuffix .incl,$(addprefix $(PROFILE_OUTPUT).,$(GPROF_TYPES)))) 49 | GPROF_TARGETS := $(addprefix show-,$(GPROF_TYPES)) 50 | 51 | define GenerateGprofTarget 52 | # $(1) - profiling information type (insn, cyc, bdelay, interlock) 53 | show-$(1): $$(PROFILE_OUTPUT).$(1) 54 | xt-gprof $$(TEST_PROG) $$^ 55 | 56 | $$(PROFILE_OUTPUT).$(1): profile 57 | endef 58 | 59 | $(foreach tp,$(GPROF_TYPES), $(eval $(call GenerateGprofTarget,$(tp)))) 60 | 61 | clean: 62 | rm -f $(OBJECTS) $(TEST_PROG) $(GPROF_OUTPUTS) 63 | 64 | .PHONY: all clean run profile $(GPROF_TARGETS) 65 | -------------------------------------------------------------------------------- /modules/iir/test_sim/main.c: -------------------------------------------------------------------------------- 1 | 2 | void test_iir_biquad(); 3 | 4 | int main(void) 5 | { 6 | printf("main starts!\n"); 7 | // xt_iss_profile_enable(); 8 | test_iir_biquad(); 9 | // xt_iss_profile_disable(); 10 | 11 | printf("Test done\n"); 12 | } 13 | -------------------------------------------------------------------------------- /modules/iir/test_sim/test_iir_biquad.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "dsp_common.h" 7 | 8 | #include "dsps_biquad.h" 9 | 10 | #define N_SAMPLES 1024 11 | int N = N_SAMPLES; 12 | // Input test array 13 | float d[N_SAMPLES]; 14 | // output array 15 | float y[N_SAMPLES]; 16 | float y_ref[N_SAMPLES]; 17 | 18 | extern void xt_iss_profile_disable(); 19 | extern void xt_iss_profile_enable(); 20 | esp_err_t dsps_biquad_f32_aes3(const float *input, float *output, int len, float *coef, float *w); 21 | 22 | void test_iir_biquad() 23 | { 24 | float coeffs_lpf[5] = {0.073802, 0.147603, 0.073802, -1.250516, 0.545723}; 25 | float w_lpf[5] = {0, 0}; 26 | float w_lpf_ref[5] = {0, 0}; 27 | esp_err_t ret = ESP_OK; 28 | 29 | for (size_t i = 0; i < N; i++) { 30 | d[i] = 0; 31 | } 32 | d[0] = 1; 33 | xt_iss_profile_enable(); 34 | ret = dsps_biquad_f32_ansi(d, y_ref, N, coeffs_lpf, w_lpf_ref); 35 | xt_iss_profile_disable(); 36 | if (ret != ESP_OK) { 37 | printf("dsps_biquad_f32 error = %i\n", ret); 38 | return; 39 | } 40 | xt_iss_profile_enable(); 41 | ret = dsps_biquad_f32_aes3(d, y, N, coeffs_lpf, w_lpf); 42 | xt_iss_profile_disable(); 43 | if (ret != ESP_OK) { 44 | printf("dsps_biquad_f32 error = %i\n", ret); 45 | return; 46 | } 47 | for (size_t i = 0; i < N; i++) { 48 | if (((y[i] - y_ref[i]) > 0.0000001) || (y[i] - y_ref[i]) < -0.0000001) { 49 | printf("ERROR result[%i]: %f, expect = %f, diff=%f\n", i, y[i], y_ref[i], y[i] - y_ref[i]); 50 | return; 51 | 52 | } 53 | } 54 | printf("Test Correct!\n"); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /modules/kalman/ekf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "common/ekf.cpp") 2 | 3 | set(COMPONENT_ADD_INCLUDEDIRS "include") 4 | 5 | register_component() 6 | -------------------------------------------------------------------------------- /modules/math/add/fixed/dsps_add_s16_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | 8 | #include "dsps_add.h" 9 | 10 | esp_err_t dsps_add_s16_ansi(const int16_t *input1, const int16_t *input2, int16_t *output, int len, int step1, int step2, int step_out, int shift) 11 | { 12 | if (NULL == input1) { 13 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 14 | } 15 | if (NULL == input2) { 16 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 17 | } 18 | if (NULL == output) { 19 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 20 | } 21 | 22 | for (int i = 0 ; i < len ; i++) { 23 | int32_t acc = (int32_t)input1[i * step1] + (int32_t)input2[i * step2]; 24 | output[i * step_out] = acc >> shift; 25 | } 26 | return ESP_OK; 27 | } 28 | -------------------------------------------------------------------------------- /modules/math/add/fixed/dsps_add_s8_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dsps_add.h" 8 | 9 | esp_err_t dsps_add_s8_ansi(const int8_t *input1, const int8_t *input2, int8_t *output, int len, int step1, int step2, int step_out, int shift) 10 | { 11 | if (NULL == input1) { 12 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 13 | } 14 | if (NULL == input2) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | if (NULL == output) { 18 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 19 | } 20 | 21 | for (int i = 0 ; i < len ; i++) { 22 | int32_t acc = (int32_t)input1[i * step1] + (int32_t)input2[i * step2]; 23 | output[i * step_out] = acc >> shift; 24 | } 25 | return ESP_OK; 26 | } 27 | -------------------------------------------------------------------------------- /modules/math/add/float/dsps_add_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_add.h" 16 | 17 | esp_err_t dsps_add_f32_ansi(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out) 18 | { 19 | if (NULL == input1) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == input2) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | if (NULL == output) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | 29 | for (int i = 0 ; i < len ; i++) { 30 | output[i * step_out] = input1[i * step1] + input2[i * step2]; 31 | } 32 | return ESP_OK; 33 | } 34 | -------------------------------------------------------------------------------- /modules/math/add/include/dsps_add_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_add_platform_H_ 2 | #define _dsps_add_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | #if (CONFIG_IDF_TARGET_ESP32S3 == 1) 11 | #define dsps_add_f32_ae32_enabled 1 12 | #define dsps_add_s16_aes3_enabled 1 13 | #else 14 | 15 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 16 | 17 | #define dsps_add_f32_ae32_enabled 1 18 | #define dsps_add_s16_ae32_enabled 1 19 | 20 | #endif 21 | 22 | #if (XCHAL_HAVE_LOOPS == 1) 23 | #define dsps_add_f32_ae32_enabled 1 24 | #define dsps_add_s16_ae32_enabled 1 25 | #endif 26 | 27 | #endif // CONFIG_IDF_TARGET_ESP32S3 28 | 29 | #endif // __XTENSA__ 30 | 31 | 32 | #endif // _dsps_add_platform_H_ 33 | -------------------------------------------------------------------------------- /modules/math/add/test/test_dsps_add_s16_ae32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | 12 | #include "dsp_tests.h" 13 | #include "dsps_add.h" 14 | #include "esp_attr.h" 15 | 16 | #if (dsps_add_s16_ae32_enabled == 1) 17 | 18 | static const char *TAG = "dsps_add"; 19 | TEST_CASE("dsps_add_s16_ae32 functionality", "[dsps]") 20 | { 21 | int n = 64; 22 | int16_t x[n]; 23 | int16_t y[n]; 24 | int32_t temp; 25 | int shift = 0; 26 | for (int i = 0 ; i < n ; i++) { 27 | x[i] = i << 4; 28 | temp = ((int32_t)x[i] + (int32_t)x[i]) >> shift; 29 | y[i] = temp; 30 | } 31 | 32 | dsps_add_s16_ae32(x, x, x, n, 1, 1, 1, shift); 33 | for (int i = 0 ; i < n ; i++) { 34 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 35 | if (x[i] != y[i]) { 36 | TEST_ASSERT_EQUAL(x[i], y[i]); 37 | } 38 | } 39 | } 40 | 41 | TEST_CASE("dsps_add_s16_ae32 benchmark", "[dsps]") 42 | { 43 | const int n = 256; 44 | int16_t x[n]; 45 | for (int i = 0 ; i < n ; i++) { 46 | x[i] = i << 4; 47 | } 48 | 49 | unsigned int start_b = dsp_get_cpu_cycle_count(); 50 | dsps_add_s16_ae32(x, x, x, n, 1, 1, 1, 0); 51 | unsigned int end_b = dsp_get_cpu_cycle_count(); 52 | 53 | float cycles = end_b - start_b; 54 | ESP_LOGI(TAG, "dsps_add_s16_ae32 - %f cycles per sample \n", cycles); 55 | } 56 | 57 | #endif // (dsps_add_s16_ae32_enabled == 1) 58 | -------------------------------------------------------------------------------- /modules/math/add/test/test_dsps_add_s16_aes3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | #include 12 | 13 | #include "dsps_add.h" 14 | #include "esp_attr.h" 15 | #include "dsp_tests.h" 16 | 17 | #if (dsps_add_s16_aes3_enabled == 1) 18 | 19 | static const char *TAG = "dsps_add"; 20 | TEST_CASE("dsps_add_s16_aes3 functionality", "[dsps]") 21 | { 22 | int n = 64; 23 | int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t)); 24 | int16_t *y = (int16_t *)memalign(16, n * sizeof(int16_t)); 25 | int32_t temp; 26 | int shift = 0; 27 | for (int i = 0 ; i < n ; i++) { 28 | x[i] = i << 4; 29 | temp = ((int32_t)x[i] + (int32_t)x[i]) >> shift; 30 | y[i] = temp; 31 | } 32 | 33 | dsps_add_s16_aes3(x, x, x, n, 1, 1, 1, shift); 34 | for (int i = 0 ; i < n ; i++) { 35 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 36 | if (x[i] != y[i]) { 37 | TEST_ASSERT_EQUAL(x[i], y[i]); 38 | } 39 | } 40 | free(x); 41 | free(y); 42 | } 43 | 44 | TEST_CASE("dsps_add_s16_aes3 benchmark", "[dsps]") 45 | { 46 | const int n = 2048; 47 | int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t)); 48 | for (int i = 0 ; i < n ; i++) { 49 | x[i] = i << 4; 50 | } 51 | 52 | unsigned int start_b = dsp_get_cpu_cycle_count(); 53 | dsps_add_s16_aes3(x, x, x, n, 1, 1, 1, 0); 54 | unsigned int end_b = dsp_get_cpu_cycle_count(); 55 | 56 | float cycles = end_b - start_b; 57 | ESP_LOGI(TAG, "dsps_add_s16_aes3 - %f cycles per sample \n", cycles); 58 | free(x); 59 | 60 | } 61 | #endif // (dsps_add_s16_aes3_enabled == 1) 62 | -------------------------------------------------------------------------------- /modules/math/add/test/test_dsps_add_s16_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | 12 | #include "dsp_tests.h" 13 | #include "dsps_add.h" 14 | #include "esp_attr.h" 15 | 16 | static const char *TAG = "dsps_add"; 17 | 18 | TEST_CASE("dsps_add_s16_ansi functionality", "[dsps]") 19 | { 20 | int n = 64; 21 | int16_t x[n]; 22 | int16_t y[n]; 23 | int32_t temp; 24 | int shift = 0; 25 | for (int i = 0 ; i < n ; i++) { 26 | x[i] = i << 4; 27 | temp = ((int32_t)x[i] + (int32_t)x[i]) >> shift; 28 | y[i] = temp; 29 | } 30 | 31 | dsps_add_s16_ansi(x, x, x, n, 1, 1, 1, 0); 32 | for (int i = 0 ; i < n ; i++) { 33 | if (x[i] != y[i]) { 34 | TEST_ASSERT_EQUAL(x[i], y[i]); 35 | } 36 | } 37 | } 38 | 39 | TEST_CASE("dsps_add_s16_ansi benchmark", "[dsps]") 40 | { 41 | const int n = 256; 42 | int16_t x[n]; 43 | for (int i = 0 ; i < n ; i++) { 44 | x[i] = i << 4; 45 | } 46 | 47 | unsigned int start_b = dsp_get_cpu_cycle_count(); 48 | dsps_add_s16_ansi(x, x, x, n, 1, 1, 1, 0); 49 | unsigned int end_b = dsp_get_cpu_cycle_count(); 50 | 51 | float cycles = end_b - start_b; 52 | ESP_LOGI(TAG, "dsps_add_s16_ansi - %f cycles per sample \n", cycles); 53 | } 54 | -------------------------------------------------------------------------------- /modules/math/add/test/test_dsps_add_s8_aes3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | #include 12 | 13 | #include "dsps_add.h" 14 | #include "esp_attr.h" 15 | #include "dsp_tests.h" 16 | 17 | #if (dsps_add_s16_aes3_enabled == 1) 18 | 19 | static const char *TAG = "dsps_add"; 20 | TEST_CASE("dsps_add_s8_aes3 functionality", "[dsps]") 21 | { 22 | int n = 64; 23 | int8_t *x = (int8_t *)memalign(16, n * sizeof(int8_t)); 24 | int8_t *y = (int8_t *)memalign(16, n * sizeof(int8_t)); 25 | int32_t temp; 26 | int shift = 0; 27 | for (int i = 0 ; i < n ; i++) { 28 | x[i] = i - n / 2; 29 | temp = ((int32_t)x[i] + (int32_t)x[i]) >> shift; 30 | y[i] = temp; 31 | } 32 | 33 | dsps_add_s8_aes3(x, x, x, n, 1, 1, 1, shift); 34 | for (int i = 0 ; i < n ; i++) { 35 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 36 | if (x[i] != y[i]) { 37 | TEST_ASSERT_EQUAL(x[i], y[i]); 38 | } 39 | } 40 | free(x); 41 | free(y); 42 | } 43 | 44 | TEST_CASE("dsps_add_s8_aes3 benchmark", "[dsps]") 45 | { 46 | const int n = 2048; 47 | int8_t *x = (int8_t *)memalign(16, n * sizeof(int8_t)); 48 | for (int i = 0 ; i < n ; i++) { 49 | x[i] = i << 4; 50 | } 51 | 52 | unsigned int start_b = dsp_get_cpu_cycle_count(); 53 | dsps_add_s8_aes3(x, x, x, n, 1, 1, 1, 0); 54 | unsigned int end_b = dsp_get_cpu_cycle_count(); 55 | 56 | float cycles = end_b - start_b; 57 | ESP_LOGI(TAG, "dsps_add_s8_aes3 - %f cycles per sample \n", cycles); 58 | free(x); 59 | 60 | } 61 | #endif // (dsps_add_s16_aes3_enabled == 1) 62 | -------------------------------------------------------------------------------- /modules/math/add/test/test_dsps_add_s8_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | 12 | #include "dsp_tests.h" 13 | #include "dsps_add.h" 14 | #include "esp_attr.h" 15 | 16 | static const char *TAG = "dsps_add"; 17 | 18 | TEST_CASE("dsps_add_s8_ansi functionality", "[dsps]") 19 | { 20 | int n = 64; 21 | int8_t x[n]; 22 | int8_t y[n]; 23 | int32_t temp; 24 | int shift = 0; 25 | for (int i = 0 ; i < n ; i++) { 26 | x[i] = i - n / 2; 27 | temp = ((int32_t)x[i] + (int32_t)x[i]) >> shift; 28 | y[i] = temp; 29 | } 30 | 31 | dsps_add_s8_ansi(x, x, x, n, 1, 1, 1, 0); 32 | for (int i = 0 ; i < n ; i++) { 33 | if (x[i] != y[i]) { 34 | TEST_ASSERT_EQUAL(x[i], y[i]); 35 | } 36 | } 37 | } 38 | 39 | TEST_CASE("dsps_add_s8_ansi benchmark", "[dsps]") 40 | { 41 | const int n = 256; 42 | int8_t x[n]; 43 | for (int i = 0 ; i < n ; i++) { 44 | x[i] = i << 4; 45 | } 46 | 47 | unsigned int start_b = dsp_get_cpu_cycle_count(); 48 | dsps_add_s8_ansi(x, x, x, n, 1, 1, 1, 0); 49 | unsigned int end_b = dsp_get_cpu_cycle_count(); 50 | 51 | float cycles = end_b - start_b; 52 | ESP_LOGI(TAG, "dsps_add_s8_ansi - %f cycles per sample \n", cycles); 53 | } 54 | -------------------------------------------------------------------------------- /modules/math/addc/float/dsps_addc_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_addc.h" 16 | 17 | esp_err_t dsps_addc_f32_ansi(const float *input, float *output, int len, float C, int step_in, int step_out) 18 | { 19 | if (NULL == input) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == output) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | 26 | for (int i = 0 ; i < len ; i++) { 27 | output[i * step_out] = input[i * step_in] + C; 28 | } 29 | return ESP_OK; 30 | } 31 | -------------------------------------------------------------------------------- /modules/math/addc/include/dsps_addc_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_addc_platform_H_ 2 | #define _dsps_addc_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_addc_f32_ae32_enabled 1 14 | 15 | #endif 16 | #endif // __XTENSA__ 17 | 18 | 19 | #endif // _dsps_addc_platform_H_ 20 | -------------------------------------------------------------------------------- /modules/math/include/dsps_math.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dsps_math_H_ 16 | #define _dsps_math_H_ 17 | 18 | #include "dsps_add.h" 19 | #include "dsps_sub.h" 20 | #include "dsps_mul.h" 21 | #include "dsps_addc.h" 22 | #include "dsps_mulc.h" 23 | #include "dsps_sqrt.h" 24 | 25 | #endif // _dsps_math_H_ 26 | -------------------------------------------------------------------------------- /modules/math/mul/fixed/dsps_mul_s16_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_mul.h" 16 | 17 | esp_err_t dsps_mul_s16_ansi(const int16_t *input1, const int16_t *input2, int16_t *output, int len, int step1, int step2, int step_out, int shift) 18 | { 19 | if (NULL == input1) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == input2) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | if (NULL == output) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | 29 | for (int i = 0 ; i < len ; i++) { 30 | int ttt = (int)input1[i * step1] * (int)input2[i * step2]; 31 | output[i * step_out] = ttt >> shift; 32 | } 33 | return ESP_OK; 34 | } 35 | -------------------------------------------------------------------------------- /modules/math/mul/fixed/dsps_mul_s8_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dsps_mul.h" 8 | 9 | esp_err_t dsps_mul_s8_ansi(const int8_t *input1, const int8_t *input2, int8_t *output, int len, int step1, int step2, int step_out, int shift) 10 | { 11 | if (NULL == input1) { 12 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 13 | } 14 | if (NULL == input2) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | if (NULL == output) { 18 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 19 | } 20 | 21 | for (int i = 0 ; i < len ; i++) { 22 | int32_t acc = (int32_t)input1[i * step1] * (int32_t)input2[i * step2]; 23 | output[i * step_out] = acc >> shift; 24 | } 25 | return ESP_OK; 26 | } 27 | -------------------------------------------------------------------------------- /modules/math/mul/float/dsps_mul_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_mul.h" 16 | 17 | esp_err_t dsps_mul_f32_ansi(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out) 18 | { 19 | if (NULL == input1) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == input2) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | if (NULL == output) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | 29 | for (int i = 0 ; i < len ; i++) { 30 | output[i * step_out] = input1[i * step1] * input2[i * step2]; 31 | } 32 | return ESP_OK; 33 | } 34 | -------------------------------------------------------------------------------- /modules/math/mul/include/dsps_mul_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_mul_platform_H_ 2 | #define _dsps_mul_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_mul_f32_ae32_enabled 1 14 | #define dsps_mul_s16_ae32_enabled 1 15 | 16 | #endif 17 | 18 | #if (XCHAL_HAVE_LOOPS == 1) 19 | #define dsps_mul_f32_ae32_enabled 1 20 | #define dsps_mul_s16_ae32_enabled 1 21 | #endif 22 | 23 | #if (CONFIG_IDF_TARGET_ESP32S3 == 1) 24 | #define dsps_mul_f32_ae32_enabled 1 25 | #define dsps_mul_s16_aes3_enabled 1 26 | #endif 27 | 28 | #endif // __XTENSA__ 29 | 30 | #endif // _dsps_mul_platform_H_ 31 | -------------------------------------------------------------------------------- /modules/math/mulc/fixed/dsps_mulc_s16_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_mulc.h" 16 | 17 | esp_err_t dsps_mulc_s16_ansi(const int16_t *input, int16_t *output, int len, int16_t C, int step_in, int step_out) 18 | { 19 | if (NULL == input) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == output) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | 26 | for (int i = 0 ; i < len ; i++) { 27 | int32_t acc = (int32_t)input[i * step_in] * (int32_t)C; 28 | output[i * step_out] = (int16_t)(acc >> 15); 29 | } 30 | return ESP_OK; 31 | } 32 | -------------------------------------------------------------------------------- /modules/math/mulc/float/dsps_mulc_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_mulc.h" 16 | 17 | esp_err_t dsps_mulc_f32_ansi(const float *input, float *output, int len, float C, int step_in, int step_out) 18 | { 19 | if (NULL == input) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == output) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | 26 | for (int i = 0 ; i < len ; i++) { 27 | output[i * step_out] = input[i * step_in] * C; 28 | } 29 | return ESP_OK; 30 | } 31 | -------------------------------------------------------------------------------- /modules/math/mulc/include/dsps_mulc_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_mulc_platform_H_ 2 | #define _dsps_mulc_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_mulc_f32_ae32_enabled 1 14 | 15 | #endif 16 | 17 | #if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1)) 18 | 19 | #define dsps_mulc_s16_ae32_enabled 1 20 | 21 | #endif // 22 | #endif // __XTENSA__ 23 | 24 | 25 | #endif // _dsps_mulc_platform_H_ 26 | -------------------------------------------------------------------------------- /modules/math/sqrt/float/dsps_sqrt_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_sqrt.h" 16 | #include 17 | 18 | 19 | inline float dsps_sqrtf_f32_ansi(float f) 20 | { 21 | int result; 22 | int *f_ptr = (int *)&f; 23 | result = 0x1fbb4000 + (*f_ptr >> 1); 24 | const int *p = &result; 25 | float *f_result = (float *)p; 26 | return *f_result; 27 | } 28 | 29 | esp_err_t dsps_sqrt_f32_ansi(const float *input, float *output, int len) 30 | { 31 | if (NULL == input) { 32 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 33 | } 34 | if (NULL == output) { 35 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 36 | } 37 | 38 | for (int i = 0 ; i < len ; i++) { 39 | output[i] = dsps_sqrtf_f32_ansi(input[i]); 40 | } 41 | return ESP_OK; 42 | } 43 | 44 | float dsps_inverted_sqrtf_f32_ansi(float data ) 45 | { 46 | const float x2 = data * 0.5F; 47 | const float threehalfs = 1.5F; 48 | 49 | union { 50 | float f; 51 | uint32_t i; 52 | } conv = {data}; // member 'f' set to value of 'data'. 53 | conv.i = 0x5f3759df - ( conv.i >> 1 ); 54 | conv.f *= ( threehalfs - ( x2 * conv.f * conv.f ) ); 55 | return conv.f; 56 | } 57 | -------------------------------------------------------------------------------- /modules/math/sub/fixed/dsps_sub_s16_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dsps_add.h" 8 | 9 | esp_err_t dsps_sub_s16_ansi(const int16_t *input1, const int16_t *input2, int16_t *output, int len, int step1, int step2, int step_out, int shift) 10 | { 11 | if (NULL == input1) { 12 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 13 | } 14 | if (NULL == input2) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | if (NULL == output) { 18 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 19 | } 20 | 21 | for (int i = 0 ; i < len ; i++) { 22 | int32_t acc = (int32_t)input1[i * step1] - (int32_t)input2[i * step2]; 23 | output[i * step_out] = acc >> shift; 24 | } 25 | return ESP_OK; 26 | } 27 | -------------------------------------------------------------------------------- /modules/math/sub/fixed/dsps_sub_s8_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dsps_sub.h" 8 | 9 | esp_err_t dsps_sub_s8_ansi(const int8_t *input1, const int8_t *input2, int8_t *output, int len, int step1, int step2, int step_out, int shift) 10 | { 11 | if (NULL == input1) { 12 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 13 | } 14 | if (NULL == input2) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | if (NULL == output) { 18 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 19 | } 20 | 21 | for (int i = 0 ; i < len ; i++) { 22 | int32_t acc = (int32_t)input1[i * step1] - (int32_t)input2[i * step2]; 23 | output[i * step_out] = acc >> shift; 24 | } 25 | return ESP_OK; 26 | } 27 | -------------------------------------------------------------------------------- /modules/math/sub/float/dsps_sub_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_sub.h" 16 | 17 | esp_err_t dsps_sub_f32_ansi(const float *input1, const float *input2, float *output, int len, int step1, int step2, int step_out) 18 | { 19 | if (NULL == input1) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (NULL == input2) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | if (NULL == output) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | 29 | for (int i = 0 ; i < len ; i++) { 30 | output[i * step_out] = input1[i * step1] - input2[i * step2]; 31 | } 32 | return ESP_OK; 33 | } 34 | -------------------------------------------------------------------------------- /modules/math/sub/include/dsps_sub_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_sub_platform_H_ 2 | #define _dsps_sub_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dsps_sub_f32_ae32_enabled 1 14 | #define dsps_sub_s16_ae32_enabled 1 15 | 16 | #endif 17 | 18 | #if (XCHAL_HAVE_LOOPS == 1) 19 | #define dsps_sub_f32_ae32_enabled 1 20 | #define dsps_sub_s16_ae32_enabled 1 21 | #endif 22 | 23 | #if (CONFIG_IDF_TARGET_ESP32S3 == 1) 24 | #define dsps_sub_f32_ae32_enabled 1 25 | #define dsps_sub_s16_aes3_enabled 1 26 | #endif 27 | 28 | #endif // __XTENSA__ 29 | 30 | #endif // _dsps_sub_platform_H_ 31 | -------------------------------------------------------------------------------- /modules/math/sub/test/test_dsps_sub_s16_ae32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | 12 | #include "dsp_tests.h" 13 | #include "dsps_sub.h" 14 | #include "esp_attr.h" 15 | 16 | #if (dsps_sub_s16_ae32_enabled == 1) 17 | 18 | static const char *TAG = "dsps_sub"; 19 | 20 | TEST_CASE("dsps_sub_s16_ae32 functionality", "[dsps]") 21 | { 22 | int n = 64; 23 | int16_t x[n]; 24 | int16_t y[n]; 25 | int32_t temp; 26 | int shift = 0; 27 | for (int i = 0 ; i < n ; i++) { 28 | x[i] = i << 4; 29 | temp = ((int32_t)x[i] - (int32_t)x[i]) >> shift; 30 | y[i] = temp; 31 | } 32 | 33 | dsps_sub_s16_ae32(x, x, x, n, 1, 1, 1, shift); 34 | for (int i = 0 ; i < n ; i++) { 35 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 36 | if (x[i] != y[i]) { 37 | TEST_ASSERT_EQUAL(x[i], y[i]); 38 | } 39 | } 40 | } 41 | 42 | TEST_CASE("dsps_sub_s16_ae32 benchmark", "[dsps]") 43 | { 44 | const int n = 256; 45 | int16_t x[n]; 46 | for (int i = 0 ; i < n ; i++) { 47 | x[i] = i << 4; 48 | } 49 | 50 | unsigned int start_b = dsp_get_cpu_cycle_count(); 51 | dsps_sub_s16_ae32(x, x, x, n, 1, 1, 1, 0); 52 | unsigned int end_b = dsp_get_cpu_cycle_count(); 53 | 54 | float cycles = end_b - start_b; 55 | ESP_LOGI(TAG, "dsps_sub_s16_ae32 - %f cycles per sample \n", cycles); 56 | } 57 | #endif // dsps_sub_s16_ae32_enabled 58 | -------------------------------------------------------------------------------- /modules/math/sub/test/test_dsps_sub_s16_aes3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | #include 12 | 13 | #include "dsps_sub.h" 14 | #include "esp_attr.h" 15 | #include "dsp_tests.h" 16 | 17 | #if (dsps_sub_s16_aes3_enabled == 1) 18 | 19 | static const char *TAG = "dsps_sub"; 20 | TEST_CASE("dsps_sub_s16_aes3 functionality", "[dsps]") 21 | { 22 | int n = 64; 23 | int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t)); 24 | int16_t *y = (int16_t *)memalign(16, n * sizeof(int16_t)); 25 | int32_t temp; 26 | int shift = 0; 27 | for (int i = 0 ; i < n ; i++) { 28 | x[i] = i << 4; 29 | temp = ((int32_t)x[i] - (int32_t)x[i]) >> shift; 30 | y[i] = temp; 31 | } 32 | 33 | dsps_sub_s16_aes3(x, x, x, n, 1, 1, 1, shift); 34 | for (int i = 0 ; i < n ; i++) { 35 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 36 | if (x[i] != y[i]) { 37 | TEST_ASSERT_EQUAL(x[i], y[i]); 38 | } 39 | } 40 | free(x); 41 | free(y); 42 | } 43 | 44 | TEST_CASE("dsps_sub_s16_aes3 benchmark", "[dsps]") 45 | { 46 | const int n = 256; 47 | int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t)); 48 | for (int i = 0 ; i < n ; i++) { 49 | x[i] = i << 4; 50 | } 51 | 52 | unsigned int start_b = dsp_get_cpu_cycle_count(); 53 | dsps_sub_s16_aes3(x, x, x, n, 1, 1, 1, 0); 54 | unsigned int end_b = dsp_get_cpu_cycle_count(); 55 | 56 | float cycles = end_b - start_b; 57 | ESP_LOGI(TAG, "dsps_sub_s16_aes3 - %f cycles per sample \n", cycles); 58 | free(x); 59 | 60 | } 61 | #endif // (dsps_sub_s16_aes3_enabled == 1) 62 | -------------------------------------------------------------------------------- /modules/math/sub/test/test_dsps_sub_s16_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | 12 | #include "dsp_tests.h" 13 | #include "dsps_sub.h" 14 | #include "esp_attr.h" 15 | 16 | static const char *TAG = "dsps_sub"; 17 | 18 | TEST_CASE("dsps_sub_s16_ansi functionality", "[dsps]") 19 | { 20 | int n = 64; 21 | int16_t x[n]; 22 | int16_t y[n]; 23 | int32_t temp; 24 | int shift = 0; 25 | for (int i = 0 ; i < n ; i++) { 26 | x[i] = i << 4; 27 | temp = ((int32_t)x[i] - (int32_t)x[i]) >> shift; 28 | y[i] = temp; 29 | } 30 | 31 | dsps_sub_s16_ansi(x, x, x, n, 1, 1, 1, shift); 32 | for (int i = 0 ; i < n ; i++) { 33 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 34 | if (x[i] != y[i]) { 35 | TEST_ASSERT_EQUAL(x[i], y[i]); 36 | } 37 | } 38 | } 39 | 40 | TEST_CASE("dsps_sub_s16_ansi benchmark", "[dsps]") 41 | { 42 | const int n = 256; 43 | int16_t x[n]; 44 | for (int i = 0 ; i < n ; i++) { 45 | x[i] = i << 4; 46 | } 47 | 48 | unsigned int start_b = dsp_get_cpu_cycle_count(); 49 | dsps_sub_s16_ansi(x, x, x, n, 1, 1, 1, 0); 50 | unsigned int end_b = dsp_get_cpu_cycle_count(); 51 | 52 | float cycles = end_b - start_b; 53 | ESP_LOGI(TAG, "dsps_sub_s16_ansi - %f cycles per sample \n", cycles); 54 | } 55 | -------------------------------------------------------------------------------- /modules/math/sub/test/test_dsps_sub_s8_aes3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | #include 12 | 13 | #include "dsps_sub.h" 14 | #include "esp_attr.h" 15 | #include "dsp_tests.h" 16 | 17 | #if (dsps_sub_s16_aes3_enabled == 1) 18 | 19 | static const char *TAG = "dsps_sub"; 20 | TEST_CASE("dsps_sub_s8_aes3 functionality", "[dsps]") 21 | { 22 | int n = 64; 23 | int8_t *x = (int8_t *)memalign(16, n * sizeof(int8_t)); 24 | int8_t *y = (int8_t *)memalign(16, n * sizeof(int8_t)); 25 | int32_t temp; 26 | int shift = 0; 27 | for (int i = 0 ; i < n ; i++) { 28 | x[i] = i - n / 2; 29 | temp = ((int32_t)x[i] - (int32_t)x[i]) >> shift; 30 | y[i] = temp; 31 | } 32 | 33 | dsps_sub_s8_aes3(x, x, x, n, 1, 1, 1, shift); 34 | for (int i = 0 ; i < n ; i++) { 35 | ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]); 36 | if (x[i] != y[i]) { 37 | TEST_ASSERT_EQUAL(x[i], y[i]); 38 | } 39 | } 40 | free(x); 41 | free(y); 42 | } 43 | 44 | TEST_CASE("dsps_sub_s8_aes3 benchmark", "[dsps]") 45 | { 46 | const int n = 256; 47 | int8_t *x = (int8_t *)memalign(16, n * sizeof(int8_t)); 48 | for (int i = 0 ; i < n ; i++) { 49 | x[i] = i << 4; 50 | } 51 | 52 | unsigned int start_b = dsp_get_cpu_cycle_count(); 53 | dsps_sub_s8_aes3(x, x, x, n, 1, 1, 1, 0); 54 | unsigned int end_b = dsp_get_cpu_cycle_count(); 55 | 56 | float cycles = end_b - start_b; 57 | ESP_LOGI(TAG, "dsps_sub_s8_aes3 - %f cycles per sample \n", cycles); 58 | free(x); 59 | 60 | } 61 | #endif // (dsps_sub_s16_aes3_enabled == 1) 62 | -------------------------------------------------------------------------------- /modules/math/sub/test/test_dsps_sub_s8_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include "unity.h" 9 | #include "dsp_platform.h" 10 | #include "esp_log.h" 11 | 12 | #include "dsp_tests.h" 13 | #include "dsps_sub.h" 14 | #include "esp_attr.h" 15 | 16 | static const char *TAG = "dsps_sub"; 17 | 18 | TEST_CASE("dsps_sub_s8_ansi functionality", "[dsps]") 19 | { 20 | int n = 64; 21 | int8_t x[n]; 22 | int8_t y[n]; 23 | int32_t temp; 24 | int shift = 0; 25 | for (int i = 0 ; i < n ; i++) { 26 | x[i] = i - n / 2; 27 | temp = ((int32_t)x[i] - (int32_t)x[i]) >> shift; 28 | y[i] = temp; 29 | } 30 | 31 | dsps_sub_s8_ansi(x, x, x, n, 1, 1, 1, 0); 32 | for (int i = 0 ; i < n ; i++) { 33 | if (x[i] != y[i]) { 34 | TEST_ASSERT_EQUAL(x[i], y[i]); 35 | } 36 | } 37 | } 38 | 39 | TEST_CASE("dsps_sub_s8_ansi benchmark", "[dsps]") 40 | { 41 | const int n = 256; 42 | int8_t x[n]; 43 | for (int i = 0 ; i < n ; i++) { 44 | x[i] = i << 4; 45 | } 46 | 47 | unsigned int start_b = dsp_get_cpu_cycle_count(); 48 | dsps_sub_s8_ansi(x, x, x, n, 1, 1, 1, 0); 49 | unsigned int end_b = dsp_get_cpu_cycle_count(); 50 | 51 | float cycles = end_b - start_b; 52 | ESP_LOGI(TAG, "dsps_sub_s8_ansi - %f cycles per sample \n", cycles); 53 | } 54 | -------------------------------------------------------------------------------- /modules/matrix/add/include/dspm_add_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dspm_add_platform_H_ 2 | #define _dspm_add_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dspm_add_f32_ae32_enabled 1 14 | 15 | #endif 16 | 17 | #endif // __XTENSA__ 18 | 19 | 20 | #endif // _dspm_add_platform_H_ 21 | -------------------------------------------------------------------------------- /modules/matrix/addc/float/dspm_addc_f32_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dspm_addc.h" 8 | 9 | esp_err_t dspm_addc_f32_ansi(const float *input, float *output, float C, int rows, int cols, int padd_in, int padd_out, int step_in, int step_out) 10 | { 11 | if (NULL == input) { 12 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 13 | } 14 | if (NULL == output) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | 18 | if (rows <= 0) { 19 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 20 | } 21 | if (cols <= 0) { 22 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 23 | } 24 | 25 | if (padd_in < 0) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | if (padd_out < 0) { 29 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 30 | } 31 | 32 | if (step_in <= 0) { 33 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 34 | } 35 | if (step_out <= 0) { 36 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 37 | } 38 | 39 | const int ptr_step_in = cols + padd_in; 40 | const int ptr_step_out = cols + padd_out; 41 | float *ptr_input = (float *)input; 42 | 43 | for (int row = 0; row < rows; row++) { 44 | for (int col = 0; col < cols; col++) { 45 | output[col * step_out] = ptr_input[col * step_in] + C; 46 | } 47 | output += ptr_step_out; 48 | ptr_input += ptr_step_in; 49 | } 50 | return ESP_OK; 51 | } 52 | -------------------------------------------------------------------------------- /modules/matrix/addc/include/dspm_addc_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dspm_addc_platform_H_ 2 | #define _dspm_addc_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dspm_addc_f32_ae32_enabled 1 14 | 15 | #endif 16 | #endif // __XTENSA__ 17 | 18 | 19 | #endif // _dspm_addc_platform_H_ 20 | -------------------------------------------------------------------------------- /modules/matrix/include/dspm_matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _dspm_matrix_H_ 8 | #define _dspm_matrix_H_ 9 | 10 | #include "dspm_add.h" 11 | #include "dspm_addc.h" 12 | #include "dspm_mult.h" 13 | #include "dspm_mulc.h" 14 | #include "dspm_sub.h" 15 | 16 | #endif // _dspm_matrix_H_ 17 | -------------------------------------------------------------------------------- /modules/matrix/mul/fixed/dspm_mult_s16_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_dotprod.h" 16 | #include "dspm_mult.h" 17 | 18 | // Matrinx A(m,n), m - amount or rows, n - amount of columns 19 | // C(m,k) = A(m,n)*B(n,k) 20 | // c(i,j) = sum(a(i,s)*b(s,j)) , s=1..n 21 | esp_err_t dspm_mult_s16_ansi(const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift) 22 | { 23 | int final_shift = shift - 15; 24 | for (int i = 0 ; i < m ; i++) { 25 | for (int j = 0 ; j < k ; j++) { 26 | // This code also could be used 27 | //dsps_dotprode_f32_ae32(&A[i*n],&B[j],&C[i*k + j],n,1,n); 28 | long long acc = 0x7fff >> shift; 29 | for (int s = 0; s < n ; s++) { 30 | acc += (int32_t)A[i * n + s] * (int32_t)B[s * k + j]; 31 | } 32 | if (final_shift > 0) { 33 | C[i * k + j] = (acc << final_shift); 34 | } else { 35 | C[i * k + j] = (acc >> (-final_shift)); 36 | } 37 | } 38 | } 39 | return ESP_OK; 40 | } 41 | -------------------------------------------------------------------------------- /modules/matrix/mul/fixed/dspm_mult_s16_m_ae32.S: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | .macro dspm_mult_s16_ae32_MxNxN 17 | // A - a2 18 | // B - a3 19 | // C - a4 20 | // m - a5 21 | // n - a6 22 | // k - a7 23 | // shift - stack (a8) 24 | 25 | movi a10, 4 // load 4 as a constant 26 | // Check if n >=4 then acceleration is possible and 27 | blt a6, a10, do_dotproduct 28 | // Here we make operations one by one... 29 | 30 | 31 | movi.n a2, 0 // return status ESP_OK 32 | retw.n 33 | 34 | do_dotproduct: 35 | 36 | mov a12, a2 37 | mov a13, a3 38 | 39 | srli a9, a6, 2 // a9 - count/4 - 1 40 | addi a9, a9, -1 41 | 42 | movi.n a10, 0 // load 0 to the a10 to increment second array 43 | dotprod_s16_ae32_full a12, a13, a9, a10, a6 44 | 45 | /* Get accumulator */ 46 | ssr a6 47 | rsr a2, acchi 48 | rsr a3, acclo 49 | src a2, a2, a3 50 | 51 | s16i a2, a4, 0 52 | movi.n a2, 0 53 | 54 | 55 | movi.n a2, 0 // return status ESP_OK 56 | retw.n 57 | 58 | .endm // dspm_mult_s16_ae32_MxNxN -------------------------------------------------------------------------------- /modules/matrix/mul/float/dspm_mult_ex_f32_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dspm_mult.h" 8 | 9 | // Matrix A(m,n), m - amount or rows, n - amount of columns 10 | // C(m,k) = A(m,n)*B(n,k) 11 | // c(i * c_step,j) = sum(a(i * a_step,s)*b(s * b_step,j)) , s=1..n 12 | esp_err_t dspm_mult_ex_f32_ansi(const float *A, const float *B, float *C, int A_rows, int A_cols, int B_cols, int A_padding, int B_padding, int C_padding) 13 | { 14 | if (NULL == A) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | if (NULL == B) { 18 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 19 | } 20 | if (NULL == C) { 21 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 22 | } 23 | 24 | if (A_rows <= 0) { 25 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 26 | } 27 | if (A_cols <= 0) { 28 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 29 | } 30 | if (B_cols <= 0) { 31 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 32 | } 33 | 34 | if (A_padding < 0) { 35 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 36 | } 37 | if (B_padding < 0) { 38 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 39 | } 40 | if (C_padding < 0) { 41 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 42 | } 43 | 44 | const int A_step = A_cols + A_padding; 45 | const int B_step = B_cols + B_padding; 46 | const int C_step = B_cols + C_padding; 47 | 48 | for (int i = 0; i < A_rows; i++) { 49 | for (int j = 0; j < B_cols; j++) { 50 | C[i * C_step + j] = A[i * A_step] * B[j]; 51 | for (int s = 1; s < A_cols; s++) { 52 | C[i * C_step + j] += A[i * A_step + s] * B[s * B_step + j]; 53 | } 54 | } 55 | } 56 | return ESP_OK; 57 | } 58 | -------------------------------------------------------------------------------- /modules/matrix/mul/float/dspm_mult_f32_ansi.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #include "dsps_dotprod.h" 17 | #include "dspm_mult.h" 18 | 19 | // Matrinx A(m,n), m - amount or rows, n - amount of columns 20 | // C(m,k) = A(m,n)*B(n,k) 21 | // c(i,j) = sum(a(i,s)*b(s,j)) , s=1..n 22 | esp_err_t dspm_mult_f32_ansi(const float *A, const float *B, float *C, int m, int n, int k) 23 | { 24 | for (int i = 0 ; i < m ; i++) { 25 | for (int j = 0 ; j < k ; j++) { 26 | C[i * k + j] = A[i * n] * B[j]; 27 | for (int s = 1; s < n ; s++) { 28 | C[i * k + j] += A[i * n + s] * B[s * k + j]; 29 | } 30 | } 31 | } 32 | return ESP_OK; 33 | } 34 | -------------------------------------------------------------------------------- /modules/matrix/mul/include/dspm_mult_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dspm_mult_platform_H_ 2 | #define _dspm_mult_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dspm_mult_f32_ae32_enabled 1 14 | #define dspm_mult_3x3x1_f32_ae32_enabled 1 15 | #define dspm_mult_3x3x3_f32_ae32_enabled 1 16 | #define dspm_mult_4x4x1_f32_ae32_enabled 1 17 | #define dspm_mult_4x4x4_f32_ae32_enabled 1 18 | 19 | #endif 20 | 21 | #if ((XCHAL_HAVE_LOOPS == 1) && (XCHAL_HAVE_MAC16 == 1)) 22 | 23 | #define dspm_mult_s16_ae32_enabled 1 24 | 25 | #endif 26 | #endif // __XTENSA__ 27 | 28 | #if CONFIG_IDF_TARGET_ESP32S3 29 | #define dspm_mult_f32_aes3_enabled 1 30 | #define dspm_mult_s16_aes3_enabled 1 31 | #endif 32 | 33 | #if CONFIG_IDF_TARGET_ESP32P4 34 | #ifdef CONFIG_DSP_OPTIMIZED 35 | #define dspm_mult_f32_arp4_enabled 1 36 | #define dspm_mult_s16_arp4_enabled 1 37 | #else 38 | #define dspm_mult_f32_arp4_enabled 0 39 | #define dspm_mult_s16_arp4_enabled 0 40 | #endif // CONFIG_DSP_OPTIMIZED 41 | 42 | #endif 43 | 44 | #endif // _dspm_mult_platform_H_ 45 | -------------------------------------------------------------------------------- /modules/matrix/mul/test_sim/main.c: -------------------------------------------------------------------------------- 1 | 2 | void test_mmult(); 3 | 4 | int main(void) 5 | { 6 | printf("main starts!\n"); 7 | // xt_iss_profile_enable(); 8 | test_mmult(); 9 | // xt_iss_profile_disable(); 10 | 11 | printf("Test done\n"); 12 | } 13 | -------------------------------------------------------------------------------- /modules/matrix/mul/test_sim/test_mmult.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "dsp_common.h" 7 | 8 | #include "dspm_mult.h" 9 | extern void xt_iss_profile_disable(); 10 | extern void xt_iss_profile_enable(); 11 | 12 | #define M 4 13 | #define N 8 14 | #define K 16 15 | 16 | const int m = M; 17 | const int n = N; 18 | const int k = K; 19 | 20 | float A[M][N]; 21 | float B[N][K]; 22 | float C[M][K]; 23 | float C_compare[M][K]; 24 | 25 | void test_mmult() 26 | { 27 | 28 | float *A_ptr = (float *)A; 29 | float *B_ptr = (float *)B; 30 | float *C_ptr = (float *)C; 31 | float *Cc_ptr = (float *)C_compare; 32 | 33 | for (int i = 0 ; i < m * n; i++) { 34 | A_ptr[i] = i; 35 | B_ptr[i] = i; 36 | } 37 | for (int i = 0 ; i < m ; i++) { 38 | for (int j = 0 ; j < k ; j++) { 39 | C_compare[i][j] = 0; 40 | for (int s = 0 ; s < n ; s++) { 41 | C_compare[i][j] += A[i][s] * B[s][j]; 42 | } 43 | C[i][j] = -1; 44 | } 45 | } 46 | xt_iss_profile_enable(); 47 | dspm_mult_f32_ae32(A_ptr, B_ptr, Cc_ptr, m, n, k); 48 | dspm_mult_f32_aes3(A_ptr, B_ptr, C_ptr, m, n, k); 49 | xt_iss_profile_disable(); 50 | 51 | for (int i = 0 ; i < m ; i++) { 52 | for (int j = 0 ; j < k ; j++) { 53 | printf("[%i][%i] calc=%f, expected =%f\n", i, j, C[i][j], C_compare[i][j]); 54 | } 55 | } 56 | // Compare and check results 57 | for (int i = 0 ; i < m * k ; i++) { 58 | if (Cc_ptr[i] != C_ptr[i]) { 59 | printf("Error - C_ptr= %f, Cc_ptr= %f \n", C_ptr[i], Cc_ptr[i]); 60 | return; 61 | } 62 | } 63 | 64 | printf("Test Pass!\n"); 65 | } 66 | -------------------------------------------------------------------------------- /modules/matrix/mulc/float/dspm_mulc_f32_ansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dspm_mulc.h" 8 | 9 | esp_err_t dspm_mulc_f32_ansi(const float *input, float *output, float C, int rows, int cols, int padd_in, int padd_out, int step_in, int step_out) 10 | { 11 | if (NULL == input) { 12 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 13 | } 14 | if (NULL == output) { 15 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 16 | } 17 | 18 | if (rows <= 0) { 19 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 20 | } 21 | if (cols <= 0) { 22 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 23 | } 24 | 25 | if (padd_in < 0) { 26 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 27 | } 28 | if (padd_out < 0) { 29 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 30 | } 31 | 32 | if (step_in <= 0) { 33 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 34 | } 35 | if (step_out <= 0) { 36 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 37 | } 38 | 39 | const int ptr_input_step = cols + padd_in; 40 | const int ptr_output_step = cols + padd_out; 41 | float *ptr_input = (float *)input; 42 | 43 | for (int row = 0; row < rows; row++) { 44 | for (int col = 0; col < cols; col++) { 45 | output[col * step_out] = ptr_input[col * step_in] * C; 46 | } 47 | ptr_input += ptr_input_step; 48 | output += ptr_output_step; 49 | } 50 | return ESP_OK; 51 | } 52 | -------------------------------------------------------------------------------- /modules/matrix/mulc/include/dspm_mulc_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dspm_mulc_platform_H_ 2 | #define _dspm_mulc_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dspm_mulc_f32_ae32_enabled 1 14 | 15 | #endif 16 | 17 | #endif // __XTENSA__ 18 | 19 | 20 | #endif // _dspm_mulc_platform_H_ 21 | -------------------------------------------------------------------------------- /modules/matrix/sub/include/dspm_sub_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dspm_sub_platform_H_ 2 | #define _dspm_sub_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #define dspm_sub_f32_ae32_enabled 1 14 | 15 | #endif 16 | #endif // __XTENSA__ 17 | 18 | #endif // _dspm_sub_platform_H_ 19 | -------------------------------------------------------------------------------- /modules/support/cplx_gen/dsps_cplx_gen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "dsps_cplx_gen.h" 8 | 9 | esp_err_t dsps_cplx_gen_ansi(cplx_sig_t *cplx_gen, void *output, int32_t len) 10 | { 11 | // angle frequency is already cplx_gen->freq 12 | const int sin_to_cos = cplx_gen->lut_len / 4; 13 | float ph = cplx_gen->phase; 14 | const float fr = cplx_gen->freq; 15 | int sin_pos, cos_pos; 16 | 17 | for (int i = 0 ; i < len; i++) { 18 | 19 | if (ph < 0) { 20 | ph += 1.0; 21 | } 22 | if (ph >= 1.0) { 23 | ph -= 1.0; 24 | } 25 | 26 | sin_pos = (int)(ph * (cplx_gen->lut_len)); 27 | cos_pos = (sin_pos + sin_to_cos) & (cplx_gen->lut_len - 1); 28 | 29 | if (cplx_gen->d_type == S16_FIXED) { 30 | ((int16_t *)output)[i * 2 + 0] = ((int16_t *)cplx_gen->lut)[cos_pos]; 31 | ((int16_t *)output)[i * 2 + 1] = ((int16_t *)cplx_gen->lut)[sin_pos]; 32 | } else { 33 | ((float *)output)[i * 2 + 0] = ((float *)cplx_gen->lut)[cos_pos]; 34 | ((float *)output)[i * 2 + 1] = ((float *)cplx_gen->lut)[sin_pos]; 35 | } 36 | ph += fr; 37 | } 38 | 39 | return ESP_OK; 40 | } 41 | -------------------------------------------------------------------------------- /modules/support/include/dsps_cplx_gen_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _dsps_cplx_gen_platform_H_ 8 | #define _dsps_cplx_gen_platform_H_ 9 | 10 | #include "sdkconfig.h" 11 | 12 | #ifdef __XTENSA__ 13 | #include 14 | #include 15 | 16 | 17 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 18 | 19 | #if CONFIG_IDF_TARGET_ESP32S3 20 | #define dsps_cplx_gen_aes3_enbled 1 21 | #define dsps_cplx_gen_ae32_enbled 0 22 | 23 | #elif CONFIG_IDF_TARGET_ESP32 24 | #define dsps_cplx_gen_ae32_enbled 1 25 | #define dsps_cplx_gen_aes3_enbled 0 26 | 27 | #endif // CONFIG_IDF_TARGET_ESP32S3 CONFIG_IDF_TARGET_ESP32 28 | #endif // 29 | #endif // __XTENSA__ 30 | #endif // _dsps_cplx_gen_platform_H_ 31 | -------------------------------------------------------------------------------- /modules/support/include/dsps_d_gen.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dsps_d_gen_H_ 16 | #define _dsps_d_gen_H_ 17 | #include "dsp_err.h" 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /** 26 | * @brief delta function 27 | * 28 | * The function generate delta function. 29 | * output[i]=0, if i=[0..N) 30 | * output[i]=1, if i=pos, pos: [0..N-1) 31 | * The implementation use ANSI C and could be compiled and run on any platform 32 | * 33 | * @param output: output array. 34 | * @param len: length of the input signal 35 | * @param pos: delta function position 36 | * 37 | * @return 38 | * - ESP_OK on success 39 | * - One of the error codes from DSP library 40 | */ 41 | esp_err_t dsps_d_gen_f32(float *output, int len, int pos); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // _dsps_d_gen_H_ 48 | -------------------------------------------------------------------------------- /modules/support/include/dsps_h_gen.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dsps_h_gen_H_ 16 | #define _dsps_h_gen_H_ 17 | #include "dsp_err.h" 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /** 26 | * @brief Heviside function 27 | * 28 | * The Heviside function. 29 | * output[i]=0, if i=[0..pos) 30 | * output[i]=1, if i=[pos..N) 31 | * The implementation use ANSI C and could be compiled and run on any platform 32 | * 33 | * @param output: output array. 34 | * @param len: length of the input signal 35 | * @param pos: heviside function position 36 | * 37 | * @return 38 | * - ESP_OK on success 39 | * - One of the error codes from DSP library 40 | */ 41 | 42 | esp_err_t dsps_h_gen_f32(float *output, int len, int pos); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // _dsps_h_gen_H_ 49 | -------------------------------------------------------------------------------- /modules/support/include/dsps_sfdr.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dsps_sfdr_H_ 16 | #define _dsps_sfdr_H_ 17 | 18 | 19 | #include "dsp_err.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" 23 | { 24 | #endif 25 | 26 | /** 27 | * @brief SFDR 28 | * 29 | * The function calculates Spurious-Free Dynamic Range. 30 | * The function makes FFT of the input, then search a spectrum maximum, and then compare 31 | * maximum value with all others. Result calculated as minimum value. 32 | * This function have to be used for debug and unit tests only. It's not optimized for real-time processing. 33 | * The implementation use ANSI C and could be compiled and run on any platform 34 | * 35 | * @param[in] input: input array. 36 | * @param len: length of the input signal 37 | * @param use_dc: this parameter define will be DC value used for calculation or not. 38 | * 0 - SNR will not include DC power 39 | * 1 - SNR will include DC power 40 | * 41 | * @return 42 | * - SFDR in DB 43 | */ 44 | float dsps_sfdr_f32(const float *input, int32_t len, int8_t use_dc); 45 | float dsps_sfdr_fc32(const float *input, int32_t len); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif // _dsps_sfdr_H_ 52 | -------------------------------------------------------------------------------- /modules/support/include/dsps_snr.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _DSP_SNR_H_ 16 | #define _DSP_SNR_H_ 17 | 18 | #include "dsp_err.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /** 26 | * @brief SNR 27 | * 28 | * The function calculates signal to noise ration in case if signal is sine tone. 29 | * The function makes FFT of the input, then search a spectrum maximum, and then calculated 30 | * SNR as sum of all harmonics to the maximum value. 31 | * This function have to be used for debug and unit tests only. It's not optimized for real-time processing. 32 | * The implementation use ANSI C and could be compiled and run on any platform 33 | * 34 | * @param input: input array. 35 | * @param len: length of the input signal 36 | * @param use_dc: this parameter define will be DC value used for calculation or not. 37 | * 0 - SNR will not include DC power 38 | * 1 - SNR will include DC power 39 | * 40 | * @return 41 | * - SNR in dB 42 | */ 43 | float dsps_snr_f32(const float *input, int32_t len, uint8_t use_dc); 44 | float dsps_snr_fc32(const float *input, int32_t len); 45 | 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif // _DSP_SNR_H_ 52 | -------------------------------------------------------------------------------- /modules/support/include/dsps_tone_gen.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _dsps_tone_gen_H_ 16 | #define _dsps_tone_gen_H_ 17 | #include "dsp_err.h" 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /** 26 | * @brief tone 27 | * 28 | * The function generate a tone signal. 29 | * x[i]=A*sin(2*PI*i + ph/180*PI) 30 | * The implementation use ANSI C and could be compiled and run on any platform 31 | * 32 | * @param output: output array. 33 | * @param len: length of the input signal 34 | * @param Ampl: amplitude 35 | * @param freq: Naiquist frequency -1..1 36 | * @param phase: phase in degree 37 | * 38 | * @return 39 | * - ESP_OK on success 40 | * - One of the error codes from DSP library 41 | */ 42 | esp_err_t dsps_tone_gen_f32(float *output, int len, float Ampl, float freq, float phase); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // _dsps_tone_gen_H_ 49 | -------------------------------------------------------------------------------- /modules/support/mem/include/dsps_mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef _dsps_mem_H_ 8 | #define _dsps_mem_H_ 9 | 10 | #include "dsp_err.h" 11 | #include "dsp_common.h" 12 | #include "dsps_mem_platform.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | 19 | /**@{*/ 20 | /** 21 | * @brief memory copy function using esp32s3 TIE 22 | * 23 | * The extension (_aes3) is optimized for esp32S3 chip. 24 | * 25 | * @param arr_dest: pointer to the destination array 26 | * @param arr_src: pointer to the source array 27 | * @param arr_len: count of bytes to be copied from arr_src to arr_dest 28 | * 29 | * @return: pointer to dest array 30 | */ 31 | void *dsps_memcpy_aes3(void *arr_dest, const void *arr_src, size_t arr_len); 32 | 33 | /**@{*/ 34 | /** 35 | * @brief memory set function using esp32s3 TIE 36 | * 37 | * The extension (_aes3) is optimized for esp32S3 chip. 38 | * 39 | * @param arr_dest: pointer to the destination array 40 | * @param set_val: byte value, the dest array will be set with 41 | * @param set_size: count of bytes, the dest array will be set with 42 | * 43 | * @return: pointer to dest array 44 | */ 45 | void *dsps_memset_aes3(void *arr_dest, uint8_t set_val, size_t set_size); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #if CONFIG_DSP_OPTIMIZED 52 | 53 | #if dsps_mem_aes3_enbled 54 | #define dsps_memcpy dsps_memcpy_aes3 55 | #define dsps_memset dsps_memset_aes3 56 | #else 57 | #define dsps_memcpy memcpy 58 | #define dsps_memset memset 59 | #endif 60 | 61 | #else // CONFIG_DSP_OPTIMIZED 62 | 63 | #define dsps_memcpy memcpy 64 | #define dsps_memset memset 65 | 66 | #endif // CONFIG_DSP_OPTIMIZED 67 | #endif // _dsps_mem_H_ 68 | -------------------------------------------------------------------------------- /modules/support/mem/include/dsps_mem_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _dsps_mem_platform_H_ 2 | #define _dsps_mem_platform_H_ 3 | 4 | #include "sdkconfig.h" 5 | 6 | #ifdef __XTENSA__ 7 | #include 8 | #include 9 | 10 | 11 | #if ((XCHAL_HAVE_FP == 1) && (XCHAL_HAVE_LOOPS == 1)) 12 | 13 | #if CONFIG_IDF_TARGET_ESP32S3 14 | #define dsps_mem_aes3_enbled 1 15 | #else 16 | #define dsps_mem_aes3_enbled 0 17 | #endif // CONFIG_IDF_TARGET_ESP32S3 18 | 19 | #endif // 20 | #endif // __XTENSA__ 21 | #endif // _dsps_mem_platform_H_ 22 | -------------------------------------------------------------------------------- /modules/support/misc/dsps_d_gen.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_d_gen.h" 16 | 17 | esp_err_t dsps_d_gen_f32(float *output, int len, int pos) 18 | { 19 | if (pos >= len) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (pos < 0) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | for (int i = 0 ; i < len ; i++) { 26 | output[i] = 0; 27 | } 28 | output[pos] = 1; 29 | return ESP_OK; 30 | } 31 | -------------------------------------------------------------------------------- /modules/support/misc/dsps_h_gen.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_h_gen.h" 16 | 17 | esp_err_t dsps_h_gen_f32(float *output, int len, int pos) 18 | { 19 | if (pos >= len) { 20 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 21 | } 22 | if (pos < 0) { 23 | return ESP_ERR_DSP_PARAM_OUTOFRANGE; 24 | } 25 | for (int i = 0 ; i < pos ; i++) { 26 | output[i] = 0; 27 | } 28 | for (int i = pos ; i < len ; i++) { 29 | output[i] = 1; 30 | } 31 | return ESP_OK; 32 | } 33 | -------------------------------------------------------------------------------- /modules/support/misc/dsps_tone_gen.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "dsps_tone_gen.h" 16 | #include 17 | 18 | esp_err_t dsps_tone_gen_f32(float *output, int len, float Ampl, float freq, float phase) 19 | { 20 | if (freq >= 1) { 21 | return ESP_ERR_DSP_INVALID_PARAM; 22 | } 23 | if (freq <= -1) { 24 | return ESP_ERR_DSP_INVALID_PARAM; 25 | } 26 | float ph = phase / 180 * M_PI; 27 | float fr = 2 * M_PI * freq; 28 | for (int i = 0 ; i < len ; i++) { 29 | output[i] = Ampl * sin(ph); 30 | ph += fr; 31 | if (ph > 2 * M_PI) { 32 | ph -= 2 * M_PI; 33 | } 34 | if (ph < -2 * M_PI) { 35 | ph += 2 * M_PI; 36 | } 37 | } 38 | return ESP_OK; 39 | } 40 | -------------------------------------------------------------------------------- /modules/support/sfdr/test/test_dsps_sfdr_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include "unity.h" 17 | #include "dsp_platform.h" 18 | #include "esp_log.h" 19 | 20 | #include "dsps_view.h" 21 | #include "dsps_sfdr.h" 22 | #include "dsps_fft2r.h" 23 | 24 | 25 | static const char *TAG = "dsps_sfdr_f32"; 26 | 27 | TEST_CASE("dsps_sfdr_f32 functionality", "[dsps]") 28 | { 29 | int N = 512; 30 | float *data = (float *)malloc(N * 2 * sizeof(float)); 31 | int check_bin = 32; 32 | float sfdr_exp = 4; 33 | for (int i = 0 ; i < N ; i++) { 34 | data[i] = 4 * sinf(M_PI / N * check_bin * i) / (N / 2); 35 | data[i] += sinf(M_PI / N * check_bin * i * 2) / (N / 2); 36 | } 37 | 38 | float sfdr = dsps_sfdr_f32(data, N, 1); 39 | TEST_ASSERT_EQUAL( (int)20 * log10(sfdr_exp), (int)sfdr); 40 | ESP_LOGI(TAG, "dsps_sfdr_f32 = %f dB", sfdr); 41 | dsps_fft2r_deinit_fc32(); 42 | free(data); 43 | } 44 | -------------------------------------------------------------------------------- /modules/support/snr/test/test_dsps_snr_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include "unity.h" 17 | #include "dsp_platform.h" 18 | #include "esp_log.h" 19 | 20 | #include "dsps_view.h" 21 | #include "dsps_snr.h" 22 | #include "dsps_fft2r.h" 23 | 24 | 25 | static const char *TAG = "dsps_snr_f32"; 26 | 27 | 28 | TEST_CASE("dsps_snr_f32 functionality", "[dsps]") 29 | { 30 | int N = 512; 31 | float *data = (float *)malloc(N * 2 * sizeof(float)); 32 | int check_bin = 32; 33 | float snr_exp = 0.001; 34 | for (int i = 0 ; i < N ; i++) { 35 | data[i] = 1 * sinf(M_PI / N * check_bin * i) / (N / 2); 36 | data[i] += 0.001 / N; //0.1*sinf(M_PI/N*check_bin*i*2)/(N/2); 37 | } 38 | 39 | float snr = dsps_snr_f32(data, N, 1); 40 | TEST_ASSERT_EQUAL(-round(20 * log10(snr_exp) + 3), (int)round(snr)); 41 | ESP_LOGI(TAG, "dsps_snr_f32 = %f dB", snr); 42 | dsps_fft2r_deinit_fc32(); 43 | free(data); 44 | } 45 | -------------------------------------------------------------------------------- /modules/support/view/test/test_dsps_view.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include "unity.h" 17 | #include "dsp_platform.h" 18 | #include "esp_log.h" 19 | 20 | #include "dsps_view.h" 21 | 22 | 23 | static const char *TAG = "dsps_view"; 24 | 25 | TEST_CASE("dsps_view functionality", "[dsps]") 26 | { 27 | float *data = (float *)malloc(1024 * sizeof(float)); 28 | for (int i = 0 ; i < 1024 ; i++) { 29 | data[i] = -100; 30 | } 31 | data[256] = 0; 32 | dsps_view_spectrum(data, 1024, -100, 0); 33 | 34 | ESP_LOGI(TAG, "Just a check\n"); 35 | free(data); 36 | } 37 | -------------------------------------------------------------------------------- /modules/windows/blackman/float/dsps_wind_blackman_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define _USE_MATH_DEFINES 16 | #include "dsps_wind_blackman.h" 17 | #include 18 | 19 | void dsps_wind_blackman_f32(float *window, int len) 20 | { 21 | const float a0 = 0.42; 22 | const float a1 = 0.5; 23 | const float a2 = 0.08; 24 | 25 | float len_mult = 1 / (float)(len - 1); 26 | for (int i = 0; i < len; i++) { 27 | window[i] = a0 - a1 * cosf(i * 2 * M_PI * len_mult) + a2 * cosf(i * 4 * M_PI * len_mult); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /modules/windows/blackman/include/dsps_wind_blackman.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_blackman_H_ 17 | #define _dsps_wind_blackman_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /** 25 | * @brief Blackman window 26 | * 27 | * The function generates Blackman window for plpha = 0.16. 28 | * 29 | * @param window: buffer to store window array. 30 | * @param len: length of the window array 31 | * 32 | */ 33 | void dsps_wind_blackman_f32(float *window, int len); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // _dsps_wind_blackman_H_ 39 | -------------------------------------------------------------------------------- /modules/windows/blackman_harris/float/dsps_wind_blackman_harris_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define _USE_MATH_DEFINES 16 | #include "dsps_wind_blackman_harris.h" 17 | #include 18 | 19 | void dsps_wind_blackman_harris_f32(float *window, int len) 20 | { 21 | const float a0 = 0.35875; 22 | const float a1 = 0.48829; 23 | const float a2 = 0.14128; 24 | const float a3 = 0.01168; 25 | 26 | float len_mult = 1 / (float)(len - 1); 27 | for (int i = 0; i < len; i++) { 28 | window[i] = a0 29 | - a1 * cosf(i * 2 * M_PI * len_mult) 30 | + a2 * cosf(i * 4 * M_PI * len_mult) 31 | - a3 * cosf(i * 6 * M_PI * len_mult); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /modules/windows/blackman_harris/include/dsps_wind_blackman_harris.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_blackman_harris_H_ 17 | #define _dsps_wind_blackman_harris_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /** 25 | * @brief Blackman-Harris window 26 | * 27 | * The function generates Blackman-Harris window. 28 | * 29 | * @param window: buffer to store window array. 30 | * @param len: length of the window array 31 | * 32 | */ 33 | void dsps_wind_blackman_harris_f32(float *window, int len); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // _dsps_wind_blackman_harris_H_ 39 | -------------------------------------------------------------------------------- /modules/windows/blackman_nuttall/float/dsps_wind_blackman_nuttall_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define _USE_MATH_DEFINES 16 | #include "dsps_wind_blackman_nuttall.h" 17 | #include 18 | 19 | void dsps_wind_blackman_nuttall_f32(float *window, int len) 20 | { 21 | const float a0 = 0.3635819; 22 | const float a1 = 0.4891775; 23 | const float a2 = 0.1365995; 24 | const float a3 = 0.0106411; 25 | 26 | float len_mult = 1 / (float)(len - 1); 27 | for (int i = 0; i < len; i++) { 28 | window[i] = a0 29 | - a1 * cosf(i * 2 * M_PI * len_mult) 30 | + a2 * cosf(i * 4 * M_PI * len_mult) 31 | - a3 * cosf(i * 6 * M_PI * len_mult); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /modules/windows/blackman_nuttall/include/dsps_wind_blackman_nuttall.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_blackman_nuttall_H_ 17 | #define _dsps_wind_blackman_nuttall_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /** 25 | * @brief Blackman-Nuttall window 26 | * 27 | * The function generates Blackman-Nuttall window. 28 | * 29 | * @param window: buffer to store window array. 30 | * @param len: length of the window array 31 | * 32 | */ 33 | void dsps_wind_blackman_nuttall_f32(float *window, int len); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // _dsps_wind_blackman_nuttall_H_ 39 | -------------------------------------------------------------------------------- /modules/windows/flat_top/float/dsps_wind_flat_top_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define _USE_MATH_DEFINES 16 | #include "dsps_wind_flat_top.h" 17 | #include 18 | 19 | void dsps_wind_flat_top_f32(float *window, int len) 20 | { 21 | const float a0 = 0.21557895; 22 | const float a1 = 0.41663158; 23 | const float a2 = 0.277263158; 24 | const float a3 = 0.083578947; 25 | const float a4 = 0.006947368; 26 | 27 | float len_mult = 1 / (float)(len - 1); 28 | for (int i = 0; i < len; i++) { 29 | window[i] = a0 30 | - a1 * cosf(i * 2 * M_PI * len_mult) 31 | + a2 * cosf(i * 4 * M_PI * len_mult) 32 | - a3 * cosf(i * 6 * M_PI * len_mult) 33 | + a4 * cosf(i * 8 * M_PI * len_mult); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /modules/windows/flat_top/include/dsps_wind_flat_top.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_flat_top_H_ 17 | #define _dsps_wind_flat_top_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /** 25 | * @brief Flat-Top window 26 | * 27 | * The function generates Flat-Top window. 28 | * 29 | * @param window: buffer to store window array. 30 | * @param len: length of the window array 31 | * 32 | */ 33 | void dsps_wind_flat_top_f32(float *window, int len); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // _dsps_wind_flat_top_H_ 39 | -------------------------------------------------------------------------------- /modules/windows/hann/float/dsps_wind_hann_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define _USE_MATH_DEFINES 16 | #include "dsps_wind_hann.h" 17 | #include 18 | 19 | void dsps_wind_hann_f32(float *window, int len) 20 | { 21 | float len_mult = 1 / (float)(len - 1); 22 | for (int i = 0; i < len; i++) { 23 | window[i] = 0.5 * (1 - cosf(i * 2 * M_PI * len_mult)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /modules/windows/hann/include/dsps_wind_hann.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_hann_H_ 17 | #define _dsps_wind_hann_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /** 25 | * @brief Hann window 26 | * 27 | * The function generates Hann window. 28 | * 29 | * @param window: buffer to store window array. 30 | * @param len: length of the window array 31 | * 32 | */ 33 | void dsps_wind_hann_f32(float *window, int len); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // _dsps_wind_hann_H_ 39 | -------------------------------------------------------------------------------- /modules/windows/include/dsps_wind.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_H_ 17 | #define _dsps_wind_H_ 18 | 19 | #include "dsps_wind_hann.h" 20 | #include "dsps_wind_blackman.h" 21 | #include "dsps_wind_blackman_harris.h" 22 | #include "dsps_wind_blackman_nuttall.h" 23 | #include "dsps_wind_nuttall.h" 24 | #include "dsps_wind_flat_top.h" 25 | 26 | #endif // _dsps_wind_H_ 27 | -------------------------------------------------------------------------------- /modules/windows/nuttall/float/dsps_wind_nuttall_f32.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define _USE_MATH_DEFINES 16 | #include "dsps_wind_nuttall.h" 17 | #include 18 | 19 | void dsps_wind_nuttall_f32(float *window, int len) 20 | { 21 | const float a0 = 0.355768; 22 | const float a1 = 0.487396; 23 | const float a2 = 0.144232; 24 | const float a3 = 0.012604; 25 | 26 | float len_mult = 1 / (float)(len - 1); 27 | for (int i = 0; i < len; i++) { 28 | window[i] = a0 29 | - a1 * cosf(i * 2 * M_PI * len_mult) 30 | + a2 * cosf(i * 4 * M_PI * len_mult) 31 | - a3 * cosf(i * 6 * M_PI * len_mult); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /modules/windows/nuttall/include/dsps_wind_nuttall.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | #ifndef _dsps_wind_nuttall_H_ 17 | #define _dsps_wind_nuttall_H_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | /** 25 | * @brief Nuttall window 26 | * 27 | * The function generates Nuttall window. 28 | * 29 | * @param window: buffer to store window array. 30 | * @param len: length of the window array 31 | * 32 | */ 33 | void dsps_wind_nuttall_f32(float *window, int len); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif // _dsps_wind_nuttall_H_ 39 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCDIRS 2 | "." 3 | "../modules/dotprod/test" 4 | "../modules/matrix/mul/test" 5 | "../modules/matrix/add/test" 6 | "../modules/matrix/addc/test" 7 | "../modules/matrix/mulc/test" 8 | "../modules/matrix/sub/test" 9 | "../modules/iir/test" 10 | "../modules/fir/test" 11 | "../modules/math/mulc/test" 12 | "../modules/math/addc/test" 13 | "../modules/math/add/test" 14 | "../modules/math/sub/test" 15 | "../modules/math/mul/test" 16 | "../modules/math/sqrt/test" 17 | "../modules/support/view/test" 18 | "../modules/support/snr/test" 19 | "../modules/support/sfdr/test" 20 | "../modules/support/cplx_gen/test" 21 | "../modules/fft/test" 22 | "../modules/dct/test" 23 | "../modules/conv/test" 24 | "../modules/kalman/ekf_imu13states/test" 25 | 26 | ) 27 | 28 | if(target STREQUAL "esp32s3") 29 | list(APPEND COMPONENT_SRCDIRS "../modules/support/mem/test") 30 | endif() 31 | 32 | set(COMPONENT_REQUIRES unity esp-dsp) 33 | 34 | set(COMPONENT_ADD_LDFRAGMENTS linker.lf) 35 | 36 | register_component() 37 | -------------------------------------------------------------------------------- /test/component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_SRCDIRS := \ 2 | . \ 3 | ../modules/dotprod/test \ 4 | ../modules/matrix/add/test \ 5 | ../modules/matrix/addc/test \ 6 | ../modules/matrix/mul/test \ 7 | ../modules/matrix/mulc/test \ 8 | ../modules/matrix/sub/test \ 9 | ../modules/iir/test \ 10 | ../modules/fir/test \ 11 | ../modules/math/mulc/test \ 12 | ../modules/math/addc/test \ 13 | ../modules/math/add/test \ 14 | ../modules/math/sub/test \ 15 | ../modules/math/mul/test \ 16 | ../modules/math/sqrt/test \ 17 | ../modules/support/view/test \ 18 | ../modules/support/snr/test \ 19 | ../modules/support/sfdr/test \ 20 | ../modules/windows/test \ 21 | ../modules/conv/test \ 22 | ../modules/fft/test \ 23 | ../modules/dct/test 24 | 25 | COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive 26 | 27 | COMPONENT_ADD_LDFRAGMENTS += linker.lf 28 | -------------------------------------------------------------------------------- /test/linker.lf: -------------------------------------------------------------------------------- 1 | [mapping:dsp] 2 | archive: libesp-dsp.a 3 | entries: 4 | * (noflash) 5 | * (noflash_data) 6 | * (noflash_text) 7 | 8 | [mapping:dsp2] 9 | archive: libdsp.a 10 | entries: 11 | * (noflash) 12 | * (noflash_data) 13 | * (noflash_text) 14 | 15 | [mapping:dsp_test] 16 | archive: libesp-dsp_test.a 17 | entries: 18 | * (noflash) 19 | * (noflash_data) 20 | * (noflash_text) 21 | -------------------------------------------------------------------------------- /test_app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This is the project CMakeLists.txt file for the test subproject 2 | cmake_minimum_required(VERSION 3.5) 3 | 4 | # Include the components directory of the main application: 5 | # 6 | set(EXTRA_COMPONENT_DIRS "../") 7 | set(IDF_EXCLUDE_COMPONENTS "test" "test_app") 8 | 9 | set(TEST_COMPONENTS "esp-dsp" CACHE STRING "List of components to test") 10 | 11 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 12 | project(test_app) 13 | -------------------------------------------------------------------------------- /test_app/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile for the test subproject. 3 | # 4 | 5 | PROJECT_NAME := test_app 6 | 7 | # Include the components directory of the main application: 8 | # 9 | EXTRA_COMPONENT_DIRS := $(realpath ..) 10 | EXCLUDE_COMPONENTS := test_app 11 | TEST_COMPONENTS ?= esp-dsp 12 | 13 | include $(IDF_PATH)/make/project.mk 14 | -------------------------------------------------------------------------------- /test_app/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "test_app_main.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS ".") 3 | 4 | register_component() 5 | -------------------------------------------------------------------------------- /test_app/main/component.mk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-dsp/eedf2a50811195224f07f941250a99bf1368d69e/test_app/main/component.mk -------------------------------------------------------------------------------- /test_app/main/test_app_main.c: -------------------------------------------------------------------------------- 1 | #include "esp_dsp.h" 2 | #include 3 | 4 | #include "unity.h" 5 | 6 | #include "sdkconfig.h" 7 | #include "dsp_tests.h" 8 | 9 | void app_main() 10 | { 11 | unity_run_menu(); 12 | } 13 | -------------------------------------------------------------------------------- /test_app/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | # only the files with prefix `pytest_` would be recognized as pytest test scripts. 3 | python_files = pytest_*.py 4 | 5 | # ignore PytestExperimentalApiWarning for record_xml_attribute 6 | # set traceback to "short" to prevent the overwhelming tracebacks 7 | addopts = 8 | -s 9 | --embedded-services esp,idf 10 | --tb short 11 | --skip-check-coredump y 12 | 13 | # ignore DeprecationWarning 14 | filterwarnings = 15 | ignore::DeprecationWarning:matplotlib.*: 16 | ignore::DeprecationWarning:google.protobuf.*: 17 | ignore::_pytest.warning_types.PytestExperimentalApiWarning 18 | 19 | markers = 20 | # target markers 21 | esp32: support esp32 target 22 | esp32s3: support esp32s3 target 23 | 24 | # log related 25 | log_cli = True 26 | log_cli_level = INFO 27 | log_cli_format = %(asctime)s %(levelname)s %(message)s 28 | log_cli_date_format = %Y-%m-%d %H:%M:%S 29 | 30 | # junit related 31 | junit_family = xunit1 32 | 33 | ## log all to `system-out` when case fail 34 | junit_logging = stdout 35 | junit_log_passing_tests = False 36 | -------------------------------------------------------------------------------- /test_app/pytest_esp-dsp_unity_tests.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | import pytest 5 | from pytest_embedded import Dut 6 | 7 | @pytest.mark.esp32 8 | @pytest.mark.esp32s3 9 | def test_esp_system(dut: Dut) -> None: 10 | dut.run_all_single_board_cases() 11 | 12 | -------------------------------------------------------------------------------- /test_app/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | CONFIG_PARTITION_TABLE_OFFSET=0x9000 2 | CONFIG_ESP_TASK_WDT=n 3 | CONFIG_OPTIMIZATION_LEVEL_RELEASE=y 4 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 5 | CONFIG_ETH_USE_SPI_ETHERNET=n 6 | --------------------------------------------------------------------------------