├── LICENSE ├── README.md ├── capuchin-MCU ├── .ccsproject ├── .cproject ├── .launches │ └── Capuchin-MCU.launch ├── .project ├── .settings │ ├── org.eclipse.cdt.codan.core.prefs │ ├── org.eclipse.cdt.debug.core.prefs │ └── org.eclipse.core.resources.prefs ├── DSPLib │ ├── include │ │ ├── DSPLib.h │ │ ├── DSPLib_filter.h │ │ ├── DSPLib_lea.h │ │ ├── DSPLib_matrix.h │ │ ├── DSPLib_support.h │ │ ├── DSPLib_transform.h │ │ ├── DSPLib_types.h │ │ ├── DSPLib_utility.h │ │ └── DSPLib_vector.h │ └── source │ │ ├── filter │ │ ├── msp_biquad_cascade_df1_q15.c │ │ ├── msp_biquad_cascade_df2_ext_q15.c │ │ ├── msp_biquad_cascade_df2_q15.c │ │ ├── msp_biquad_df1_q15.c │ │ ├── msp_biquad_df2_ext_q15.c │ │ ├── msp_biquad_df2_q15.c │ │ ├── msp_cmplx_fir_iq31.c │ │ ├── msp_cmplx_fir_q15.c │ │ ├── msp_fir_iq31.c │ │ └── msp_fir_q15.c │ │ ├── lea │ │ ├── msp_lea_flags.c │ │ ├── msp_lea_init.c │ │ ├── msp_lea_isr.c │ │ └── msp_lea_patch.c │ │ ├── matrix │ │ ├── msp_matrix_abs_iq31.c │ │ ├── msp_matrix_abs_q15.c │ │ ├── msp_matrix_add_iq31.c │ │ ├── msp_matrix_add_q15.c │ │ ├── msp_matrix_mpy_iq31.c │ │ ├── msp_matrix_mpy_q15.c │ │ ├── msp_matrix_neg_iq31.c │ │ ├── msp_matrix_neg_q15.c │ │ ├── msp_matrix_offset_iq31.c │ │ ├── msp_matrix_offset_q15.c │ │ ├── msp_matrix_scale_iq31.c │ │ ├── msp_matrix_scale_q15.c │ │ ├── msp_matrix_shift_iq31.c │ │ ├── msp_matrix_shift_q15.c │ │ ├── msp_matrix_sub_iq31.c │ │ ├── msp_matrix_sub_q15.c │ │ ├── msp_matrix_trans_iq31.c │ │ └── msp_matrix_trans_q15.c │ │ ├── transform │ │ ├── msp_cmplx_bitrev_iq31.c │ │ ├── msp_cmplx_bitrev_q15.c │ │ ├── msp_cmplx_fft_auto_q15.c │ │ ├── msp_cmplx_fft_fixed_q15.c │ │ ├── msp_cmplx_fft_iq31.c │ │ ├── msp_cmplx_ifft_auto_q15.c │ │ ├── msp_cmplx_ifft_fixed_q15.c │ │ ├── msp_cmplx_ifft_iq31.c │ │ ├── msp_fft_auto_q15.c │ │ ├── msp_fft_fixed_q15.c │ │ ├── msp_fft_iq31.c │ │ ├── msp_ifft_auto_q15.c │ │ ├── msp_ifft_fixed_q15.c │ │ ├── msp_ifft_iq31.c │ │ ├── msp_split_iq31.c │ │ ├── msp_split_q15.c │ │ └── msp_transform_tables.c │ │ ├── utility │ │ ├── msp_cmplx_fill_iq31.c │ │ ├── msp_cmplx_fill_q15.c │ │ ├── msp_cmplx_iq31.c │ │ ├── msp_cmplx_q15.c │ │ ├── msp_copy_iq31.c │ │ ├── msp_copy_q15.c │ │ ├── msp_deinterleave_iq31.c │ │ ├── msp_deinterleave_q15.c │ │ ├── msp_fill_iq31.c │ │ ├── msp_fill_q15.c │ │ ├── msp_interleave_iq31.c │ │ ├── msp_interleave_q15.c │ │ ├── msp_iq31_to_q15.c │ │ ├── msp_q15_to_iq31.c │ │ └── msp_sinusoid_q15.c │ │ └── vector │ │ ├── msp_abs_iq31.c │ │ ├── msp_abs_q15.c │ │ ├── msp_add_iq31.c │ │ ├── msp_add_q15.c │ │ ├── msp_cmplx_add_iq31.c │ │ ├── msp_cmplx_add_q15.c │ │ ├── msp_cmplx_conj_iq31.c │ │ ├── msp_cmplx_conj_q15.c │ │ ├── msp_cmplx_mac_iq31.c │ │ ├── msp_cmplx_mac_q15.c │ │ ├── msp_cmplx_mpy_iq31.c │ │ ├── msp_cmplx_mpy_q15.c │ │ ├── msp_cmplx_mpy_real_iq31.c │ │ ├── msp_cmplx_mpy_real_q15.c │ │ ├── msp_cmplx_scale_iq31.c │ │ ├── msp_cmplx_scale_q15.c │ │ ├── msp_cmplx_shift_iq31.c │ │ ├── msp_cmplx_shift_q15.c │ │ ├── msp_cmplx_sub_iq31.c │ │ ├── msp_cmplx_sub_q15.c │ │ ├── msp_mac_iq31.c │ │ ├── msp_mac_q15.c │ │ ├── msp_max_iq31.c │ │ ├── msp_max_q15.c │ │ ├── msp_max_uq15.c │ │ ├── msp_max_uq31.c │ │ ├── msp_min_iq31.c │ │ ├── msp_min_q15.c │ │ ├── msp_min_uq15.c │ │ ├── msp_min_uq31.c │ │ ├── msp_mpy_iq31.c │ │ ├── msp_mpy_q15.c │ │ ├── msp_neg_iq31.c │ │ ├── msp_neg_q15.c │ │ ├── msp_offset_iq31.c │ │ ├── msp_offset_q15.c │ │ ├── msp_scale_iq31.c │ │ ├── msp_scale_q15.c │ │ ├── msp_shift_iq31.c │ │ ├── msp_shift_q15.c │ │ ├── msp_sub_iq31.c │ │ └── msp_sub_q15.c ├── Debug │ ├── Capuchin-MCU.map │ ├── Capuchin-MCU.out │ ├── Capuchin-MCU_linkInfo.xml │ ├── DSPLib │ │ └── source │ │ │ ├── filter │ │ │ ├── msp_biquad_cascade_df1_q15.d │ │ │ ├── msp_biquad_cascade_df1_q15.obj │ │ │ ├── msp_biquad_cascade_df2_ext_q15.d │ │ │ ├── msp_biquad_cascade_df2_ext_q15.obj │ │ │ ├── msp_biquad_cascade_df2_q15.d │ │ │ ├── msp_biquad_cascade_df2_q15.obj │ │ │ ├── msp_biquad_df1_q15.d │ │ │ ├── msp_biquad_df1_q15.obj │ │ │ ├── msp_biquad_df2_ext_q15.d │ │ │ ├── msp_biquad_df2_ext_q15.obj │ │ │ ├── msp_biquad_df2_q15.d │ │ │ ├── msp_biquad_df2_q15.obj │ │ │ ├── msp_cmplx_fir_iq31.d │ │ │ ├── msp_cmplx_fir_iq31.obj │ │ │ ├── msp_cmplx_fir_q15.d │ │ │ ├── msp_cmplx_fir_q15.obj │ │ │ ├── msp_fir_iq31.d │ │ │ ├── msp_fir_iq31.obj │ │ │ ├── msp_fir_q15.d │ │ │ ├── msp_fir_q15.obj │ │ │ ├── subdir_rules.mk │ │ │ └── subdir_vars.mk │ │ │ ├── lea │ │ │ ├── msp_lea_flags.d │ │ │ ├── msp_lea_flags.obj │ │ │ ├── msp_lea_init.d │ │ │ ├── msp_lea_init.obj │ │ │ ├── msp_lea_isr.d │ │ │ ├── msp_lea_isr.obj │ │ │ ├── msp_lea_patch.d │ │ │ ├── msp_lea_patch.obj │ │ │ ├── subdir_rules.mk │ │ │ └── subdir_vars.mk │ │ │ ├── matrix │ │ │ ├── msp_matrix_abs_iq31.d │ │ │ ├── msp_matrix_abs_iq31.obj │ │ │ ├── msp_matrix_abs_q15.d │ │ │ ├── msp_matrix_abs_q15.obj │ │ │ ├── msp_matrix_add_iq31.d │ │ │ ├── msp_matrix_add_iq31.obj │ │ │ ├── msp_matrix_add_q15.d │ │ │ ├── msp_matrix_add_q15.obj │ │ │ ├── msp_matrix_mpy_iq31.d │ │ │ ├── msp_matrix_mpy_iq31.obj │ │ │ ├── msp_matrix_mpy_q15.d │ │ │ ├── msp_matrix_mpy_q15.obj │ │ │ ├── msp_matrix_neg_iq31.d │ │ │ ├── msp_matrix_neg_iq31.obj │ │ │ ├── msp_matrix_neg_q15.d │ │ │ ├── msp_matrix_neg_q15.obj │ │ │ ├── msp_matrix_offset_iq31.d │ │ │ ├── msp_matrix_offset_iq31.obj │ │ │ ├── msp_matrix_offset_q15.d │ │ │ ├── msp_matrix_offset_q15.obj │ │ │ ├── msp_matrix_scale_iq31.d │ │ │ ├── msp_matrix_scale_iq31.obj │ │ │ ├── msp_matrix_scale_q15.d │ │ │ ├── msp_matrix_scale_q15.obj │ │ │ ├── msp_matrix_shift_iq31.d │ │ │ ├── msp_matrix_shift_iq31.obj │ │ │ ├── msp_matrix_shift_q15.d │ │ │ ├── msp_matrix_shift_q15.obj │ │ │ ├── msp_matrix_sub_iq31.d │ │ │ ├── msp_matrix_sub_iq31.obj │ │ │ ├── msp_matrix_sub_q15.d │ │ │ ├── msp_matrix_sub_q15.obj │ │ │ ├── msp_matrix_trans_iq31.d │ │ │ ├── msp_matrix_trans_iq31.obj │ │ │ ├── msp_matrix_trans_q15.d │ │ │ ├── msp_matrix_trans_q15.obj │ │ │ ├── subdir_rules.mk │ │ │ └── subdir_vars.mk │ │ │ ├── transform │ │ │ ├── msp_cmplx_bitrev_iq31.d │ │ │ ├── msp_cmplx_bitrev_iq31.obj │ │ │ ├── msp_cmplx_bitrev_q15.d │ │ │ ├── msp_cmplx_bitrev_q15.obj │ │ │ ├── msp_cmplx_fft_auto_q15.d │ │ │ ├── msp_cmplx_fft_auto_q15.obj │ │ │ ├── msp_cmplx_fft_fixed_q15.d │ │ │ ├── msp_cmplx_fft_fixed_q15.obj │ │ │ ├── msp_cmplx_fft_iq31.d │ │ │ ├── msp_cmplx_fft_iq31.obj │ │ │ ├── msp_cmplx_ifft_auto_q15.d │ │ │ ├── msp_cmplx_ifft_auto_q15.obj │ │ │ ├── msp_cmplx_ifft_fixed_q15.d │ │ │ ├── msp_cmplx_ifft_fixed_q15.obj │ │ │ ├── msp_cmplx_ifft_iq31.d │ │ │ ├── msp_cmplx_ifft_iq31.obj │ │ │ ├── msp_fft_auto_q15.d │ │ │ ├── msp_fft_auto_q15.obj │ │ │ ├── msp_fft_fixed_q15.d │ │ │ ├── msp_fft_fixed_q15.obj │ │ │ ├── msp_fft_iq31.d │ │ │ ├── msp_fft_iq31.obj │ │ │ ├── msp_ifft_auto_q15.d │ │ │ ├── msp_ifft_auto_q15.obj │ │ │ ├── msp_ifft_fixed_q15.d │ │ │ ├── msp_ifft_fixed_q15.obj │ │ │ ├── msp_ifft_iq31.d │ │ │ ├── msp_ifft_iq31.obj │ │ │ ├── msp_split_iq31.d │ │ │ ├── msp_split_iq31.obj │ │ │ ├── msp_split_q15.d │ │ │ ├── msp_split_q15.obj │ │ │ ├── msp_transform_tables.d │ │ │ ├── msp_transform_tables.obj │ │ │ ├── subdir_rules.mk │ │ │ └── subdir_vars.mk │ │ │ ├── utility │ │ │ ├── msp_cmplx_fill_iq31.d │ │ │ ├── msp_cmplx_fill_iq31.obj │ │ │ ├── msp_cmplx_fill_q15.d │ │ │ ├── msp_cmplx_fill_q15.obj │ │ │ ├── msp_cmplx_iq31.d │ │ │ ├── msp_cmplx_iq31.obj │ │ │ ├── msp_cmplx_q15.d │ │ │ ├── msp_cmplx_q15.obj │ │ │ ├── msp_copy_iq31.d │ │ │ ├── msp_copy_iq31.obj │ │ │ ├── msp_copy_q15.d │ │ │ ├── msp_copy_q15.obj │ │ │ ├── msp_deinterleave_iq31.d │ │ │ ├── msp_deinterleave_iq31.obj │ │ │ ├── msp_deinterleave_q15.d │ │ │ ├── msp_deinterleave_q15.obj │ │ │ ├── msp_fill_iq31.d │ │ │ ├── msp_fill_iq31.obj │ │ │ ├── msp_fill_q15.d │ │ │ ├── msp_fill_q15.obj │ │ │ ├── msp_interleave_iq31.d │ │ │ ├── msp_interleave_iq31.obj │ │ │ ├── msp_interleave_q15.d │ │ │ ├── msp_interleave_q15.obj │ │ │ ├── msp_iq31_to_q15.d │ │ │ ├── msp_iq31_to_q15.obj │ │ │ ├── msp_q15_to_iq31.d │ │ │ ├── msp_q15_to_iq31.obj │ │ │ ├── msp_sinusoid_q15.d │ │ │ ├── msp_sinusoid_q15.obj │ │ │ ├── subdir_rules.mk │ │ │ └── subdir_vars.mk │ │ │ └── vector │ │ │ ├── msp_abs_iq31.d │ │ │ ├── msp_abs_iq31.obj │ │ │ ├── msp_abs_q15.d │ │ │ ├── msp_abs_q15.obj │ │ │ ├── msp_add_iq31.d │ │ │ ├── msp_add_iq31.obj │ │ │ ├── msp_add_q15.d │ │ │ ├── msp_add_q15.obj │ │ │ ├── msp_cmplx_add_iq31.d │ │ │ ├── msp_cmplx_add_iq31.obj │ │ │ ├── msp_cmplx_add_q15.d │ │ │ ├── msp_cmplx_add_q15.obj │ │ │ ├── msp_cmplx_conj_iq31.d │ │ │ ├── msp_cmplx_conj_iq31.obj │ │ │ ├── msp_cmplx_conj_q15.d │ │ │ ├── msp_cmplx_conj_q15.obj │ │ │ ├── msp_cmplx_mac_iq31.d │ │ │ ├── msp_cmplx_mac_iq31.obj │ │ │ ├── msp_cmplx_mac_q15.d │ │ │ ├── msp_cmplx_mac_q15.obj │ │ │ ├── msp_cmplx_mpy_iq31.d │ │ │ ├── msp_cmplx_mpy_iq31.obj │ │ │ ├── msp_cmplx_mpy_q15.d │ │ │ ├── msp_cmplx_mpy_q15.obj │ │ │ ├── msp_cmplx_mpy_real_iq31.d │ │ │ ├── msp_cmplx_mpy_real_iq31.obj │ │ │ ├── msp_cmplx_mpy_real_q15.d │ │ │ ├── msp_cmplx_mpy_real_q15.obj │ │ │ ├── msp_cmplx_scale_iq31.d │ │ │ ├── msp_cmplx_scale_iq31.obj │ │ │ ├── msp_cmplx_scale_q15.d │ │ │ ├── msp_cmplx_scale_q15.obj │ │ │ ├── msp_cmplx_shift_iq31.d │ │ │ ├── msp_cmplx_shift_iq31.obj │ │ │ ├── msp_cmplx_shift_q15.d │ │ │ ├── msp_cmplx_shift_q15.obj │ │ │ ├── msp_cmplx_sub_iq31.d │ │ │ ├── msp_cmplx_sub_iq31.obj │ │ │ ├── msp_cmplx_sub_q15.d │ │ │ ├── msp_cmplx_sub_q15.obj │ │ │ ├── msp_mac_iq31.d │ │ │ ├── msp_mac_iq31.obj │ │ │ ├── msp_mac_q15.d │ │ │ ├── msp_mac_q15.obj │ │ │ ├── msp_max_iq31.d │ │ │ ├── msp_max_iq31.obj │ │ │ ├── msp_max_q15.d │ │ │ ├── msp_max_q15.obj │ │ │ ├── msp_max_uq15.d │ │ │ ├── msp_max_uq15.obj │ │ │ ├── msp_max_uq31.d │ │ │ ├── msp_max_uq31.obj │ │ │ ├── msp_min_iq31.d │ │ │ ├── msp_min_iq31.obj │ │ │ ├── msp_min_q15.d │ │ │ ├── msp_min_q15.obj │ │ │ ├── msp_min_uq15.d │ │ │ ├── msp_min_uq15.obj │ │ │ ├── msp_min_uq31.d │ │ │ ├── msp_min_uq31.obj │ │ │ ├── msp_mpy_iq31.d │ │ │ ├── msp_mpy_iq31.obj │ │ │ ├── msp_mpy_q15.d │ │ │ ├── msp_mpy_q15.obj │ │ │ ├── msp_neg_iq31.d │ │ │ ├── msp_neg_iq31.obj │ │ │ ├── msp_neg_q15.d │ │ │ ├── msp_neg_q15.obj │ │ │ ├── msp_offset_iq31.d │ │ │ ├── msp_offset_iq31.obj │ │ │ ├── msp_offset_q15.d │ │ │ ├── msp_offset_q15.obj │ │ │ ├── msp_scale_iq31.d │ │ │ ├── msp_scale_iq31.obj │ │ │ ├── msp_scale_q15.d │ │ │ ├── msp_scale_q15.obj │ │ │ ├── msp_shift_iq31.d │ │ │ ├── msp_shift_iq31.obj │ │ │ ├── msp_shift_q15.d │ │ │ ├── msp_shift_q15.obj │ │ │ ├── msp_sub_iq31.d │ │ │ ├── msp_sub_iq31.obj │ │ │ ├── msp_sub_q15.d │ │ │ ├── msp_sub_q15.obj │ │ │ ├── subdir_rules.mk │ │ │ └── subdir_vars.mk │ ├── ccsObjs.opt │ ├── decoder │ │ ├── decoder.d │ │ ├── decoder.obj │ │ ├── subdir_rules.mk │ │ └── subdir_vars.mk │ ├── init.d │ ├── init.obj │ ├── layers │ │ ├── layers.d │ │ ├── layers.obj │ │ ├── subdir_rules.mk │ │ └── subdir_vars.mk │ ├── main.d │ ├── main.obj │ ├── makefile │ ├── math │ │ ├── fixed_point_ops.d │ │ ├── fixed_point_ops.obj │ │ ├── matrix_ops.d │ │ ├── matrix_ops.obj │ │ ├── subdir_rules.mk │ │ └── subdir_vars.mk │ ├── objects.mk │ ├── sources.mk │ ├── subdir_rules.mk │ └── subdir_vars.mk ├── decoder │ ├── decoder.c │ └── decoder.h ├── init.c ├── init.h ├── layers │ ├── layers.c │ └── layers.h ├── lnk_msp430fr5994.cmd ├── main.c ├── main.h ├── math │ ├── fixed_point_ops.c │ ├── fixed_point_ops.h │ ├── matrix.h │ ├── matrix_ops.c │ └── matrix_ops.h ├── neural_network_parameters.h ├── targetConfigs │ ├── MSP430FR5994.ccxml │ └── readme.txt └── utils │ └── utils.h ├── encoder.py └── examples ├── CIFAR_10_uDNN_Capuchin.ipynb └── MNIST_uDNN_Capuchin.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # Capuchin: A Neural Network Model Generator for 16-bit Microcontrollers 2 | ## About This 3 | This repository stores Capuchin, a Neural Network model generator for implementing pre-trained models on TI MSP430FR5994 microcontrollers. 4 | 5 | This project is made into two parts: a Python interface `encoder.py` and the microcontroller C implementation `capuchin-MCU`. The Python interface is built with a function that takes `tensorflow.keras.Model` objects as the argument to extract uDNN model configuration and generates a compiled header file `neural_network_parameters.h` that can be used to compile along with the microcontroller C implementation. The microcontroller C implementation extracts the model configuration array in the header file `neural_network_parameters.h`, builds a uDNN model on MSP430FR5994 by calling a sequence of uDNN layer implemetations, and feeds the sample dataset input into the uDNN model to compute the inference output. 6 | 7 | ## Getting Started 8 | ### Dependencies 9 | Disclaim: the following dependencies are only author's recommended setup. This project was tested under the following dependencies and verified as correct. This project may work under other versions of dependencies but the correctness may not be guaranteed. 10 | 11 | + tensorflow=2.6.0 12 | + keras=2.6.0 13 | + fxpmath=0.4.0 14 | + numpy=1.19.5 15 | + TI Code Composer Studio (recommended to debug as this project only simulates input and output rather than connecting to actual sensors) 16 | ### Installation 17 | `git clone https://github.com/leleonardzhang/Capuchin.git` 18 | ### Executing the Program 19 | #### Using Python Interface 20 | 1. Copy `encoder.py` into the same directory of your Python uDNN implementation program. 21 | 22 | `cp Capuchin/encoder.py {UDNN_PYTHON_IMPL_DIR}` 23 | 2. Import encoder package into your Python uDNN implementation program. 24 | 25 | `import encoder` 26 | 3. Call `encoder.export_model(MODEL_OBJECT)` in your program where the argument`MODEL_OBJECT` should be a trained `tensorflow.keras.Model` object. 27 | 4. Now a header file named `neural_network_parameters.h` should be written in the same directory. 28 | #### Using C Implementation 29 | 1. Copy the header file `neural_network_parameters.h` into directory `Capuchin/capuchin-MCU`. 30 | 31 | `cp {UDNN_PYTHON_IMPL_DIR}/neural_network_parameters.h {CAPUCHIN_PROJECT_DIR}/Capuchin/capuchin-MCU` 32 | 2. Open `{CAPUCHIN_PROJECT_DIR}/Capuchin/capuchin-MCU` as a TI CCS project. 33 | 3. Copy desired input into `input_buffer` array in `/neural_network_parameters.h`. 34 | 4. Compile and Run the inference on MSP430. 35 | 36 | ## Supports 37 | ### Python Interface 38 | For the reason that tensorflow is a complex framework for deep learning, the functionality of automation implementation on MSP430 is not comprehensive. Only frequent-used layers and functions in DNNs and CNNs are now supported. The following implementations are supported and verified as correct: 39 | #### Tensorflow Models 40 | + Sequential 41 | #### Tensorflow Layers (Parameters) 42 | + Dense (activation) 43 | + Conv2d (filters, channels, activation, strides, padding=`'valid' | 'same'`) 44 | + Maxpooling2d (pool_size) 45 | + Flatten 46 | + Dropout 47 | + LeakyReLU 48 | #### Tensorflow Activation Functions 49 | + linear 50 | + ReLU 51 | + LeakyReLU 52 | + tanh 53 | + sigmoid 54 | ### C Implementation 55 | Due to the hardware constraints of MSP430, the C implementation should meet the following known requirements: 56 | + `LENGTH_OF_INPUT + NUMBER_OF_PARAMETERS_IN_MODEL <= 68K` (FRAM persistent memory constraint) 57 | + `LEA_RAM_SIZE <= 1.8K` (LEA SRAM volatile memory constraint) 58 | + `LENGTH_OF_ANY_LAYER_OUTPUT <= 16384` (FRAM persistent memory constraint) 59 | ## Examples 60 | [MNIST](examples/MNIST_uDNN_Capuchin.ipynb) 61 | [CIFAR-10](examples/CIFAR_10_uDNN_Capuchin.ipynb) 62 | ## Contact 63 | Le Zhang - Email: lezhang at unc.edu 64 | 65 | Project Link: https://github.com/leleonardzhang/Capuchin 66 | 67 | ## Acknowledgement 68 | This project is built on the framework of budget-RNN. 69 | 70 | T. Kannan and H. Hoffmann, "Budget RNNs: Multi-Capacity Neural Networks to Improve In-Sensor Inference Under Energy Budgets," 2021 IEEE 27th Real-Time and Embedded Technology and Applications Symposium (RTAS), 2021, pp. 143-156, doi: 10.1109/RTAS52030.2021.00020. 71 | -------------------------------------------------------------------------------- /capuchin-MCU/.ccsproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /capuchin-MCU/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Capuchin-MCU 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 15 | full,incremental, 16 | 17 | 18 | 19 | 20 | 21 | com.ti.ccstudio.core.ccsNature 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /capuchin-MCU/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | inEditor=false 3 | onBuild=false 4 | -------------------------------------------------------------------------------- /capuchin-MCU/.settings/org.eclipse.cdt.debug.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker 3 | -------------------------------------------------------------------------------- /capuchin-MCU/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//Debug/DSPLib/source/filter/subdir_rules.mk=UTF-8 3 | encoding//Debug/DSPLib/source/filter/subdir_vars.mk=UTF-8 4 | encoding//Debug/DSPLib/source/lea/subdir_rules.mk=UTF-8 5 | encoding//Debug/DSPLib/source/lea/subdir_vars.mk=UTF-8 6 | encoding//Debug/DSPLib/source/matrix/subdir_rules.mk=UTF-8 7 | encoding//Debug/DSPLib/source/matrix/subdir_vars.mk=UTF-8 8 | encoding//Debug/DSPLib/source/transform/subdir_rules.mk=UTF-8 9 | encoding//Debug/DSPLib/source/transform/subdir_vars.mk=UTF-8 10 | encoding//Debug/DSPLib/source/utility/subdir_rules.mk=UTF-8 11 | encoding//Debug/DSPLib/source/utility/subdir_vars.mk=UTF-8 12 | encoding//Debug/DSPLib/source/vector/subdir_rules.mk=UTF-8 13 | encoding//Debug/DSPLib/source/vector/subdir_vars.mk=UTF-8 14 | encoding//Debug/decoder/subdir_rules.mk=UTF-8 15 | encoding//Debug/decoder/subdir_vars.mk=UTF-8 16 | encoding//Debug/layers/subdir_rules.mk=UTF-8 17 | encoding//Debug/layers/subdir_vars.mk=UTF-8 18 | encoding//Debug/makefile=UTF-8 19 | encoding//Debug/math/subdir_rules.mk=UTF-8 20 | encoding//Debug/math/subdir_vars.mk=UTF-8 21 | encoding//Debug/objects.mk=UTF-8 22 | encoding//Debug/sources.mk=UTF-8 23 | encoding//Debug/subdir_rules.mk=UTF-8 24 | encoding//Debug/subdir_vars.mk=UTF-8 25 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/include/DSPLib.h: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | #ifndef __DSPLIB_H__ 33 | #define __DSPLIB_H__ 34 | 35 | #include "msp430.h" 36 | 37 | #include 38 | #include 39 | 40 | #include "DSPLib_types.h" // Include DSPLib type definitions 41 | #include "DSPLib_lea.h" // Include DSPLib LEA definitions 42 | #include "DSPLib_support.h" // Include DSPLib support functions 43 | #include "DSPLib_vector.h" // Include DSPLib vector functions 44 | #include "DSPLib_matrix.h" // Include DSPLib matrix functions 45 | #include "DSPLib_filter.h" // Include DSPLib filter functions 46 | #include "DSPLib_transform.h" // Include DSPLib transform functions 47 | #include "DSPLib_utility.h" // Include DSPLib utility functions 48 | 49 | #endif //__DSPLIB_H__ 50 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/filter/msp_biquad_cascade_df1_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_biquad_cascade_df1_q15(const msp_biquad_cascade_df1_q15_params *params, const _q15 *src, _q15 *dst) 36 | { 37 | uint16_t i; 38 | uint16_t stages; 39 | const _q15 *srcPtr; 40 | msp_status status; 41 | msp_biquad_df1_q15_params df1Params; 42 | 43 | /* Load the number of stages from the parameters. */ 44 | stages = params->stages; 45 | 46 | /* Set initial source pointer. */ 47 | srcPtr = src; 48 | 49 | /* Run the input through all stages of the cascaded biquad. */ 50 | for (i = 0; i < stages; i++) { 51 | /* Initialize the DF1 biquad parameter structure. */ 52 | df1Params.length = params->length; 53 | df1Params.coeffs = ¶ms->coeffs[i]; 54 | df1Params.states = ¶ms->states[i]; 55 | 56 | /* Invoke the msp_biquad_df1_q15 function and check status flag. */ 57 | status = msp_biquad_df1_q15(&df1Params, srcPtr, dst); 58 | if (status != MSP_SUCCESS) { 59 | /* Something went wrong, return the status of the operation. */ 60 | return status; 61 | } 62 | 63 | /* Set source pointer to destination for next stage. */ 64 | srcPtr = dst; 65 | } 66 | 67 | /* Return the status of the operation. */ 68 | return status; 69 | } 70 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/filter/msp_biquad_cascade_df2_ext_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_biquad_cascade_df2_ext_q15(const msp_biquad_cascade_df2_ext_q15_params *params, const _q15 *src, _q15 *dst) 36 | { 37 | uint16_t i; 38 | uint16_t stages; 39 | const _q15 *srcPtr; 40 | msp_status status; 41 | msp_biquad_df2_ext_q15_params df2ExtParams; 42 | 43 | /* Load the number of stages from the parameters. */ 44 | stages = params->stages; 45 | 46 | /* Set initial source pointer. */ 47 | srcPtr = src; 48 | 49 | /* Run the input through all stages of the cascaded biquad. */ 50 | for (i = 0; i < stages; i++) { 51 | /* Initialize the DF2 biquad parameter structure. */ 52 | df2ExtParams.length = params->length; 53 | df2ExtParams.coeffs = ¶ms->coeffs[i]; 54 | df2ExtParams.states = ¶ms->states[i]; 55 | 56 | /* Invoke the msp_biquad_df2_ext_q15 function and check status flag. */ 57 | status = msp_biquad_df2_ext_q15(&df2ExtParams, srcPtr, dst); 58 | if (status != MSP_SUCCESS) { 59 | /* Something went wrong, return the status of the operation. */ 60 | return status; 61 | } 62 | 63 | /* Set source pointer to destination for next stage. */ 64 | srcPtr = dst; 65 | } 66 | 67 | /* Return the status of the operation. */ 68 | return status; 69 | } 70 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/filter/msp_biquad_cascade_df2_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_biquad_cascade_df2_q15(const msp_biquad_cascade_df2_q15_params *params, const _q15 *src, _q15 *dst) 36 | { 37 | uint16_t i; 38 | uint16_t stages; 39 | const _q15 *srcPtr; 40 | msp_status status; 41 | msp_biquad_df2_q15_params df2Params; 42 | 43 | /* Load the number of stages from the parameters. */ 44 | stages = params->stages; 45 | 46 | /* Set initial source pointer. */ 47 | srcPtr = src; 48 | 49 | /* Run the input through all stages of the cascaded biquad. */ 50 | for (i = 0; i < stages; i++) { 51 | /* Initialize the DF2 biquad parameter structure. */ 52 | df2Params.length = params->length; 53 | df2Params.coeffs = ¶ms->coeffs[i]; 54 | df2Params.states = ¶ms->states[i]; 55 | 56 | /* Invoke the msp_biquad_df2_q15 function and check status flag. */ 57 | status = msp_biquad_df2_q15(&df2Params, srcPtr, dst); 58 | if (status != MSP_SUCCESS) { 59 | /* Something went wrong, return the status of the operation. */ 60 | return status; 61 | } 62 | 63 | /* Set source pointer to destination for next stage. */ 64 | srcPtr = dst; 65 | } 66 | 67 | /* Return the status of the operation. */ 68 | return status; 69 | } 70 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/lea/msp_lea_flags.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | #if defined(MSP_USE_LEA) 36 | 37 | volatile uint16_t msp_lea_locked; 38 | 39 | volatile uint16_t msp_lea_ifg; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/lea/msp_lea_init.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | #if defined(MSP_USE_LEA) 36 | 37 | #if defined(MSP_DISABLE_LPM0) 38 | #warning "DSPLib: LPM0 is disabled, undefine MSP_DISABLE_LPM0 to enable LPM0. 39 | #elif ((MSP_LEA_REVISION==MSP_LEA_REVISION_A) && !defined(MSP_ENABLE_LPM0)) 40 | #warning "DSPLib: Building for revision A of LEA, LPM0 is disabled to work \ 41 | around LEA1 errata. See the LEA chapter of API User's Guide and device errata \ 42 | sheet for more details." 43 | #endif 44 | 45 | void msp_lea_init(void) 46 | { 47 | /* Initialize DSPLib ISR flags. */ 48 | msp_lea_ifg = 0; 49 | 50 | /* Initialize LEA registers. */ 51 | LEACNF0 = LEALPR | LEAILPM; 52 | LEACNF1 = 0; 53 | LEACNF2 = LEAMT >> 2; 54 | LEAPMS1 = 0; 55 | LEAPMS0 = 0; 56 | LEAPMDST = 0; 57 | LEAPMCTL |= LEACMDEN; 58 | LEAIE |= LEAPMCMDIE; 59 | LEACMCTL = 0; 60 | 61 | #if (MSP_LEA_REVISION == MSP_LEA_REVISION_A) 62 | msp_lea_initCommandTable(); 63 | #endif 64 | 65 | return; 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/lea/msp_lea_isr.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | #if defined(MSP_USE_LEA) 36 | 37 | #if defined(__TI_COMPILER_VERSION__) || (__IAR_SYSTEMS_ICC__) 38 | #pragma vector=LEA_VECTOR 39 | __interrupt void msp_lea_isr(void) 40 | #elif defined(__GNUC__) && (__MSP430__) 41 | void __attribute__ ((interrupt(LEA_VECTOR))) msp_lea_isr(void) 42 | #endif 43 | { 44 | /* Save the interrupt flags, clear interrupt and exit LPM0. */ 45 | uint16_t flags = LEAIFG; 46 | LEAIFG |= flags; 47 | msp_lea_ifg = flags; 48 | __bic_SR_register_on_exit(LPM0_bits); 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_abs_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix absolute value of a source matrix. 37 | */ 38 | msp_status msp_matrix_abs_iq31(const msp_matrix_abs_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | msp_abs_iq31_params paramsTemp; 41 | 42 | /* Use real vector absolute value function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_abs_iq31(¶msTemp, src, dst); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_abs_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix absolute value of a source matrix. 37 | */ 38 | msp_status msp_matrix_abs_q15(const msp_matrix_abs_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | msp_abs_q15_params paramsTemp; 41 | 42 | /* Use real vector absolute value function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_abs_q15(¶msTemp, src, dst); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_add_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix addition of two source matrices. 37 | */ 38 | msp_status msp_matrix_add_iq31(const msp_matrix_add_iq31_params *params, const _iq31 *srcA, const _iq31 *srcB, _iq31 *dst) 39 | { 40 | msp_add_iq31_params paramsTemp; 41 | 42 | /* Use real vector addition function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_add_iq31(¶msTemp, srcA, srcB, dst); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_add_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix addition of two source matrices. 37 | */ 38 | msp_status msp_matrix_add_q15(const msp_matrix_add_q15_params *params, const int16_t *srcA, const int16_t *srcB, int16_t *dst) 39 | { 40 | msp_add_q15_params paramsTemp; 41 | 42 | /* Use real vector addition function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_add_q15(¶msTemp, srcA, srcB, dst); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_neg_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise multiplication of a single source vector with negative one. 37 | */ 38 | msp_status msp_matrix_neg_iq31(const msp_matrix_neg_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | msp_neg_iq31_params paramsTemp; 41 | 42 | /* Use real vector negate function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_neg_iq31(¶msTemp, src, dst); 46 | } 47 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_neg_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise multiplication of a single source vector with negative one. 37 | */ 38 | msp_status msp_matrix_neg_q15(const msp_matrix_neg_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | msp_neg_q15_params paramsTemp; 41 | 42 | /* Use real vector negate function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_neg_q15(¶msTemp, src, dst); 46 | } 47 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_offset_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix offset of a source matrix. 37 | */ 38 | msp_status msp_matrix_offset_iq31(const msp_matrix_offset_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | msp_offset_iq31_params paramsTemp; 41 | 42 | /* Use real vector offset function. */ 43 | paramsTemp.offset = params->offset; 44 | paramsTemp.length = params->rows * params->cols; 45 | 46 | return msp_offset_iq31(¶msTemp, src, dst); 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_offset_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix offset of a source matrix. 37 | */ 38 | msp_status msp_matrix_offset_q15(const msp_matrix_offset_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | msp_offset_q15_params paramsTemp; 41 | 42 | /* Use real vector offset function. */ 43 | paramsTemp.offset = params->offset; 44 | paramsTemp.length = params->rows * params->cols; 45 | 46 | return msp_offset_q15(¶msTemp, src, dst); 47 | 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_scale_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise iq31 multiply and left shift 37 | */ 38 | msp_status msp_matrix_scale_iq31(const msp_matrix_scale_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | msp_scale_iq31_params paramsTemp; 41 | 42 | /* Use real vector scale function. */ 43 | paramsTemp.shift = params->shift; 44 | paramsTemp.length = params->rows * params->cols; 45 | paramsTemp.scale = params->scale; 46 | 47 | return msp_scale_iq31(¶msTemp, src, dst); 48 | } 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_scale_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix bitwise shift and q15 multiply of a source matrix. 37 | */ 38 | msp_status msp_matrix_scale_q15(const msp_matrix_scale_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | msp_scale_q15_params paramsTemp; 41 | 42 | /* Use real vector scale function. */ 43 | paramsTemp.scale = params->scale; 44 | paramsTemp.shift = params->shift; 45 | paramsTemp.length = params->rows * params->cols; 46 | 47 | return msp_scale_q15(¶msTemp, src, dst); 48 | 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_shift_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise left or right shift of a single source matrix. 37 | */ 38 | msp_status msp_matrix_shift_iq31(const msp_matrix_shift_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | msp_shift_iq31_params paramsTemp; 41 | 42 | /* Use real vector shift function. */ 43 | paramsTemp.shift = params->shift; 44 | paramsTemp.length = params->rows * params->cols; 45 | 46 | return msp_shift_iq31(¶msTemp, src, dst); 47 | } 48 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_shift_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise left or right shift of a single source matrix. 37 | */ 38 | msp_status msp_matrix_shift_q15(const msp_matrix_shift_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | msp_shift_q15_params paramsTemp; 41 | 42 | /* Use real vector shift function. */ 43 | paramsTemp.shift = params->shift; 44 | paramsTemp.length = params->rows * params->cols; 45 | 46 | return msp_shift_q15(¶msTemp, src, dst); 47 | } 48 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_sub_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix subtraction of two source matrices. 37 | */ 38 | msp_status msp_matrix_sub_iq31(const msp_matrix_sub_iq31_params *params, const _iq31 *srcA, const _iq31 *srcB, _iq31 *dst) 39 | { 40 | msp_sub_iq31_params paramsTemp; 41 | 42 | /* Use real vector subtraction function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_sub_iq31(¶msTemp, srcA, srcB, dst); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_sub_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix subtraction of two source matrices. 37 | */ 38 | msp_status msp_matrix_sub_q15(const msp_matrix_sub_q15_params *params, const int16_t *srcA, const int16_t *srcB, int16_t *dst) 39 | { 40 | msp_sub_q15_params paramsTemp; 41 | 42 | /* Use real vector subtraction function. */ 43 | paramsTemp.length = params->rows * params->cols; 44 | 45 | return msp_sub_q15(¶msTemp, srcA, srcB, dst); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_trans_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix transposition of a source matrix. 37 | */ 38 | msp_status msp_matrix_trans_iq31(const msp_matrix_trans_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | uint16_t i; 41 | uint16_t rows; 42 | uint16_t cols; 43 | msp_status status; 44 | msp_deinterleave_iq31_params deinterParams; 45 | 46 | /* Extract matrix parameters. */ 47 | rows = params->rows; 48 | cols = params->cols; 49 | 50 | /* Initialize deinterleave parameters. */ 51 | deinterParams.length = rows; 52 | deinterParams.numChannels = cols; 53 | 54 | /* Iterate through source columns and deinterleave to destination. */ 55 | for (i = 0; i < cols; i++) { 56 | /* Transpose source columns to destination rows using deinterleave. */ 57 | deinterParams.channel = i; 58 | status = msp_deinterleave_iq31(&deinterParams, src, &dst[i*rows]); 59 | if (status != MSP_SUCCESS) { 60 | return status; 61 | } 62 | } 63 | 64 | return MSP_SUCCESS; 65 | } 66 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/matrix/msp_matrix_trans_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform matrix transposition of a source matrix. 37 | */ 38 | msp_status msp_matrix_trans_q15(const msp_matrix_trans_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | uint16_t i; 41 | uint16_t rows; 42 | uint16_t cols; 43 | msp_status status; 44 | msp_deinterleave_q15_params deinterParams; 45 | 46 | /* Extract matrix parameters. */ 47 | rows = params->rows; 48 | cols = params->cols; 49 | 50 | #ifndef MSP_DISABLE_DIAGNOSTICS 51 | /* Check that row and column sizes are even. */ 52 | if ((rows & 1) || (cols & 1)) { 53 | return MSP_SIZE_ERROR; 54 | } 55 | #endif //MSP_DISABLE_DIAGNOSTICS 56 | 57 | /* Initialize deinterleave parameters. */ 58 | deinterParams.length = rows; 59 | deinterParams.numChannels = cols; 60 | 61 | /* Iterate through source columns and deinterleave to destination. */ 62 | for (i = 0; i < cols; i++) { 63 | /* Transpose source columns to destination rows using deinterleave. */ 64 | deinterParams.channel = i; 65 | status = msp_deinterleave_q15(&deinterParams, src, &dst[i*rows]); 66 | if (status != MSP_SUCCESS) { 67 | return status; 68 | } 69 | } 70 | 71 | return MSP_SUCCESS; 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_cmplx_ifft_auto_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place complex inverse DFT of the input signal using complex 37 | * conjugate, the complex DFT and complex scaling. Auto scaling is performed 38 | * such that this is the direct inverse of the forward FFT with auto scaling. 39 | */ 40 | msp_status msp_cmplx_ifft_auto_q15(const msp_cmplx_fft_q15_params *params, int16_t *src, uint16_t shift) 41 | { 42 | uint16_t length; // src length 43 | uint16_t resultShift; // complex fft result shift 44 | msp_status status; // Status of the operations 45 | msp_cmplx_conj_q15_params conjParams; // Complex conjugate params 46 | msp_cmplx_fft_q15_params paramsCmplxFFT; // Complex FFT params 47 | msp_cmplx_shift_q15_params paramsShift; // Complex shift params 48 | 49 | /* Initialize complex conjugate params structure. */ 50 | conjParams.length = params->length; 51 | 52 | /* Take the complex conjugate of the input. */ 53 | status = msp_cmplx_conj_q15(&conjParams, src, src); 54 | if (status != MSP_SUCCESS) { 55 | return status; 56 | } 57 | 58 | /* Initialize complex FFT params structure. */ 59 | paramsCmplxFFT.length = params->length; 60 | paramsCmplxFFT.bitReverse = params->bitReverse; 61 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 62 | 63 | /* Perform complex FFT on real source with scaling. */ 64 | status = msp_cmplx_fft_auto_q15(¶msCmplxFFT, src, &resultShift); 65 | if (status != MSP_SUCCESS) { 66 | return status; 67 | } 68 | 69 | /* Calculate necessary shift to complete the operation. */ 70 | shift += resultShift; 71 | length = params->length; 72 | while (length > 1) { 73 | shift--; 74 | length >>= 1; 75 | } 76 | 77 | /* Initialize complex shift parameters with conjugate enabled. */ 78 | paramsShift.length = params->length; 79 | paramsShift.shift = (int8_t)shift; 80 | paramsShift.conjugate = true; 81 | return msp_cmplx_shift_q15(¶msShift, src, src); 82 | } 83 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_cmplx_ifft_fixed_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place complex inverse DFT of the input signal using complex 37 | * conjugate, the complex DFT and complex scaling. Fixed scaling is performed 38 | * such that this is the direct inverse of the forward FFT with fixed scaling. 39 | */ 40 | msp_status msp_cmplx_ifft_fixed_q15(const msp_cmplx_fft_q15_params *params, int16_t *src) 41 | { 42 | uint16_t resultShift; // complex fft result shift 43 | msp_status status; // Status of the operations 44 | msp_cmplx_conj_q15_params conjParams; // Complex conjugate params 45 | msp_cmplx_fft_q15_params paramsCmplxFFT; // Complex FFT params 46 | msp_cmplx_shift_q15_params paramsShift; // Complex shift params 47 | 48 | /* Initialize complex conjugate params structure. */ 49 | conjParams.length = params->length; 50 | 51 | /* Take the complex conjugate of the input. */ 52 | status = msp_cmplx_conj_q15(&conjParams, src, src); 53 | if (status != MSP_SUCCESS) { 54 | return status; 55 | } 56 | 57 | /* Initialize complex FFT params structure. */ 58 | paramsCmplxFFT.length = params->length; 59 | paramsCmplxFFT.bitReverse = params->bitReverse; 60 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 61 | 62 | /* Perform complex FFT on real source with scaling. */ 63 | status = msp_cmplx_fft_auto_q15(¶msCmplxFFT, src, &resultShift); 64 | if (status != MSP_SUCCESS) { 65 | return status; 66 | } 67 | 68 | /* Initialize complex shift parameters with conjugate enabled. */ 69 | paramsShift.length = params->length; 70 | paramsShift.shift = (int8_t)resultShift; 71 | paramsShift.conjugate = true; 72 | return msp_cmplx_shift_q15(¶msShift, src, src); 73 | } 74 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_fft_auto_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place real DFT of the real input signal using a complex DFT of 37 | * size N/2 and a split operation to obtain a complex output with length N/2. 38 | * No fixed scaling is performed. 39 | */ 40 | msp_status msp_fft_auto_q15(const msp_fft_q15_params *params, int16_t *src, uint16_t *shift) 41 | { 42 | msp_status status; // Status of the operations 43 | msp_split_q15_params paramsSplit; // Split operation params 44 | msp_cmplx_fft_q15_params paramsCmplxFFT; // Complex FFT params 45 | 46 | /* Initialize complex FFT params structure. */ 47 | paramsCmplxFFT.length = params->length >> 1; 48 | paramsCmplxFFT.bitReverse = params->bitReverse; 49 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 50 | 51 | /* Perform N/2 complex FFT on real source without scaling. */ 52 | status = msp_cmplx_fft_auto_q15(¶msCmplxFFT, src, shift); 53 | if (status != MSP_SUCCESS) { 54 | return status; 55 | } 56 | 57 | /* Initialize split operation params structure. */ 58 | paramsSplit.length = params->length; 59 | paramsSplit.twiddleTable = params->twiddleTable; 60 | 61 | /* Perform the last stage split operation to obtain N/2 complex FFT results. */ 62 | return msp_split_q15(¶msSplit, src); 63 | } 64 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_fft_fixed_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place real DFT of the real input signal using a complex DFT of 37 | * size N/2 and a split operation to obtain a complex output with length N/2. 38 | * Fixed scaling by 2 is performed at each stage. 39 | */ 40 | msp_status msp_fft_fixed_q15(const msp_fft_q15_params *params, int16_t *src) 41 | { 42 | msp_status status; // Status of the operations 43 | msp_split_q15_params paramsSplit; // Split operation params 44 | msp_cmplx_fft_q15_params paramsCmplxFFT; // Complex FFT params 45 | 46 | /* Initialize complex FFT params structure. */ 47 | paramsCmplxFFT.length = params->length >> 1; 48 | paramsCmplxFFT.bitReverse = params->bitReverse; 49 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 50 | 51 | /* Perform N/2 complex FFT on real source with scaling. */ 52 | status = msp_cmplx_fft_fixed_q15(¶msCmplxFFT, src); 53 | if (status != MSP_SUCCESS) { 54 | return status; 55 | } 56 | 57 | /* Initialize split operation params structure. */ 58 | paramsSplit.length = params->length; 59 | paramsSplit.twiddleTable = params->twiddleTable; 60 | 61 | /* Perform the last stage split operation to obtain N/2 complex FFT results. */ 62 | return msp_split_q15(¶msSplit, src); 63 | } 64 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_fft_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place real DFT of the real input signal using a complex DFT of 37 | * size N/2 and a split operation to obtain a complex output with length N/2. 38 | * Fixed scaling by 2 is performed at each stage. 39 | */ 40 | msp_status msp_fft_iq31(const msp_fft_iq31_params *params, int32_t *src) 41 | { 42 | msp_status status; // Status of the operations 43 | msp_split_iq31_params paramsSplit; // Split operation params 44 | msp_cmplx_fft_iq31_params paramsCmplxFFT; // Complex FFT params 45 | 46 | /* Initialize complex FFT params structure. */ 47 | paramsCmplxFFT.length = params->length >> 1; 48 | paramsCmplxFFT.bitReverse = params->bitReverse; 49 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 50 | 51 | /* Perform N/2 complex FFT on real source with scaling. */ 52 | status = msp_cmplx_fft_iq31(¶msCmplxFFT, src); 53 | if (status != MSP_SUCCESS) { 54 | return status; 55 | } 56 | 57 | /* Initialize split operation params structure. */ 58 | paramsSplit.length = params->length; 59 | paramsSplit.twiddleTable = params->twiddleTable; 60 | 61 | /* Perform the last stage split operation to obtain N/2 complex FFT results. */ 62 | return msp_split_iq31(¶msSplit, src); 63 | } 64 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_ifft_auto_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place real inverse DFT of the complex input signal using a 37 | * split operation and a complex DFT of size N/2 and to obtain a real output 38 | * with length N. Automatic scaling is performed such that this is the direct 39 | * inverse of the forward FFT with auto scaling. 40 | */ 41 | msp_status msp_ifft_auto_q15(const msp_fft_q15_params *params, int16_t *src, uint16_t shift) 42 | { 43 | uint16_t length; // src length 44 | uint16_t resultShift; // complex fft result shift 45 | msp_status status; // Status of the operations 46 | msp_split_q15_params paramsSplit; // Split operation params 47 | msp_cmplx_conj_q15_params conjParams; // Complex conjugate params 48 | msp_cmplx_fft_q15_params paramsCmplxFFT; // Complex FFT params 49 | msp_cmplx_shift_q15_params paramsShift; // Complex shift params 50 | 51 | /* Initialize complex conjugate params structure. */ 52 | conjParams.length = params->length/2; 53 | 54 | /* Take the complex conjugate of the input. */ 55 | status = msp_cmplx_conj_q15(&conjParams, src, src); 56 | if (status != MSP_SUCCESS) { 57 | return status; 58 | } 59 | 60 | /* Initialize split operation params structure. */ 61 | paramsSplit.length = params->length; 62 | paramsSplit.twiddleTable = params->twiddleTable; 63 | 64 | /* Perform the last stage split operation to obtain N/2 complex FFT results. */ 65 | status = msp_split_q15(¶msSplit, src); 66 | if (status != MSP_SUCCESS) { 67 | return status; 68 | } 69 | 70 | /* Initialize complex FFT params structure. */ 71 | paramsCmplxFFT.length = params->length >> 1; 72 | paramsCmplxFFT.bitReverse = params->bitReverse; 73 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 74 | 75 | /* Perform N/2 complex FFT on real source with scaling. */ 76 | status = msp_cmplx_fft_auto_q15(¶msCmplxFFT, src, &resultShift); 77 | if (status != MSP_SUCCESS) { 78 | return status; 79 | } 80 | 81 | /* Calculate necessary shift to complete the operation. */ 82 | shift += resultShift; 83 | length = params->length; 84 | while (length > 2) { 85 | shift--; 86 | length >>= 1; 87 | } 88 | 89 | /* Initialize complex shift parameters with conjugate enabled. */ 90 | paramsShift.length = params->length >> 1; 91 | paramsShift.shift = (int8_t)shift; 92 | paramsShift.conjugate = true; 93 | return msp_cmplx_shift_q15(¶msShift, src, src); 94 | } 95 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/transform/msp_ifft_fixed_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform an in-place real inverse DFT of the complex input signal using a 37 | * split operation and a complex DFT of size N/2 and to obtain a real output 38 | * with length N. Fixed scaling is performed such that this is the direct 39 | * inverse of the forward FFT with fixed scaling. 40 | */ 41 | msp_status msp_ifft_fixed_q15(const msp_fft_q15_params *params, int16_t *src) 42 | { 43 | uint16_t resultShift; // complex fft result shift 44 | msp_status status; // Status of the operations 45 | msp_split_q15_params paramsSplit; // Split operation params 46 | msp_cmplx_conj_q15_params conjParams; // Complex conjugate params 47 | msp_cmplx_fft_q15_params paramsCmplxFFT; // Complex FFT params 48 | msp_cmplx_shift_q15_params paramsShift; // Complex shift params 49 | 50 | /* Initialize complex conjugate params structure. */ 51 | conjParams.length = params->length/2; 52 | 53 | /* Take the complex conjugate of the input. */ 54 | status = msp_cmplx_conj_q15(&conjParams, src, src); 55 | if (status != MSP_SUCCESS) { 56 | return status; 57 | } 58 | 59 | /* Initialize split operation params structure. */ 60 | paramsSplit.length = params->length; 61 | paramsSplit.twiddleTable = params->twiddleTable; 62 | 63 | /* Perform the last stage split operation to obtain N/2 complex FFT results. */ 64 | status = msp_split_q15(¶msSplit, src); 65 | if (status != MSP_SUCCESS) { 66 | return status; 67 | } 68 | 69 | /* Initialize complex FFT params structure. */ 70 | paramsCmplxFFT.length = params->length >> 1; 71 | paramsCmplxFFT.bitReverse = params->bitReverse; 72 | paramsCmplxFFT.twiddleTable = params->twiddleTable; 73 | 74 | /* Perform N/2 complex FFT on real source with scaling. */ 75 | status = msp_cmplx_fft_auto_q15(¶msCmplxFFT, src, &resultShift); 76 | if (status != MSP_SUCCESS) { 77 | return status; 78 | } 79 | 80 | /* Initialize complex shift parameters with conjugate enabled. */ 81 | paramsShift.length = params->length >> 1; 82 | paramsShift.shift = (int8_t)resultShift; 83 | paramsShift.conjugate = true; 84 | return msp_cmplx_shift_q15(¶msShift, src, src); 85 | } 86 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/utility/msp_cmplx_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_cmplx_iq31(const msp_cmplx_iq31_params *params, const _iq31 *real, const _iq31 *imag, _iq31 *dst) 36 | { 37 | uint16_t length; 38 | msp_status status; 39 | msp_interleave_iq31_params interleaveParams; 40 | 41 | /* Initialize the vector length. */ 42 | length = params->length; 43 | 44 | /* Interleave IQ31 real to channel zero of the destination vector. */ 45 | interleaveParams.length = length; 46 | interleaveParams.numChannels = 2; 47 | interleaveParams.channel = 0; 48 | status = msp_interleave_iq31(&interleaveParams, real, dst); 49 | 50 | /* Interleave IQ31 imaginary to channel one of the destination vector. */ 51 | interleaveParams.length = length; 52 | interleaveParams.numChannels = 2; 53 | interleaveParams.channel = 1; 54 | status = msp_interleave_iq31(&interleaveParams, imag, dst); 55 | 56 | return status; 57 | } 58 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/utility/msp_cmplx_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_cmplx_q15(const msp_cmplx_q15_params *params, const _q15 *real, const _q15 *imag, _q15 *dst) 36 | { 37 | uint16_t length; 38 | msp_status status; 39 | msp_interleave_q15_params interleaveParams; 40 | 41 | /* Initialize the vector length. */ 42 | length = params->length; 43 | 44 | /* Interleave Q15 real to channel zero of the destination vector. */ 45 | interleaveParams.length = length; 46 | interleaveParams.numChannels = 2; 47 | interleaveParams.channel = 0; 48 | status = msp_interleave_q15(&interleaveParams, real, dst); 49 | 50 | /* Interleave Q15 imaginary to channel one of the destination vector. */ 51 | interleaveParams.length = length; 52 | interleaveParams.numChannels = 2; 53 | interleaveParams.channel = 1; 54 | status = msp_interleave_q15(&interleaveParams, imag, dst); 55 | 56 | return status; 57 | } 58 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/utility/msp_iq31_to_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_iq31_to_q15(const msp_iq31_to_q15_params *params, const _iq31 *src, _q15 *dst) 36 | { 37 | uint16_t length; 38 | msp_status status; 39 | msp_deinterleave_q15_params deinterleaveParams; 40 | 41 | /* Initialize the vector length. */ 42 | length = params->length; 43 | 44 | /* Extract upper 16-bits of IQ31 source to Q15 destination. */ 45 | deinterleaveParams.length = length; 46 | deinterleaveParams.numChannels = 2; 47 | deinterleaveParams.channel = 1; 48 | status = msp_deinterleave_q15(&deinterleaveParams, (const _q15 *)src, dst); 49 | 50 | return status; 51 | } 52 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/utility/msp_q15_to_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_q15_to_iq31(const msp_q15_to_iq31_params *params, const _q15 *src, _iq31 *dst) 36 | { 37 | uint16_t length; 38 | msp_status status; 39 | msp_fill_iq31_params fillParams; 40 | msp_interleave_q15_params interleaveParams; 41 | 42 | /* Initialize the vector length. */ 43 | length = params->length; 44 | 45 | /* Fill destination with zeros. */ 46 | fillParams.length = length; 47 | fillParams.value = 0; 48 | status = msp_fill_iq31(&fillParams, dst); 49 | if (status != MSP_SUCCESS) { 50 | return status; 51 | } 52 | 53 | /* Interleave Q15 source to upper 16-bits of IQ31 destination. */ 54 | interleaveParams.length = length; 55 | interleaveParams.numChannels = 2; 56 | interleaveParams.channel = 1; 57 | status = msp_interleave_q15(&interleaveParams, src, (_q15 *)dst); 58 | 59 | return status; 60 | } 61 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/utility/msp_sinusoid_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | msp_status msp_sinusoid_q15(const msp_sinusoid_q15_params *params, _q15 *dst) 36 | { 37 | msp_status status; 38 | msp_biquad_df1_q15_params df1Params; 39 | 40 | #if defined(MSP_USE_LEA) 41 | /* Initialize LEA if it is not enabled. */ 42 | if (!(LEAPMCTL & LEACMDEN)) { 43 | msp_lea_init(); 44 | } 45 | 46 | /* Allocate coefficients in LEA memory and set parameters */ 47 | df1Params.length = params->length; 48 | df1Params.coeffs = (msp_biquad_df1_q15_coeffs *)msp_lea_allocMemory(sizeof(msp_biquad_df1_q15_coeffs)/sizeof(uint32_t)); 49 | df1Params.states = (msp_biquad_df1_q15_states *)msp_lea_allocMemory(sizeof(msp_biquad_df1_q15_coeffs)/sizeof(uint32_t)); 50 | #else //MSP_USE_LEA 51 | /* Allocate coefficients on stack */ 52 | msp_biquad_df1_q15_coeffs coeffs; 53 | msp_biquad_df1_q15_states states; 54 | 55 | /* Set parameters */ 56 | df1Params.coeffs = &coeffs; 57 | df1Params.states = &states; 58 | df1Params.length = params->length; 59 | #endif //MSP_USE_LEA 60 | 61 | #if defined(__MSP430_HAS_MPY32__) 62 | /* If MPY32 is available save control context and set to fractional mode. */ 63 | uint16_t ui16MPYState = MPY32CTL0; 64 | MPY32CTL0 = MPYFRAC | MPYDLYWRTEN; 65 | #endif //__MSP430_HAS_MPY32__ 66 | 67 | /* Initialize coefficients */ 68 | ((msp_biquad_df1_q15_coeffs *)df1Params.coeffs)->a1By2 = params->cosOmega; 69 | ((msp_biquad_df1_q15_coeffs *)df1Params.coeffs)->a2 = _Q15(-1.0); 70 | ((msp_biquad_df1_q15_coeffs *)df1Params.coeffs)->b0 = _Q15(0.0); 71 | ((msp_biquad_df1_q15_coeffs *)df1Params.coeffs)->b1By2 = _Q15(0.0); 72 | ((msp_biquad_df1_q15_coeffs *)df1Params.coeffs)->b2 = _Q15(0.0); 73 | 74 | /* Initialize states */ 75 | df1Params.states->x1 = _Q15(0.0); 76 | df1Params.states->x2 = _Q15(0.0); 77 | df1Params.states->y1 = -__q15mpy(params->amplitude, params->sinOmega); 78 | df1Params.states->y2 = __q15mpy(df1Params.states->y1, params->cosOmega) << 1; 79 | 80 | #if defined(__MSP430_HAS_MPY32__) 81 | /* Restore MPY32 control context. */ 82 | MPY32CTL0 = ui16MPYState; 83 | #endif //__MSP430_HAS_MPY32__ 84 | 85 | /* Call DF1 biquad to generate sinusoid */ 86 | status = msp_biquad_df1_q15(&df1Params, dst, dst); 87 | 88 | #if defined(MSP_USE_LEA) 89 | /* Free coefficients and states from LEA memory */ 90 | msp_lea_freeMemory(sizeof(msp_biquad_df1_q15_coeffs)/sizeof(uint32_t)); 91 | msp_lea_freeMemory(sizeof(msp_biquad_df1_q15_states)/sizeof(uint32_t)); 92 | #endif //MSP_USE_LEA 93 | 94 | return status; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_abs_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise absolute value of a single source vector. 37 | */ 38 | msp_status msp_abs_iq31(const msp_abs_iq31_params *params, const _iq31 *src, _iq31 *dst) 39 | { 40 | uint16_t length; 41 | 42 | /* Initialize the loop counter with the vector length. */ 43 | length = params->length; 44 | 45 | /* Loop through all vector elements. */ 46 | while (length--) { 47 | /* Compute the absolute value of src and store to dst. */ 48 | if (*src < 0) { 49 | *dst++ = -*src++; 50 | } 51 | else { 52 | *dst++ = *src++; 53 | } 54 | } 55 | 56 | return MSP_SUCCESS; 57 | } 58 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_abs_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise absolute value of a single source vector. 37 | */ 38 | msp_status msp_abs_q15(const msp_abs_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | uint16_t length; 41 | 42 | /* Initialize the loop counter with the vector length. */ 43 | length = params->length; 44 | 45 | #ifndef MSP_DISABLE_DIAGNOSTICS 46 | /* Check that length parameter is a multiple of two. */ 47 | if (length & 1) { 48 | return MSP_SIZE_ERROR; 49 | } 50 | #endif //MSP_DISABLE_DIAGNOSTICS 51 | 52 | /* Loop through all vector elements. */ 53 | while (length--) { 54 | /* Compute the absolute value of src and store to dst. */ 55 | if (*src < 0) { 56 | *dst++ = -*src++; 57 | } 58 | else { 59 | *dst++ = *src++; 60 | } 61 | } 62 | 63 | return MSP_SUCCESS; 64 | } 65 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_add_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise addition of two complex source vectors without saturation. 37 | */ 38 | msp_status msp_cmplx_add_iq31(const msp_cmplx_add_iq31_params *params, const _iq31 *srcA, const _iq31 *srcB, _iq31 *dst) 39 | { 40 | msp_add_iq31_params paramsTemp; 41 | 42 | /* Use real vector addition function. */ 43 | paramsTemp.length = params->length << 1; 44 | 45 | return msp_add_iq31(¶msTemp, srcA, srcB, dst); 46 | } 47 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_add_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise addition of two complex source vectors without saturation. 37 | */ 38 | msp_status msp_cmplx_add_q15(const msp_cmplx_add_q15_params *params, const _q15 *srcA, const _q15 *srcB, _q15 *dst) 39 | { 40 | msp_add_q15_params paramsTemp; 41 | 42 | /* Use real vector addition function. */ 43 | paramsTemp.length = params->length << 1; 44 | 45 | return msp_add_q15(¶msTemp, srcA, srcB, dst); 46 | } 47 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_conj_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise complex conjugate of a single complex source vector. 37 | */ 38 | msp_status msp_cmplx_conj_q15(const msp_cmplx_conj_q15_params *params, const _q15 *src, _q15 *dst) 39 | { 40 | uint16_t length; 41 | 42 | /* Initialize the loop counter with the vector length. */ 43 | length = params->length; 44 | 45 | /* Loop through all vector elements. */ 46 | while (length--) { 47 | /* Take the complex conjugate of src and store to dst. */ 48 | *dst++ = *src++; // real 49 | *dst++ = -*src++; // imaginary 50 | } 51 | 52 | return MSP_SUCCESS; 53 | } 54 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_mpy_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise Q31 multiplication of two complex source vectors. 37 | */ 38 | msp_status msp_cmplx_mpy_iq31(const msp_cmplx_mpy_iq31_params *params, const _iq31 *srcA, const _iq31 *srcB, _iq31 *dst) 39 | { 40 | uint16_t length; 41 | 42 | /* Initialize the loop counter with the vector length. */ 43 | length = params->length; 44 | 45 | #if defined(__MSP430_HAS_MPY32__) 46 | uint16_t *dstPtr = (uint16_t *)dst; 47 | 48 | /* If MPY32 is available save control context and set to fractional mode. */ 49 | uint16_t ui16MPYState = MPY32CTL0; 50 | MPY32CTL0 = MPYFRAC | MPYDLYWRTEN; 51 | 52 | /* Loop through all vector elements. */ 53 | while (length--) { 54 | /* Complex multiply srcA and srcB and store to dst. */ 55 | MPYS32L = (uint16_t)CMPLX_REAL(srcA); 56 | MPYS32H = (uint16_t)(CMPLX_REAL(srcA) >> 16); 57 | OP2L = (uint16_t)CMPLX_REAL(srcB); 58 | OP2H = (uint16_t)(CMPLX_REAL(srcB) >> 16); 59 | MACS32L = (uint16_t)(-CMPLX_IMAG(srcA)); 60 | MACS32H = (uint16_t)(-CMPLX_IMAG(srcA) >> 16); 61 | OP2L = (uint16_t)CMPLX_IMAG(srcB); 62 | OP2H = (uint16_t)(CMPLX_IMAG(srcB) >> 16); 63 | *dstPtr++ = RES2; 64 | *dstPtr++ = RES3; 65 | MPYS32L = (uint16_t)CMPLX_REAL(srcA); 66 | MPYS32H = (uint16_t)(CMPLX_REAL(srcA) >> 16); 67 | OP2L = (uint16_t)CMPLX_IMAG(srcB); 68 | OP2H = (uint16_t)(CMPLX_IMAG(srcB) >> 16); 69 | MACS32L = (uint16_t)(CMPLX_IMAG(srcA)); 70 | MACS32H = (uint16_t)(CMPLX_IMAG(srcA) >> 16); 71 | OP2L = (uint16_t)CMPLX_REAL(srcB); 72 | OP2H = (uint16_t)(CMPLX_REAL(srcB) >> 16); 73 | *dstPtr++ = RES2; 74 | *dstPtr++ = RES3; 75 | 76 | /* Increment pointers. */ 77 | srcA += CMPLX_INCREMENT; 78 | srcB += CMPLX_INCREMENT; 79 | } 80 | 81 | /* Restore MPY32 control context. */ 82 | MPY32CTL0 = ui16MPYState; 83 | #else //__MSP430_HAS_MPY32__ 84 | /* Loop through all vector elements. */ 85 | while (length--) { 86 | /* Complex multiply srcA and srcB and store to dst. */ 87 | *dst++ = (((int64_t)CMPLX_REAL(srcA) * (int64_t)CMPLX_REAL(srcB)) - ((int64_t)CMPLX_IMAG(srcA) * (int64_t)CMPLX_IMAG(srcB))) >> 31; 88 | *dst++ = (((int64_t)CMPLX_REAL(srcA) * (int64_t)CMPLX_IMAG(srcB)) + ((int64_t)CMPLX_IMAG(srcA) * (int64_t)CMPLX_REAL(srcB))) >> 31; 89 | 90 | /* Increment pointers. */ 91 | srcA += CMPLX_INCREMENT; 92 | srcB += CMPLX_INCREMENT; 93 | } 94 | #endif //__MSP430_HAS_MPY32__ 95 | 96 | return MSP_SUCCESS; 97 | } 98 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_mpy_real_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise Q15 multiplication of a complex source vector with a real source vector. 37 | */ 38 | msp_status msp_cmplx_mpy_real_q15(const msp_cmplx_mpy_real_q15_params *params, const _q15 *srcCmplx, const _q15 *srcReal, _q15 *dst) 39 | { 40 | uint16_t length; 41 | 42 | /* Initialize the loop counter with the vector length. */ 43 | length = params->length; 44 | 45 | #if defined(__MSP430_HAS_MPY32__) 46 | /* If MPY32 is available save control context and set to fractional mode. */ 47 | uint16_t ui16MPYState = MPY32CTL0; 48 | MPY32CTL0 = MPYFRAC | MPYDLYWRTEN; 49 | 50 | /* Loop through all vector elements. */ 51 | while (length--) { 52 | /* Multiply srcCmplx and srcReal and store to dst. */ 53 | MPYS = *srcReal++; 54 | OP2 = *srcCmplx++; 55 | *dst++ = RESHI; 56 | OP2 = *srcCmplx++; 57 | *dst++ = RESHI; 58 | } 59 | 60 | /* Restore MPY32 control context. */ 61 | MPY32CTL0 = ui16MPYState; 62 | #else //__MSP430_HAS_MPY32__ 63 | /* Loop through all vector elements. */ 64 | while (length--) { 65 | /* Multiply srcCmplx and srcReal and store to dst. */ 66 | *dst++ = __q15mpy(*srcCmplx++, *srcReal); // real 67 | *dst++ = __q15mpy(*srcCmplx++, *srcReal++); // imaginary 68 | } 69 | #endif //__MSP430_HAS_MPY32__ 70 | 71 | return MSP_SUCCESS; 72 | } 73 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_scale_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise Q15 multiplication of a single complex source vector 37 | * with a Q15 real scale value and shift left by scale. 38 | */ 39 | msp_status msp_cmplx_scale_iq31(const msp_cmplx_scale_iq31_params *params, const _iq31 *src, _iq31 *dst) 40 | { 41 | msp_scale_iq31_params paramsTemp; 42 | 43 | /* Use real vector scale function with twice the length. */ 44 | paramsTemp.length = params->length << 1; 45 | paramsTemp.scale = params->scale; 46 | paramsTemp.shift = params->shift; 47 | 48 | return msp_scale_iq31(¶msTemp, src, dst); 49 | } 50 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_scale_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise Q15 multiplication of a single complex source vector 37 | * with a Q15 real scale value and shift left by scale. 38 | */ 39 | msp_status msp_cmplx_scale_q15(const msp_cmplx_scale_q15_params *params, const _q15 *src, _q15 *dst) 40 | { 41 | msp_scale_q15_params paramsTemp; 42 | 43 | /* Use real vector scale function with twice the length. */ 44 | paramsTemp.length = params->length << 1; 45 | paramsTemp.scale = params->scale; 46 | paramsTemp.shift = params->shift; 47 | 48 | return msp_scale_q15(¶msTemp, src, dst); 49 | } 50 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_sub_iq31.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise subtraction of two complex source vectors without saturation. 37 | */ 38 | msp_status msp_cmplx_sub_iq31(const msp_cmplx_sub_iq31_params *params, const _iq31 *srcA, const _iq31 *srcB, _iq31 *dst) 39 | { 40 | msp_sub_iq31_params paramsTemp; 41 | 42 | /* Use real vector subtraction function. */ 43 | paramsTemp.length = params->length << 1; 44 | 45 | return msp_sub_iq31(¶msTemp, srcA, srcB, dst); 46 | } 47 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_cmplx_sub_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise subtraction of two complex source vectors without saturation. 37 | */ 38 | msp_status msp_cmplx_sub_q15(const msp_cmplx_sub_q15_params *params, const _q15 *srcA, const _q15 *srcB, _q15 *dst) 39 | { 40 | msp_sub_q15_params paramsTemp; 41 | 42 | /* Use real vector subtraction function. */ 43 | paramsTemp.length = params->length << 1; 44 | 45 | return msp_sub_q15(¶msTemp, srcA, srcB, dst); 46 | } 47 | -------------------------------------------------------------------------------- /capuchin-MCU/DSPLib/source/vector/msp_scale_q15.c: -------------------------------------------------------------------------------- 1 | /* --COPYRIGHT--,BSD 2 | * Copyright (c) 2016, Texas Instruments Incorporated 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * * Neither the name of Texas Instruments Incorporated nor the names of 17 | * its contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * --/COPYRIGHT--*/ 32 | 33 | #include "../../include/DSPLib.h" 34 | 35 | /* 36 | * Perform element wise Q15 multiplication of a single source vector with a Q15 37 | * scale value and shift left by shift. 38 | */ 39 | msp_status msp_scale_q15(const msp_scale_q15_params *params, const _q15 *src, _q15 *dst) 40 | { 41 | uint16_t length; 42 | uint8_t shift; 43 | int32_t scale; 44 | 45 | /* Initialize the loop counter, scale and shift variables. */ 46 | length = params->length; 47 | scale = params->scale; 48 | shift = params->shift; 49 | 50 | #ifndef MSP_DISABLE_DIAGNOSTICS 51 | /* Check that length parameter is a multiple of two. */ 52 | if (length & 1) { 53 | return MSP_SIZE_ERROR; 54 | } 55 | 56 | /* Check for invalid shift size (maximum of 15). */ 57 | if (shift > 15) { 58 | return MSP_SHIFT_SIZE_ERROR; 59 | } 60 | #endif //MSP_DISABLE_DIAGNOSTICS 61 | 62 | #if defined(__MSP430_HAS_MPY32__) 63 | /* If MPY32 is available save control context and set to fractional mode. */ 64 | uint16_t ui16MPYState = MPY32CTL0; 65 | MPY32CTL0 = MPYFRAC | MPYDLYWRTEN; 66 | 67 | /* Combine the scale and shift parameters to a single 32-bit variable than can be reused. */ 68 | while (shift--) { 69 | scale = scale << 1; 70 | } 71 | 72 | /* Load MPY32 registers for the first argument with the new scale value. */ 73 | MPYS32L = (uint16_t)scale; 74 | MPYS32H = (uint16_t)(scale >> 16); 75 | 76 | /* Loop through all vector elements. */ 77 | while (length--) { 78 | /* Multiply src and the combined scale and shift value. */ 79 | OP2 = *src++; 80 | *dst++ = RESHI; 81 | } 82 | 83 | /* Restore MPY32 control context. */ 84 | MPY32CTL0 = ui16MPYState; 85 | #else //__MSP430_HAS_MPY32__ 86 | /* Recalculate shift value to be a shift right offset by the default Q15 shift by 15. */ 87 | shift = 15 - shift; 88 | 89 | /* Loop through all vector elements. */ 90 | while (length--) { 91 | /* Multiply src by scale and shift result right by the offset shift value. */ 92 | *dst++ = (_q15)(((int32_t)*src++ * (int32_t)scale) >> shift); 93 | } 94 | #endif //__MSP430_HAS_MPY32__ 95 | 96 | return MSP_SUCCESS; 97 | } 98 | -------------------------------------------------------------------------------- /capuchin-MCU/Debug/Capuchin-MCU.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/Capuchin-MCU.out -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_cascade_df1_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_cascade_df1_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_cascade_df2_ext_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_cascade_df2_ext_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_cascade_df2_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_cascade_df2_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_df1_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_df1_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_df2_ext_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_df2_ext_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_df2_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_biquad_df2_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_cmplx_fir_iq31.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_cmplx_fir_iq31.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_cmplx_fir_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_cmplx_fir_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_fir_iq31.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_fir_iq31.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/msp_fir_q15.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leleonardzhang/Capuchin/76b6eb223f1b6da27520064a8f52b9df6fa4cab5/capuchin-MCU/Debug/DSPLib/source/filter/msp_fir_q15.obj -------------------------------------------------------------------------------- /capuchin-MCU/Debug/DSPLib/source/filter/subdir_rules.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | SHELL = cmd.exe 6 | 7 | # Each subdirectory must supply rules for building sources it contributes 8 | DSPLib/source/filter/%.obj: ../DSPLib/source/filter/%.c $(GEN_OPTS) | $(GEN_FILES) $(GEN_MISC_FILES) 9 | @echo 'Building file: "$<"' 10 | @echo 'Invoking: MSP430 Compiler' 11 | "C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-msp430_21.6.0.LTS/bin/cl430" -vmspx --data_model=large --use_hw_mpy=F5 --include_path="C:/ti/ccs1110/ccs/ccs_base/msp430/include" --include_path="C:/Users/Leonard/Desktop/Capuchin-main/Capuchin-main/capuchin-MCU/DSPLib/include" --include_path="C:/Users/Leonard/Desktop/Capuchin-main/Capuchin-main/capuchin-MCU" --include_path="C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-msp430_21.6.0.LTS/include" --advice:power="all" --advice:hw_config="all" --define=__MSP430FR5994__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="DSPLib/source/filter/$(basename $( 2 | 3 | #ifndef INIT_GUARD 4 | #define INIT_GUARD 5 | 6 | void init_gpio(void); 7 | void init_clock_system(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /capuchin-MCU/layers/layers.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../math/matrix_ops.h" 3 | #include "../math/matrix.h" 4 | #include "../math/fixed_point_ops.h" 5 | #include "../utils/utils.h" 6 | #include "../neural_network_parameters.h" 7 | 8 | #ifndef LAYERS_GUARD 9 | #define LAYERS_GUARD 10 | 11 | 12 | // Standard Neural Network Functions 13 | 14 | matrix *filter_simple(matrix *result, matrix *input, matrix *filter, uint16_t precision, uint16_t stride_numRows, uint16_t stride_numCols); 15 | matrix *maxpooling(matrix* result, matrix *input, uint16_t pool_numRows, uint16_t pool_numCols); 16 | matrix *flatten(matrix* result, matrix *input, uint16_t num_filter); 17 | matrix *padding_same(matrix *result, matrix *input, matrix *filter, uint16_t stride_numRows, uint16_t stride_numCols); 18 | matrix *maxpooling_filters(matrix *result, matrix *input, uint16_t numFilters, uint16_t pool_numRows, uint16_t pool_numCols); 19 | matrix *filters_sum(matrix *result, matrix *input, matrix *filter, uint16_t numChannels, int16_t b, int16_t (*activation)(int16_t, uint16_t), uint16_t precision, uint16_t stride_numRows, uint16_t stride_numCols, uint16_t padding, uint16_t conv_numRows, uint16_t conv_numCols); 20 | matrix *conv2d(matrix *result, matrix *input, matrix *filter, uint16_t numFilters, uint16_t numChannels, int16_t *b, int16_t (*activation)(int16_t, uint16_t), uint16_t precision, uint16_t stride_numRows, uint16_t stride_numCols, uint16_t padding); 21 | matrix *apply_leakyrelu(matrix *result, matrix *input, uint16_t precision); 22 | matrix *dense(matrix *result, matrix *input, matrix *W, matrix *b, int16_t (*activation)(int16_t, uint16_t), uint16_t precision); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /capuchin-MCU/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * Include processing inputs, outputs and applying deep learning models 4 | */ 5 | 6 | #include "main.h" 7 | 8 | void main(void){ 9 | 10 | /* stop watchdog timer */ 11 | WDTCTL = WDTPW | WDTHOLD; 12 | 13 | /* initialize GPIO System */ 14 | init_gpio(); 15 | 16 | /* initialize the clock and baudrate */ 17 | init_clock_system(); 18 | 19 | /* GSC dataset consists of 32*32 spectrograms */ 20 | inputFeatures.numRows = INPUT_NUM_ROWS; 21 | inputFeatures.numCols = INPUT_NUM_COLS; 22 | inputFeatures.data = input_buffer; 23 | 24 | /* output consists of 35 classes */ 25 | outputLabels.numRows = OUTPUT_NUM_LABELS; 26 | outputLabels.numCols = LEA_RESERVED; // one more column is reserved for LEA 27 | outputLabels.data = output_buffer; 28 | 29 | /* apply model saved in neural_network_parameters.h on input */ 30 | apply_model(&outputLabels, &inputFeatures); 31 | label = argmax(&outputLabels); 32 | 33 | __no_operation(); 34 | } 35 | -------------------------------------------------------------------------------- /capuchin-MCU/main.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "DSPLib.h" 4 | #include "neural_network_parameters.h" 5 | #include "math/matrix.h" 6 | #include "init.h" 7 | #include "decoder/decoder.h" 8 | 9 | #ifndef MAIN_GUARD 10 | #define MAIN_GUARD 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /capuchin-MCU/math/fixed_point_ops.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../utils/utils.h" 3 | 4 | #ifndef FIXED_POINT_OPS_GUARD 5 | #define FIXED_POINT_OPS_GUARD 6 | 7 | int16_t fp_add(int16_t x, int16_t y); 8 | int16_t fp_mul(int16_t x, int16_t y, uint16_t precision); 9 | int16_t fp_sub(int16_t x, int16_t y); 10 | int16_t fp_div(int16_t x, int16_t y, uint16_t precision); 11 | int16_t fp_neg(int16_t x); 12 | int16_t fp_mod(int16_t x, int16_t m, uint16_t precision); 13 | int16_t fp_tanh(int16_t x, uint16_t precision); 14 | int16_t fp_sigmoid(int16_t x, uint16_t precision); 15 | int16_t fp_relu(int16_t x, uint16_t precision); 16 | int16_t fp_leaky_relu(int16_t x, uint16_t precision); 17 | int16_t fp_linear(int16_t x, uint16_t precision); 18 | int16_t fp_round_to_int(int16_t x, uint16_t precision); 19 | int16_t convert_fp(int16_t x, uint16_t old_precision, uint16_t new_precision); 20 | int16_t float_to_fp(float x, uint16_t precision); 21 | int16_t int_to_fp(int16_t x, uint16_t precision); 22 | 23 | // 32 bit fixed point operations for improved precision. These are slightly more expensive 24 | // on 16 bit MCUs 25 | int32_t fp32_add(int32_t x, int32_t y); 26 | int32_t fp32_neg(int32_t x); 27 | int32_t fp32_sub(int32_t x, int32_t y); 28 | int32_t fp32_mul(int32_t x, int32_t y, uint16_t precision); 29 | int32_t fp32_div(int32_t x, int32_t y, uint16_t precision); 30 | int32_t fp32_sqrt(int32_t x, uint16_t precision); 31 | int32_t int_to_fp32(int32_t x, uint16_t precision); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /capuchin-MCU/math/matrix.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef MATRIX_GUARD 4 | #define MATRIX_GUARD 5 | 6 | typedef int16_t dtype; 7 | 8 | struct matrix { 9 | dtype *data; 10 | uint16_t numRows; 11 | uint16_t numCols; 12 | }; 13 | typedef struct matrix matrix; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /capuchin-MCU/math/matrix_ops.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "matrix.h" 3 | #include "fixed_point_ops.h" 4 | #include "../utils/utils.h" 5 | #include "../neural_network_parameters.h" 6 | 7 | // Imports when compiling for the MSP430 device 8 | #ifdef IS_MSP 9 | #include 10 | #include "DSPLib.h" 11 | 12 | #define DMA_CHANNEL_0 (0x00) 13 | #define DMA_CHANNEL_1 (0x10) 14 | #define DMA_CHANNEL_2 (0x20) 15 | #define DMA_CHANNEL_3 (0x30) 16 | #define DMA_CHANNEL_4 (0x40) 17 | #define DMA_CHANNEL_5 (0x50) 18 | #define DMA_CHANNEL_6 (0x60) 19 | #define DMA_CHANNEL_7 (0x70) 20 | #endif 21 | 22 | #ifndef MATRIX_OPS_GUARD 23 | #define MATRIX_OPS_GUARD 24 | 25 | #define VECTOR_COLUMN(X) ((X) * VECTOR_COLS) 26 | 27 | 28 | //// For MSP implementations, we allocate memory in the LEA RAM. 29 | //// This memory is used when executing matrix multiplications. 30 | //DSPLIB_DATA(MULTIPLY_BUFFER, 4); 31 | //static dtype MULTIPLY_BUFFER[1600]; 32 | 33 | matrix *filter_LEA(matrix* result, matrix *input, matrix *filter, uint16_t precision, uint16_t stride_numRows, uint16_t stride_numCols); 34 | // Standard matrix operations 35 | matrix *matrix_add(matrix *result, matrix *mat1, matrix *mat2); 36 | matrix *matrix_multiply(matrix *result, matrix *mat1, matrix *mat2, uint16_t precision); 37 | matrix *matrix_hadamard(matrix *result, matrix *mat1, matrix *mat2, uint16_t precision); 38 | matrix *matrix_neg(matrix *result, matrix *mat, uint16_t precision); 39 | matrix *scalar_product(matrix *result, matrix *mat, int16_t scalar, uint16_t precision); 40 | matrix *scalar_add(matrix *result, matrix *mat, int16_t scalar); 41 | matrix *apply_elementwise(matrix *result, matrix *mat, int16_t (*fn)(int16_t, uint16_t), uint16_t precision); 42 | matrix *matrix_set(matrix *mat, int16_t value); 43 | matrix *matrix_replace(matrix *dst, matrix *src); 44 | matrix *vstack(matrix *result, matrix *mat1, matrix *mat2); 45 | int16_t dot_product(matrix *vec1, matrix *vec2, uint16_t precision); 46 | uint16_t *argsort(matrix *vec, uint16_t *result); 47 | matrix *sparsemax(matrix *result, matrix *vec, uint16_t precision); 48 | 49 | // Operations useful for various neural network functions 50 | int16_t argmax(matrix *vec); 51 | int16_t matrix_sum(matrix *mat); 52 | int16_t matrix_min(matrix *mat); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /capuchin-MCU/targetConfigs/MSP430FR5994.ccxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /capuchin-MCU/targetConfigs/readme.txt: -------------------------------------------------------------------------------- 1 | The 'targetConfigs' folder contains target-configuration (.ccxml) files, automatically generated based 2 | on the device and connection settings specified in your project on the Properties > General page. 3 | 4 | Please note that in automatic target-configuration management, changes to the project's device and/or 5 | connection settings will either modify an existing or generate a new target-configuration file. Thus, 6 | if you manually edit these auto-generated files, you may need to re-apply your changes. Alternatively, 7 | you may create your own target-configuration file for this project and manage it manually. You can 8 | always switch back to automatic target-configuration management by checking the "Manage the project's 9 | target-configuration automatically" checkbox on the project's Properties > General page. -------------------------------------------------------------------------------- /capuchin-MCU/utils/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_GUARD 2 | #define UTILS_GUARD 3 | 4 | #define UNUSED(x) (void)(x) 5 | static void *NULL_PTR = (void *) 0x0; 6 | 7 | #endif 8 | --------------------------------------------------------------------------------